How to block inline userscript (greasemonkey)?

Ask for help about NoScript, no registration needed to post
100
Posts: 1
Joined: Thu Jul 31, 2014 11:37 pm

How to block inline userscript (greasemonkey)?

Post by 100 »

Guys,

Big fan of NoScript and first time posting, please excuse if this is not the right forum and point me to the right direction.

I noticed that some tracking codes/websites have inline GreaseMonkey/UserScript such as Tumblr tracker Unfollower Hater. On one website, where it was probably poorly inserted, I saw nearly 500 lines of GreaseMonkey related javascript embedded in it toward the end / after the end html tag.

My question: is there a way to block execution of all inline GreaseMonkey/UserScript scripts within a page/domain?

Thanks,
Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Firefox/31.0
User avatar
Thrawn
Master Bug Buster
Posts: 3106
Joined: Mon Jan 16, 2012 3:46 am
Location: Australia
Contact:

Re: How to block inline userscript (greasemonkey)?

Post by Thrawn »

I don't understand. Greasemonkey scripts are provided by *you*. If they're not doing what you want, then change them.

Scripts provided by the site are not Greasemonkey/user scripts.
======
Thrawn
------------
Religion is not the opium of the masses. Daily life is the opium of the masses.

True religion, which dares to acknowledge death and challenge the way we live, is an attempt to wake up.
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:31.0) Gecko/20100101 Firefox/31.0
barbaz
Senior Member
Posts: 11144
Joined: Sat Aug 03, 2013 5:45 pm

Re: How to block inline userscript (greasemonkey)?

Post by barbaz »

@100: I went to that site and I'm not seeing what you're seeing. Can you post one such script here? (wrap in code tags please)
Also, other than NoScript, what addons (& versions) do you have?
*Always* check the changelogs BEFORE updating that important software!
Mozilla/5.0 (X11; OpenBSD amd64; rv:26.0) Gecko/20100101 Firefox/26.0 SeaMonkey/2.23
oakoi
Posts: 1
Joined: Fri Sep 19, 2014 7:55 pm

Re: How to block inline userscript (greasemonkey)?

Post by oakoi »

I'm curious, I want to know if it possible to allow Greasemonkey script to run but disable the website's script. Although some userscript/Greasemonkey does work without enabling NoScript on that domain some/most userscript will not function properly.
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.31 (KHTML like Gecko) Chrome/26.0.1410.63 Safari/537.31
barbaz
Senior Member
Posts: 11144
Joined: Sat Aug 03, 2013 5:45 pm

Re: How to block inline userscript (greasemonkey)?

Post by barbaz »

I don't think Greasemonkey can do that (not sure, because I've never gotten it to work at all), but Scriptish can in most cases.

Also, NoScript has a feature surrogate scripts that can run conditionally based on site permissions status.
*Always* check the changelogs BEFORE updating that important software!
Mozilla/5.0 (Windows NT 5.1; rv:32.0) Gecko/20100101 Firefox/32.0 SeaMonkey/2.29
oakoi2

Re: How to block inline userscript (greasemonkey)?

Post by oakoi2 »

I might have wrote it in a confusing way.

I mean like so (example):

Using NoScripts:
Allow "mozilla.com" (using NoScript) so it mean it can run everything, JavaScript (website) and JavaScript (user / greasemonkey) , Plugins, HTML5(?)

What I essentially want to do is like so;

Allow "mozilla.com" (using NoScript) so it mean it can run everything, JavaScript (website) and JavaScript (user / greasemonkey) , Plugins, HTML5(?)
"Limited" Allow "firefox.com", e.g. Only allow JavaScript (user / greasemonkey), block everything else.

If you did understood what I was asking and answer with the surrogate solution, then I apologize. It just seem a bit complicated and annoying to use.
Opera/9.80 (Macintosh; Intel Mac OS X 10.6.8; U; en) Presto/2.9.168 Version/11.52
barbaz
Senior Member
Posts: 11144
Joined: Sat Aug 03, 2013 5:45 pm

Re: How to block inline userscript (greasemonkey)?

Post by barbaz »

Oh, sorry for the misunderstanding. It would have helped if you started a new thread for that, because your question is unrelated to the OP.
Anyway, the option you're looking for is
NoScript Options > Embeddings > Apply these restrictions to whitelisted sites too

To whitelist sites for plugin content, use
about:config -> noscript.allowedMimeRegExp
*Always* check the changelogs BEFORE updating that important software!
Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20140618 Firefox/24.0 PaleMoon/24.6.2
User avatar
Thrawn
Master Bug Buster
Posts: 3106
Joined: Mon Jan 16, 2012 3:46 am
Location: Australia
Contact:

Re: How to block inline userscript (greasemonkey)?

Post by Thrawn »

barbaz wrote: Anyway, the option you're looking for is
NoScript Options > Embeddings > Apply these restrictions to whitelisted sites too
Actually, I don't think that that is what oakoi wants...s/he wants to run userscript without allowing the domain's own scripts.

And the answer is, if the userscript runs in the page context, then there is no way for NoScript to tell them apart, whereas if it runs in a privileged context, then it's allowed already.
======
Thrawn
------------
Religion is not the opium of the masses. Daily life is the opium of the masses.

True religion, which dares to acknowledge death and challenge the way we live, is an attempt to wake up.
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:32.0) Gecko/20100101 Firefox/32.0
barbaz
Senior Member
Posts: 11144
Joined: Sat Aug 03, 2013 5:45 pm

Re: How to block inline userscript (greasemonkey)?

Post by barbaz »

Thrawn wrote:
barbaz wrote: Anyway, the option you're looking for is
NoScript Options > Embeddings > Apply these restrictions to whitelisted sites too
Actually, I don't think that that is what oakoi wants...s/he wants to run userscript without allowing the domain's own scripts.

And the answer is, if the userscript runs in the page context, then there is no way for NoScript to tell them apart, whereas if it runs in a privileged context, then it's allowed already.
@Thrawn: That is the question I answered with this post
*Always* check the changelogs BEFORE updating that important software!
Mozilla/5.0 (Windows NT 5.1; rv:32.0) Gecko/20100101 Firefox/32.0 SeaMonkey/2.29
oakoi2

Re: How to block inline userscript (greasemonkey)?

Post by oakoi2 »

Thank you. Having to use create rules each time via about:config is rather time consuming, I guess I will go make a request in NoScript Wishlist.

Considering how the thread is related to what I wanted to know I did not think creating a new thread was appropriate.
Opera/9.80 (Windows NT 6.1; U; en) Presto/2.9.181 Version/12.00
barbaz
Senior Member
Posts: 11144
Joined: Sat Aug 03, 2013 5:45 pm

Re: How to block inline userscript (greasemonkey)?

Post by barbaz »

oakoi2 wrote:Having to use create rules each time via about:config is rather time consuming
In what way?
If it's because of minifying the code to fit it into the pref, you could put the surrogate script's file: URL instead of the JS code. But note that changes to the script don't take effect immediately in that case.
oakoi2 wrote:Considering how the thread is related to what I wanted to know I did not think creating a new thread was appropriate.
My apologies for the misunderstanding, when I said that I didn't realize that you weren't asking something like "how do I allow only some (Temp)Allowed sites to run plugin content".
*Always* check the changelogs BEFORE updating that important software!
Mozilla/5.0 (X11; Linux i686; rv:32.0) Gecko/20140924 SeaMonkey/2.29.1pre
Post Reply