Include/Exclude Rules

in Script development
Subscribe to Include/Exclude Rules 6 posts, 5 voices



dschoon Scriptwright

I see a lot of scripts that use two lines for HTTP and HTTPS requests, something like:
"http://foo.bar"
"https://foo.bar"

Now, I'll admit I have a problem. I love elegance and I just can't stop. I try to stay away, but I just keep reducing and purifying code until it's a work of art.

So my question is: Can anyone think of a practical reason not to use "http*://foo.bar" instead?

 
alien_scum Scriptwright

That is very elegant it works and given that grease monkey only works on a limited number of protocols, it should be impossible to spoof (though if your going to be that paranoid it should have a tailing slash).
EDIT: should do my research this can be spoofed eg http://www.evil.com/steal://foo.bar
for details see the Greasespot wiki
 
Joel H Scriptwright

This brings up an interesting point: what's the regex support for the includes/excludes? If it only supports *, then you're stuck with two... if it uses standard javascript regexes, you can do a single, optional character to handle it.

-Joel

 
dschoon Scriptwright

Good call, Mr. Scum. I checked the wiki, but I didn't spend much time on it... I figured someone clever would be more thorough than myself. :)

And Joel also raises a good point. I could think of some scripts that would be nice to run on things that match certain complicated patterns that involve "/forums/".

 
Descriptor Scriptwright

* is not regex - that would be .* .
I'm sure they're just wildcards - probably * any number of characters and ? for any single character.
I think you'd want a regex like
http(s)?://([^/]+\.)?domain\.com/.*

But since it supports the key "tld" it might be better to use keys like http(s), (domain) and (sub) for any or no subdomain
So you could do the same as above with
http(s)://(sub)domain.com/*
or any userscripts forum
http(s)://(sub)userscripts.tld/forums/*
or any .com forum
http(s)://(domain).com/forums/*

 
Henrik N Admin

No regexp support, just the * wildcard and the magic tld. See http://wiki.greasespot.net/Include_and_exclude_....

Full(er) regexp support or smarter wildcars have been discussed on the mailing list. Can't recall what happened with it; probably got bogged down in conflicting opinions, or no one has been inclined to write the code.

Cross
Presentational HTML allowed.
Use <code> for inline code and <pre> for code blocks. Use &lt; and &gt; for literal < and >.
We help break paragraphs and link your links.
or cancel