GM mouseless-autoscroll removed images and cleaned code

master
Fabien Benetou 14 years ago committed by utopiah
parent eb7c9f0a6b
commit 9ce1269598
  1. 108
      pub/code/mouseless-autoscroll.user.js

@ -3,7 +3,14 @@
// @namespace Utopiah
// @description autoscroll without using your hands (keep them for the coffee cup ;)
// @include *
// @exclude *://mail.google.com/mail/*
// @exclude *?action=edit
// @exclude *tube.com/*
// @exclude *cartoons*
// @exclude *://mail.google.com/*
// @exclude *video*
// @exclude *.tv/*
// @exclude *vimeo.com/*
// @exclude *putlocker.com/file/*
// @require http://ecmanaut.googlecode.com/svn/trunk/lib/gm/$x$X.js
// ==/UserScript==
@ -12,7 +19,7 @@
/*
* Script homepage : http://userscripts.org/forums/1/topics/2150
* To do : check the homepage
* To do : check the homepage http://fabien.benetou.fr/Tools/Greasemonkey#MouselessAutoscroll
*/
@ -21,7 +28,7 @@
//=================================== Configuration =======================================
var SPEED_STEP=1; // step size for increase and decrease of speed
var BASE_TIME=6; // default scrolling speed in speed-step
var BASE_TIME=4; // default scrolling speed in speed-step
var MAX_SLOWEST_SPEED=10; // define the slowest speed-step
var speed=GM_getValue("speed", BASE_TIME); // load last speed value
@ -90,19 +97,19 @@ function scroll_reset () {
function hideallbuttons() {
var pauseButtonElement = document.getElementById('button_pause'); pauseButtonElement.style.visibility="hidden";
var startButtonElement = document.getElementById('button_start'); startButtonElement.style.visibility="hidden";
var fasterButtonElement = document.getElementById('button_faster'); fasterButtonElement.style.visibility="hidden";
var slowerButtonElement = document.getElementById('button_slower'); slowerButtonElement.style.visibility="hidden";
var resetButtonElement = document.getElementById('button_reset'); resetButtonElement.style.visibility="hidden";
document.getElementById('button_pause').style.visibility="hidden";
document.getElementById('button_start').style.visibility="hidden";
document.getElementById('button_faster').style.visibility="hidden";
document.getElementById('button_slower').style.visibility="hidden";
document.getElementById('button_reset').style.visibility="hidden";
};
GM_registerMenuCommand( "Start scrolling", scroll_start, "s", "", "t" );
GM_registerMenuCommand( "Pause scrolling", scroll_pause, "p", "", "p" );
GM_registerMenuCommand( "Scroll faster", scroll_faster, "l", "", "f" );
GM_registerMenuCommand( "Scroll slower", scroll_slower, "k", "", "s" );
GM_registerMenuCommand( "Reset scrolling speed", scroll_reset, "r", "", "r" );
GM_registerMenuCommand( "Start scrolling", scroll_start, "s", "", "t" );
GM_registerMenuCommand( "Pause scrolling", scroll_pause, "p", "", "p" );
GM_registerMenuCommand( "Scroll faster", scroll_faster, "l", "", "f" );
GM_registerMenuCommand( "Scroll slower", scroll_slower, "k", "", "s" );
GM_registerMenuCommand( "Reset scrolling speed", scroll_reset, "r", "", "r" );
function addGlobalStyle(css) {
@ -116,33 +123,43 @@ function addGlobalStyle(css) {
}
addGlobalStyle( 'div#scrollercontroller { position:fixed; bottom:0; right:0; }' +
'div#scrollercontroller { visibility:visible; }'+
'img.button { visibility:hidden; position:fixed; bottom:0; right:0; } '
addGlobalStyle( 'div#scrollercontroller { position:fixed; bottom:0; right:0;visibility:visible;}'
+'p.button { visibility:hidden; position:fixed; bottom:0; right:0; } '
);
// seems to be problematic on first load....
var button_pic_start = 'http://www.flvplayer4free.com/images/play.png';
var button_pic_pause = 'http://www.flvplayer4free.com/images/pause.png';
var button_pic_slower = 'http://www.flvplayer4free.com/images/rewind.png';
var button_pic_faster = 'http://www.flvplayer4free.com/images/fast-forward.png';
var button_pic_reset = 'http://www.flvplayer4free.com/images/toggle-repeat.png';
var scrollercontroller = document.createElement('div');
scrollercontroller.id = 'scrollercontroller';
var pauseButtonElement = scrollercontroller.appendChild(document.createElement('img'));
pauseButtonElement.className = 'button'; pauseButtonElement.id = 'button_pause'; pauseButtonElement.src = button_pic_pause;
var playButtonElement = scrollercontroller.appendChild(document.createElement('img'));
playButtonElement.className = 'button'; playButtonElement.id = 'button_start'; playButtonElement.src = button_pic_start;
var slowerButtonElement = scrollercontroller.appendChild(document.createElement('img'));
slowerButtonElement.className = 'button'; slowerButtonElement.id = 'button_slower'; slowerButtonElement.src = button_pic_slower;
var fasterButtonElement = scrollercontroller.appendChild(document.createElement('img'));
fasterButtonElement.className = 'button'; fasterButtonElement.id = 'button_faster'; fasterButtonElement.src = button_pic_faster;
var resetButtonElement = scrollercontroller.appendChild(document.createElement('img'));
resetButtonElement.className = 'button'; resetButtonElement.id = 'button_reset'; resetButtonElement.src = button_pic_reset;
var pauseButtonElement = document.createElement('p');
pauseButtonElement.className = 'button';
pauseButtonElement.id = 'button_pause';
pauseButtonElement.innerHTML = '||';
var playButtonElement = document.createElement('p');
playButtonElement.className = 'button';
playButtonElement.id = 'button_start';
playButtonElement.innerHTML = 'Autoscroll';
var slowerButtonElement = document.createElement('p');
slowerButtonElement.className = 'button';
slowerButtonElement.id = 'button_slower';
slowerButtonElement.innerHTML = '<<';
var fasterButtonElement = document.createElement('p');
fasterButtonElement.className = 'button';
fasterButtonElement.id = 'button_faster';
fasterButtonElement.innerHTML = '>>';
var resetButtonElement = document.createElement('p');
resetButtonElement.className = 'button';
resetButtonElement.id = 'button_reset';
resetButtonElement.innerHTML = 'reset';
scrollercontroller.appendChild(pauseButtonElement);
scrollercontroller.appendChild(playButtonElement);
scrollercontroller.appendChild(slowerButtonElement);
scrollercontroller.appendChild(fasterButtonElement);
scrollercontroller.appendChild(resetButtonElement);
// Display the visual interface
document.body.insertBefore(scrollercontroller, document.body.firstChild);
@ -180,24 +197,3 @@ function registerListener(node) {
registerShortcuts();
}, true);
}
//=================================== Indirect interface ====================================
/* does it loop ?
var was_scrolling_before_blur=true;
window.addEventListener("blur", function (e) {
if (speed<MAX_SLOWEST_SPEED) { was_scrolling_before_blur=true; }
else { was_scrolling_before_blur=false; }
scroll_pause();
}, true);
window.addEventListener("focus", focusHandler, true);
function focusHandler ( e ) {
alert('on focus');
if (was_scrolling_before_blur) { scroll_start(); }
window.removeEventListener("focus", focusHandler); window.addEventListener("blur", blurHandler, true); }
*/
// <choop> where blurHandler does the same as focusHandler, but backwards
//<choop> basically removing and adding the event listeners so they don't keep triggering and crash firefox
Loading…
Cancel
Save