Skip to content

Commit

Permalink
Merge pull request mouseas#84 from Eriner/auto-refresh
Browse files Browse the repository at this point in the history
Add auto-refresh option
  • Loading branch information
wchill committed Jun 14, 2015
2 parents d918835 + d73012f commit be1ccff
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions autoPlay.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@ var removeParticles = getPreferenceBoolean("removeParticles", true);
var removeFlinching = getPreferenceBoolean("removeFlinching", true);
var removeCritText = getPreferenceBoolean("removeCritText", false);
var removeAllText = getPreferenceBoolean("removeAllText", false);
var enableAutoRefresh = getPreferenceBoolean("enableAutoRefresh", typeof GM_info !== "undefined");

var enableElementLock = getPreferenceBoolean("enableElementLock", true);

var autoRefreshMinutes = 30; // refresh page after x minutes

// DO NOT MODIFY
var isAlreadyRunning = false;
var currentClickRate = clickRate;
Expand Down Expand Up @@ -69,6 +72,7 @@ var ENEMY_TYPE = {
"TREASURE":4
};

var refreshTimer = null; // global to cancel running timers if disabled after timer has already started
var GITHUB_BASE_URL = "https://raw.githubusercontent.com/pkolodziejczyk/steamSummerMinigame/master/";


Expand Down Expand Up @@ -135,6 +139,10 @@ function firstRun() {
document.body.style.backgroundPosition = "0 0";
}

if (enableAutoRefresh) {
autoRefreshPage(autoRefreshMinutes);
}

if (w.CSceneGame !== undefined) {
w.CSceneGame.prototype.DoScreenShake = function() {};
}
Expand Down Expand Up @@ -162,6 +170,9 @@ function firstRun() {
checkboxes.style["column-count"] = 2;

checkboxes.appendChild(makeCheckBox("enableAutoClicker", "Enable autoclicker", enableAutoClicker, toggleAutoClicker));
if (typeof GM_info !== "undefined") {
checkboxes.appendChild(makeCheckBox("enableAutoRefresh", "Enable auto-refresh (fix memory leak)", enableAutoRefresh, toggleAutoRefresh));
}
checkboxes.appendChild(makeCheckBox("removeInterface", "Remove interface (needs refresh)", removeInterface, handleEvent));
checkboxes.appendChild(makeCheckBox("removeParticles", "Remove particle effects (needs refresh)", removeParticles, handleEvent));
checkboxes.appendChild(makeCheckBox("removeFlinching", "Remove flinching effects (needs refresh)", removeFlinching, handleEvent));
Expand Down Expand Up @@ -284,6 +295,17 @@ function toggleAutoClicker(event) {
}
}

function toggleAutoRefresh(event) {
var value = enableAutoRefresh;
if(event !== undefined)
value = handleCheckBox(event);
if(value) {
autoRefreshPage(autoRefreshMinutes);
} else {
clearTimeout(refreshTimer);
}
}

function toggleElementLock(event) {
var value = enableElementLock;
if(event !== undefined)
Expand Down Expand Up @@ -1103,6 +1125,9 @@ function getClickDamage(){
return g_Minigame.m_CurrentScene.m_rgPlayerTechTree.damage_per_click;
}

function autoRefreshPage(autoRefreshMinutes){
refreshTimer = setTimeout(function(){w.location.reload(true);},autoRefreshMinutes*1000*60);
}
function fixActiveCapacityUI(){
$J('.tv_ui').css('background-image','url("'+GITHUB_BASE_URL+'game_frame_tv_fix.png")');
$J('#activeinlanecontainer').css('height','134px');
Expand Down

0 comments on commit be1ccff

Please sign in to comment.