[Optional about:config] Temporary pause setInterval if..

Talk about code development, features, specific bugs, enhancements, patches, and similar things.
Forum rules
Please keep everything here strictly on-topic.
This board is meant for Pale Moon source code development related subjects only like code snippets, patches, specific bugs, git, the repositories, etc.

This is not for tech support! Please do not post tech support questions in the "Development" board!
Please make sure not to use this board for support questions. Please post issues with specific websites, extensions, etc. in the relevant boards for those topics.

Please keep things on-topic as this forum will be used for reference for Pale Moon development. Expect topics that aren't relevant as such to be moved or deleted.
jangdonggun1234
Fanatic
Fanatic
Posts: 104
Joined: 2013-06-06, 01:29

[Optional about:config] Temporary pause setInterval if..

Unread post by jangdonggun1234 » 2015-04-26, 17:35

Hi Moon,

I want to request a new feature.
We all know, setInterval, setTimeout (can use as setinterval and repeat forever), AnimationFrame... can do something like good animation, clock, slide banner that change every 100-1xxxxx second depend on what developer want.

That feature is sometime helpful, but it cause a BIG problem, CPU intensive, and may waste user bandwidth for example they create XMLHttpRequest to refresh page HTML by request server HTML and then replace document.body.outerHTML with responseText from that XMLHttpRequest, that wast huge bandwidth, and that also help some site track you by sending http request on background every xxx second(s).

So it is possible for Palemoon Pause all kind of timer event if user switch tab ? There is probably no addon do such thing, unload tab type addon is overkill for this situation.

So I want to request you a about:config to prevent that from happening, there are user like me who don't want to be tracked, waste my BW, and waste my CPU cycle for suck thing.

An example to clear my request:

Code: Select all


function handleRequest(req) {
    document.body.outerHTML = req.responseText;
    
    //document.addEventListener("click", three);
    //e.target.setAttribute("onclick", req.responseText );
	//return req.responseText;
}

    
    
    
    
    function sendRequest(url,callback,postData) {
	var req = createXMLHTTPObject();
	if (!req) return;
	var method = (postData) ? "POST" : "GET";
	req.open(method,url,true);
	req.setRequestHeader('User-Agent','XMLHTTP/1.0');
	if (postData)
		req.setRequestHeader('Content-type','application/x-www-form-urlencoded');
	req.onreadystatechange = function () {
		if (req.readyState != 4) return;
		if (req.status != 200 && req.status != 304) {
//			alert('HTTP error ' + req.status);
			return;
		}
		callback(req);
	}
	if (req.readyState == 4) return;
	req.send(postData);
}

var XMLHttpFactories = [
	function () {return new XMLHttpRequest()},
	function () {return new ActiveXObject("Msxml2.XMLHTTP")},
	function () {return new ActiveXObject("Msxml3.XMLHTTP")},
	function () {return new ActiveXObject("Microsoft.XMLHTTP")}
];

function createXMLHTTPObject() {
	var xmlhttp = false;
	for (var i=0;i<XMLHttpFactories.length;i++) {
		try {
			xmlhttp = XMLHttpFactories[i]();
		}
		catch (e) {
			continue;
		}
		break;
	}
	return xmlhttp;
}


function autoreload() {
sendRequest(document.location.href, handleRequest);
}
window.setInterval(autoreload, "3000");

    
    
    
    
Run it using ScratchPad. Open Network Tool and see, even we switch tab it still run and eat out BW, CPU.
Thank!

squarefractal

Re: [Optional about:config] Temporary pause setInterval if..

Unread post by squarefractal » 2015-04-26, 18:20

As a temporary measure, why don't you try to block scripting with Noscript? It doesn't exactly do what you want, but blocking scripting entirely from bad domains can give you a very lightweight browsing experience.

jangdonggun1234
Fanatic
Fanatic
Posts: 104
Joined: 2013-06-06, 01:29

Re: [Optional about:config] Temporary pause setInterval if..

Unread post by jangdonggun1234 » 2015-04-26, 18:40

