You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.7 KiB
42 lines
1.7 KiB
// ==UserScript==
|
|
// @name VirtualBlinders
|
|
// @namespace Utopiah
|
|
// @description Stay focus, damnit!
|
|
// @include *youtube.com*
|
|
// ==/UserScript==
|
|
|
|
/* TODO
|
|
|
|
# improve the list of websites to include
|
|
## consider include * then refine pattern per task
|
|
# make timers (default to 0 sec, value defined via the script or a GM_Value) to be more flexible
|
|
## reset timer either manually or per day (i.e.) reset if last set date <5AM
|
|
## set 2 thresholds, the first as a warning, the second as an action
|
|
|
|
Note that it does work even when Flash has focus.
|
|
|
|
*/
|
|
|
|
var t;
|
|
var MODE="video";
|
|
var time_spent = GM_getValue(MODE,0);
|
|
|
|
GM_xmlhttpRequest({
|
|
method: "GET",
|
|
url: "http://fabien.benetou.fr/pub/currenttask",
|
|
onload: function(response) {
|
|
task = response.responseText;
|
|
if (task == 'Reading\n' || task == 'Programming\n'){
|
|
//document.body.innerHTML="You should be focusing on <a href=\"http://fabien.benetou.fr/CognitiveEnvironments/" + task + "\">"+task+"</a> instead,\nare you sure you need that information from that website?";
|
|
document.body.innerHTML="You should be focusing on <a href=\"http://fabien.benetou.fr/CognitiveEnvironments/" + task + "\">"+task+"</a> instead,\nare you sure you need that information from that website? <br/>Note that you have already spent <span id='timespent'>"+time_spent+"</span> seconds on that website so far!<hr/>"+document.body.innerHTML;
|
|
t=setInterval(mytimer,1000);
|
|
//see http://commons.oreilly.com/wiki/index.php/Greasemonkey_Hacks/Getting_Started#Pitfall_.231:_Auto-eval_Strings
|
|
}
|
|
}
|
|
});
|
|
|
|
function mytimer(){
|
|
time_spent=time_spent+1;
|
|
document.getElementById('timespent').innerText=time_spent;
|
|
GM_setValue(MODE,time_spent);
|
|
}
|
|
|