including .com as well as .co.in thru a single wild card

2 views
Skip to first unread message

Vikas Pandey

unread,
May 27, 2008, 4:12:53 AM5/27/08
to greasemonkey-users
Previously, orkut was a .com site.

Today, they seem to have automatically users in our area to .co.in so my
gm scripts stopped working. I have now included/ excluded both .com
and .co.in in headers like

// @include http://www.orkut.com/*
// @include https://www.orkut.com/*
// @exclude http://www.orkut.com/Privacy.aspx
// @exclude http://www.orkut.com/About.aspx
//
// @include http://www.orkut.co.in/*
// @include https://www.orkut.co.in/*
// @exclude http://www.orkut.co.in/Privacy.aspx
// @exclude http://www.orkut.co.in/About.aspx


is there any method of using wild cards so that both can be included/
excluded thru a single command like

// @include http://www.orkut.co*
or
// @include http://www.orkut.*

and can this wild card match leaving the last specified part? like
// @exclude http://www.orkut.co*/Privacy.aspx
or
// @exclude http://www.orkut.*/Privacy.aspx

Thanks.
--
Vikas

Vikas Pandey

unread,
May 27, 2008, 4:30:42 AM5/27/08
to greasemonkey-users
Hmm, not so simple.

a different effect is that I had hard coded .com url in my code while I
was modifying the original url.


viewprofilelink.href="http://www.orkut.com/FullProfile.aspx"+"?"+linkparts[1];

But now, after it could be .co.in for me and .com for other users and
may be other .co.au or .co.uk for still other users, I can't hardcode
just .com.

So, now, how to I get the first part of the main url (the current page)
upto "http://www.orkut.com/" (or "http://www.orkut.co.in/" or whatever
equivalent) to some variable that I can then put in the code instead of
the fixed "http://www.orkut.com/".

thanks.
--
VIkas

LouCypher

unread,
May 27, 2008, 8:53:20 AM5/27/08
to greasemonkey-users
You can use the magic TLD as top level domain

http://wiki.greasespot.net/Include_and_exclude_rules
http://wiki.greasespot.net/Magic_TLD
> > // @excludehttp://www.orkut.co.in/About.aspx
>
> > is there any method of using wild cards so that both can be included/
> > excluded thru a single command like
>
> > // @includehttp://www.orkut.co*
> > or
> > // @includehttp://www.orkut.*

BD

unread,
May 28, 2008, 5:20:06 AM5/28/08
to greasemon...@googlegroups.com
I hope I'm telling you the correct info here. (it's late and I'm tired)

You can use as many "*" wildcards as you want in the include/exclude specifications. (for those more technical, all "*" characters are converted to ".*" as a regular expression part (which means "zero or more characters" — see Gm convert2RegExp.js) — it also slash-quotes the characters that need it, like periods and others)

So I would think (without trying it) that the following will probably work:

@include http*://www.orkut.co*/*
and
@exclude http*://www.orkut.co*/Privacy.aspx

There may be some issues with greedy and non-greedy matching, but I would have to think about that harder. (this should also be mentioned and explained in the wiki help section that someone gave a link to)

It would be nice (and not too difficult, really) to make a utility that lets you run a URL against an include and exclude specification and tell you if you get a match or not. (maybe there is one already; I've thought about making one myself, but never did) That would be a nice addition to the wiki. (embedded or linked — also, the wiki description really needs to be worked on (like mentioning some of the stuff I do above for the more advanced people) — I might do that, but I forget if you have to be given editor privileges)

I submitted a true, advanced regular expression enhancement for Gm a long time ago, that gives you ultimate power and control and flexibility, but it unfortunately never got picked up. (it also supported the simple matching we have now) I never added it myself because I don't like messing with and learning the version control system. And it gets mentioned and discussed from time to time, and might be on the wish list.

Vikas Pandey

unread,
May 28, 2008, 12:48:38 PM5/28/08
to greasemon...@googlegroups.com
Thanks Lou and BD.

yeah, * is working as wild character any number of times.

now, how to get the top level main part of a url that would include the tld:

if i[j].href has -> http://www.orkut.co.in/Home.aspx

then,
i[j].getAttribute("href")
/Home.aspx

i[j].href.indexOf(i[j].getAttribute("href"))
22

so, taking from start to the location of this href attribute will strip
the url and give the starting url including tld.

i[j].href.substring(0,i[j].href.indexOf(i[j].getAttribute("href")))
http://www.orkut.co.in

and if u want to include ending "/" also, then
i[j].href.substring(0,i[j].href.indexOf(i[j].getAttribute("href"))+1)
http://www.orkut.co.in/

Still, anyone having a better idea is welcome to share.

hope that helps.
--
Vikas

On 5/28/2008 2:50 PM India Time, _BD_ wrote:

> I hope I'm telling you the correct info here. (it's late and I'm tired)
>
> You can use as many "*" wildcards as you want in the include/exclude
> specifications. (for those more technical, all "*" characters are
> converted to ".*" as a regular expression part (which means "zero or
> more characters" — see Gm convert2RegExp.js) — it also slash-quotes the
> characters that need it, like periods and others)
>
> So I would think (without trying it) that the following will probably work:
>
> @include http*://www.orkut.co*/*
> and
> @exclude http*://www.orkut.co*/Privacy.aspx
>
> There may be some issues with greedy and non-greedy matching, but I
> would have to think about that harder. (this should also be mentioned
> and explained in the wiki help section that someone gave a link to)
>

> *It would be nice (and not too difficult, really) to make a utility that

> lets you run a URL against an include and exclude specification and tell

> you if you get a match or not.* (maybe there is one already; I've

neel

unread,
May 28, 2008, 4:41:32 PM5/28/08
to greasemonkey-users
hi all

yes tha issue is solved on

@include http*://www.orkut.co*/*

thanks a lot

monkey is smiling again

Reply all
Reply to author
Forward
0 new messages