Discussion:
Disable Javascript setInterval and timers
Gus Wirth
2012-05-10 15:03:16 UTC
Permalink
Has anyone heard of a Firefox plugin that will disable the Javascript
functions setInterval and setTimer? I've found that about the only use
for these is to produce really annoying moving text or images on a web
page that that I'm trying to read.

Or do I have to resort to hacking Firefox to turn those functions into
null functions? I'm not sure how Javascript works as far as function
redefinition goes. But doing a little more research I found Greasemonkey.

I'm looking at this script for the Greasemonkey plugin:

http://userscripts.org/scripts/review/99430

which is intended to log setInterval and setTimer calls, but I think I
can just gut the function calls and return null. Or maybe I'll save the
old timers and make a button to restore them.

Gus
Gus Wirth
2012-05-22 14:15:25 UTC
Permalink
Post by Gus Wirth
Has anyone heard of a Firefox plugin that will disable the Javascript
functions setInterval and setTimer? I've found that about the only use
for these is to produce really annoying moving text or images on a web
page that that I'm trying to read.
Or do I have to resort to hacking Firefox to turn those functions into
null functions? I'm not sure how Javascript works as far as function
redefinition goes. But doing a little more research I found Greasemonkey.
http://userscripts.org/scripts/review/99430
which is intended to log setInterval and setTimer calls, but I think I
can just gut the function calls and return null. Or maybe I'll save the
old timers and make a button to restore them.
Just some small tweaks and this is perfect for what I want. It kills all
the moving text and pictures, auto-refresh, and the stupid "how long
have I been on this web page" trackers.

<Script>

// ==UserScript==
// @name Kill Javascript Timers
// @namespace localhost
// @description Kills javascript setTimeout and setInterval calls.
// @include *
// based on an original script at http://jazzychad.net/
// hacked by Gus Wirth to generically remove timers
// ==/UserScript==

var go = function(window){

var oldSetInterval = window.setInterval;
var newSetInterval = function(f,t) {
return;
};
window.setInterval = newSetInterval;

var oldSetTimeout = window.setTimeout;
var newSetTimeout = function (f,t) {
return;
};
window.setTimeout = newSetTimeout;

};

var script = document.createElement('script');
script.setAttribute("type", "application/javascript");
script.textContent = '(' + go + ')(window);';
document.body.appendChild(script); // run the script

<Script/>

I haven't found a web site yet where I might need to restore the timers
but I think I can just add a menu item it restore the timers if I need
them. I'll work on it if I find a use for it.

Gus

Loading...