URL

View: New views
9 Messages — Rating Filter:   Alert me  

URL

by Jamie.ds :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Right I have a load of urls on one page that look something like this
http://www.anonym.to/?[LINK]
I wantto make a script that changes all the url's on the page to just
[LINK]
so it removes the
http://www.anonym.to/?
at the beginning, how do I go about this?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "greasemonkey-users" group.
To post to this group, send email to greasemonkey-users@...
To unsubscribe from this group, send email to greasemonkey-users+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/greasemonkey-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: URL

by Jamie.ds :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Anyone? I have found a script that can substitute an ip for a url if
its in the script, but it doesnt really help.

On 31 Oct, 23:40, "Jamie.ds" <waterstonja...@...> wrote:
> Right I have a load of urls on one page that look something like thishttp://www.anonym.to/?[LINK]
> I wantto make a script that changes all the url's on the page to just
> [LINK]
> so it removes thehttp://www.anonym.to/?
> at the beginning, how do I go about this?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "greasemonkey-users" group.
To post to this group, send email to greasemonkey-users@...
To unsubscribe from this group, send email to greasemonkey-users+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/greasemonkey-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: URL

by qufighter :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


var elms = getElementsByTagName('a');
for( i in elms ){
 elms[i].href=unescape(elms[i].href.replace('something',''));
}

replace something with whatever it is you wish to delete.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "greasemonkey-users" group.
To post to this group, send email to greasemonkey-users@...
To unsubscribe from this group, send email to greasemonkey-users+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/greasemonkey-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: URL

by Jamie.ds :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


