diff --git a/greasemonkey/virtualblinders.user.js b/greasemonkey/virtualblinders.user.js index bdea8d1..ebd5c4c 100644 --- a/greasemonkey/virtualblinders.user.js +++ b/greasemonkey/virtualblinders.user.js @@ -9,7 +9,7 @@ # handle background tab ## stop timer when focus lost window.onunload or window.onblur ## restart timer when focus is back window.load or window.onfocus -## XXX failing so far +## XXX what is happening when 2 background tabs are increasing the timer?! # improve the list of websites to include ## consider include * then refine window.location pattern per task # make timers (default to 0 sec, value defined via the script or a GM_Value) to be more flexible @@ -34,10 +34,10 @@ GM_xmlhttpRequest({ }); function responseCheck(task) { - //task = 'Reading\n'; + task = 'Reading\n'; timeThreshold = 600; aboveThreshold = ( timeThreshold < time_spent ); - //aboveThreshold = true; + aboveThreshold = false; if (task == 'Reading\n' || task == 'Programming\n'){ if ( !aboveThreshold ) { //under threshold, just display a warning and the content @@ -52,9 +52,9 @@ function responseCheck(task) { //regarding the specific syntax //see http://commons.oreilly.com/wiki/index.php/Greasemonkey_Hacks/Getting_Started#Pitfall_.231:_Auto-eval_Strings GM_log("register listeners"); - window.addEventListener("onblur", stopTimer, true); - window.addEventListener("onfocus", restartTimer, true); - window.addEventListener("onunload", setTotalTimeSpent, true); + window.addEventListener("blur", stopTimer, true); + window.addEventListener("focus", restartTimer, true); + window.addEventListener("unload", setTotalTimeSpent, true); } else { //above threshold, only display the warning without the content document.body.innerHTML="You should be focusing on