squarefractal wrote:As a temporary measure, why don't you try to block scripting with Noscript? It doesn't exactly do what you want, but blocking scripting entirely from bad domains can give you a very lightweight browsing experience.
My main purpose is save CPU, BW, block script kind of overkill, and I'm sure that NoScript is not suit lazy people who don't want to spend time clicking to unblock/block site if they Block scripts globally.

squarefractal

Re: [Optional about:config] Temporary pause setInterval if..

Unread post by squarefractal » 2015-04-26, 18:48

jangdonggun1234 wrote:I'm sure that NoScript is not suit lazy people who don't want to spend time clicking to unblock/block site if they Block scripts globally.
You could set Noscript to "Scripts globally allowed" and then manually mark domains as untrusted. If you are "lazy" to even do that -- my list of untrusted domains are posted below. In about:config, set noscript.untrusted to the following value (click on "show"). Also, make sure to visit a few sites that you yourself visit and mark ad domains as untrusted.

Code: Select all

addthis.com adobedtm.com adzerk.net bluekai.com bttrack.com crwdcntrl.net d3qxef4rp70elm.cloudfront.net ensighten.com google-analytics.com googleadservices.com googlesyndication.com googletagmanager.com googletagservices.com newrelic.com ooyala.com optimizely.com outbrain.com quantserve.com reinvigorate.net scorecardresearch.com servebom.com statcounter.com taboola.com yldbt.com http://addthis.com http://adobedtm.com http://adzerk.net http://bluekai.com http://bttrack.com http://crwdcntrl.net http://ensighten.com http://google-analytics.com http://googleadservices.com http://googlesyndication.com http://googletagmanager.com http://googletagservices.com http://newrelic.com http://ooyala.com http://optimizely.com http://outbrain.com http://quantserve.com http://reinvigorate.net http://scorecardresearch.com http://servebom.com http://statcounter.com http://taboola.com http://yldbt.com https://addthis.com https://adobedtm.com https://adzerk.net https://bluekai.com https://bttrack.com https://crwdcntrl.net https://ensighten.com https://google-analytics.com https://googleadservices.com https://googlesyndication.com https://googletagmanager.com https://googletagservices.com https://newrelic.com https://ooyala.com https://optimizely.com https://outbrain.com https://quantserve.com https://reinvigorate.net https://scorecardresearch.com https://servebom.com https://statcounter.com https://taboola.com https://yldbt.com
Noscript can also act as an adblocker, too. (Hint: ABE). But all that, I suppose, is too offtopic for this thread...

megaman

Re: [Optional about:config] Temporary pause setInterval if..

Unread post by megaman » 2015-04-26, 19:00

Off-topic:
squarefractal wrote:Noscript can also act as an adblocker, too. (Hint: ABE). But all that, I suppose, is too offtopic for this thread...
Thanks for the info. Too much work these days.

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 35636
Joined: 2011-08-28, 17:27
Location: Motala, SE
Contact:

Re: [Optional about:config] Temporary pause setInterval if..

Unread post by Moonchild » 2015-04-30, 10:56

Javascript timed events are already clamped in background tabs (unless you pin them). See the preference dom.min_background_timeout_value preference for SetTimeout. If you want to restrict this further (at the risk of breaking site scripting) you can increase this value -- it's listed in ms.

Since this is basic, essential functionality for javascript/DOM execution, the responsibility for using it in a sane manner lands on the shoulders of the web designer. If it causes excessive resource usage because of bad use of this, then you should contact the website owner to have this fixed.

I will not set out on this path of making everything pref-able in the browser that can possibly be resource-intensive because of poor use -- because there is no end to that.
"Sometimes, the best way to get what you want is to be a good person." -- Louis Rossmann
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite

jangdonggun1234
Fanatic
Fanatic
Posts: 104
Joined: 2013-06-06, 01:29

Re: [Optional about:config] Temporary pause setInterval if..

Unread post by jangdonggun1234 » 2015-05-01, 17:30

-- See the preference dom.min_background_timeout_value preference for SetTimeout.

Thank you, solved! I don't even know that new config!

Locked