is there a way to pause (and later unpause) all running js scripts on a 3rd party site using greasemonkey?

Go To StackoverFlow.com

2

tl;dr -- is this possible to pause or stop all running js on the page, using greasemonkey?

here is the situation: i hate how, when watching videos on fb, they stutter. i am 99% sure the stutter is caused by the excessive amounts of js running in the background (providing all the realtime page updates)

here is what i want to do: create some code that will pause all js execution (i will attach it to a button or possibly autodetect when a video is playing) -- and then later resume execution (after video is done)(this part is not essential, i can always reload the page)

Now i know i can use an addon like noscript to pause-unpause but it would be nice if i could have something automagic (and alot more slimline)

2012-04-05 01:48
by RozzA
This should be possible with GM but pretty involved and very site-specific You'd need to overwrite JS functions and objects on a case-by-case basis and anonymous objects would be an even bigger challenge. You're probably better off writing an extension -- which can use privileged tools, that GM scripts can't access, to pause JS. The Web Developer toolbar's Disable Javascript seems to work well as a pause in most cases - Brock Adams 2012-04-05 02:12
thanks Brock - was hoping for something reasonably simple - no way i want to dig thru fb's plethora. looks like it might have to be an extention: "FBvidSmoother" ??
I have verified the JS is the cause - as there is no lag using Opera (which somehow powers on no matter what scripts are doing - RozzA 2012-04-05 14:27
offtopic: you can also try tinkering with defineMagicFunction in Opera, but (sorry @BrockAdams) i think you cannot pause javascript execution in correct and reliable way, if there is any non-trivial code - c69 2012-04-05 14:51
but do you really need GM for the task you described ? just use Opera, F12->Disable javascript, F12->Enable javascript - c69 2012-04-05 14:53
@c69, What you cannot pause, you can block and replace with something that you can pause. It is possible, but, as I said, GM is not the best tool for this job - Brock Adams 2012-04-05 22:02
Opera actually doesn't have the lag issue, so this is kinda like a firefox-fix to remove script caused lag. the lag it present across facebook but is most noticable when watching videos. it doesn't affect audio either, just the visual. i notice it happens on vimeo too - RozzA 2012-04-08 09:28


1

No, there is no easy general-purpose Greasemonkey solution to stop or block the execution of a web page's scripts. Greasemonkey can add, but not remove, javascript. Opera's way beefier User Javascript system can do both.

/ Greasemonkey co-maintainer

2012-05-08 02:43
by ecmanaut
Ads