i got
var elms = getElementsByTagName('a');
for( i in elms ){
 elms[i].href=unescape(elms[i].href.replace('http://
www.anonym.to/?',''));
}

But it's still in the links.

On Nov 2, 8:13 pm, qufighter <qufigh...@...> wrote:
> var elms = getElementsByTagName('a');
> for( i in elms ){
>  elms[i].href=unescape(elms[i].href.replace('something',''));
>
> }
>
> replace something with whatever it is you wish to delete.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "greasemonkey-users" group.
To post to this group, send email to greasemonkey-users@...
To unsubscribe from this group, send email to greasemonkey-users+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/greasemonkey-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: URL

by cc-21 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Try printf-debugging it by sticking GM_log statements around the
statement in the loop, e.g.

GM_log("after: " + elms[i].href);

would go after the statement. If you have to, run checks like using
indexOf() to see if the string you're looking for is in there in the
first place, etc.

Also, make sure the script compiles and runs to the end by sticking a
GM_log there ;-).

Finally, it occurs to me that these hrefs may be relative, e.g.
'?[LINK]' rather than 'http://www.anonym.to/?[LINK]'; check on that with
View Source or Firebug (tooltips and status bar will not help here).

On 2009-11-02 22:52, Jamie.ds wrote:

> i got
> var elms = getElementsByTagName('a');
> for( i in elms ){
>   elms[i].href=unescape(elms[i].href.replace('http://
> www.anonym.to/?',''));
> }
>
> But it's still in the links.
>
> On Nov 2, 8:13 pm, qufighter<qufigh...@...>  wrote:
>    
>> var elms = getElementsByTagName('a');
>> for( i in elms ){
>>   elms[i].href=unescape(elms[i].href.replace('something',''));
>>
>> }
>>
>> replace something with whatever it is you wish to delete.
>>      


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "greasemonkey-users" group.
To post to this group, send email to greasemonkey-users@...
To unsubscribe from this group, send email to greasemonkey-users+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/greasemonkey-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: URL

by Anthony Lieuallen :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On 11/03/09 02:20, cc wrote:
> Finally, it occurs to me that these hrefs may be relative, e.g.
> '?[LINK]' rather than 'http://www.anonym.to/?[LINK]'; check on that with
> View Source or Firebug (tooltips and status bar will not help here).

The element.href style access always gives you the full URL.  Doing
element.getAttribute('href') gives you the content actually in the href
attribute, which may be i.e. a relative link.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "greasemonkey-users" group.
To post to this group, send email to greasemonkey-users@...
To unsubscribe from this group, send email to greasemonkey-users+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/greasemonkey-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: URL

by Jamie.ds :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Don't think think there is a relative link, heres the link im on about
http://da-forums.info/viewtopic.php?search_id=1844107524&t=567
in the top post.

On 3 Nov, 13:53, Anthony Lieuallen <arant...@...> wrote:
> On 11/03/09 02:20, cc wrote:
>
> > Finally, it occurs to me that these hrefs may be relative, e.g.
> > '?[LINK]' rather than 'http://www.anonym.to/?[LINK]'; check on that with
> > View Source or Firebug (tooltips and status bar will not help here).
>
> The element.href style access always gives you the full URL.  Doing
> element.getAttribute('href') gives you the content actually in the href
> attribute, which may be i.e. a relative link.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "greasemonkey-users" group.
To post to this group, send email to greasemonkey-users@...
To unsubscribe from this group, send email to greasemonkey-users+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/greasemonkey-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: URL

by qufighter :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Thanks for including a link to the page your running it on, that helps
your case a lot.  For one thing I made a mistake posting my code, it
should probably be [CONTEXT].getElementsByTagName('A').  For your
purposes you can probably just put document or document.body for
[context], although narrowing your start element down will speed up
the search.  Chances are your not getting in the loop yet, and elms
has zero items, but this should all be easy for you to confirm with
GM_log(elms.length) or the dreaded alert(elms.length) before the
loop.  If you tracing stuff within the loop then don't use alert
because you'll have to close a zillion dialogs.

In any case since you posted the link:
var elms = document.getElementsByTagName('a');
for( i in elms ){
 if( typeof(elms[i].href) != 'undefined' && elms[i].href.indexOf
('anonym.to') > 0 )
  elms[i].href=unescape(elms[i].href.replace('h t t p : / / w w w .
anonym.to/?',''));
}

Added another test, because not all A tags had a HREF, and not all a
tags were anonym links either, so this only applies the replace to the
specified links.  Remove the extra spaces from the URL.

On Nov 3, 12:57 pm, "Jamie.ds" <waterstonja...@...> wrote:

> Don't think think there is a relative link, heres the link im on abouthttp://da-forums.info/viewtopic.php?search_id=1844107524&t=567
> in the top post.
>
> On 3 Nov, 13:53, Anthony Lieuallen <arant...@...> wrote:
>
>
>
> > On 11/03/09 02:20, cc wrote:
>
> > > Finally, it occurs to me that these hrefs may be relative, e.g.
> > > '?[LINK]' rather than 'http://www.anonym.to/?[LINK]'; check on that with
> > > View Source or Firebug (tooltips and status bar will not help here).
>
> > The element.href style access always gives you the full URL.  Doing
> > element.getAttribute('href') gives you the content actually in the href
> > attribute, which may be i.e. a relative link.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "greasemonkey-users" group.
To post to this group, send email to greasemonkey-users@...
To unsubscribe from this group, send email to greasemonkey-users+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/greasemonkey-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: URL

by Jamie.ds :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Ahh I thank you for your help, that has helped me alot.

On Nov 3, 9:51 pm, qufighter <qufigh...@...> wrote:

> Thanks for including a link to the page your running it on, that helps
> your case a lot.  For one thing I made a mistake posting my code, it
> should probably be [CONTEXT].getElementsByTagName('A').  For your
> purposes you can probably just put document or document.body for
> [context], although narrowing your start element down will speed up
> the search.  Chances are your not getting in the loop yet, and elms
> has zero items, but this should all be easy for you to confirm with
> GM_log(elms.length) or the dreaded alert(elms.length) before the
> loop.  If you tracing stuff within the loop then don't use alert
> because you'll have to close a zillion dialogs.
>
> In any case since you posted the link:
> var elms = document.getElementsByTagName('a');
> for( i in elms ){
>  if( typeof(elms[i].href) != 'undefined' && elms[i].href.indexOf
> ('anonym.to') > 0 )
>         elms[i].href=unescape(elms[i].href.replace('h t t p : / / w w w .
> anonym.to/?',''));
>
> }
>
> Added another test, because not all A tags had a HREF, and not all a
> tags were anonym links either, so this only applies the replace to the
> specified links.  Remove the extra spaces from the URL.
>
> On Nov 3, 12:57 pm, "Jamie.ds" <waterstonja...@...> wrote:
>
> > Don't think think there is a relative link, heres the link im on abouthttp://da-forums.info/viewtopic.php?search_id=1844107524&t=567
> > in the top post.
>
> > On 3 Nov, 13:53, Anthony Lieuallen <arant...@...> wrote:
>
> > > On 11/03/09 02:20, cc wrote:
>
> > > > Finally, it occurs to me that these hrefs may be relative, e.g.
> > > > '?[LINK]' rather than 'http://www.anonym.to/?[LINK]'; check on that with
> > > > View Source or Firebug (tooltips and status bar will not help here).
>
> > > The element.href style access always gives you the full URL.  Doing
> > > element.getAttribute('href') gives you the content actually in the href
> > > attribute, which may be i.e. a relative link.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "greasemonkey-users" group.
To post to this group, send email to greasemonkey-users@...
To unsubscribe from this group, send email to greasemonkey-users+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/greasemonkey-users?hl=en
-~----------~----~----~----~------~----~------~--~---