Add-on to replace a known string in a URL

General questions about scripts and buttons should be asked here. Development scripts and buttons may also be posted for feedback.

Moderators: Support Staff², Support Staff, AvantGuard, Developer

Post Reply
User avatar
hornakapopolis
AvantGuard
AvantGuard
Posts: 11318
Joined: Thu Jul 31, 2003 2:09 pm
Windows Version: Windows 10 Pro 64
Avant Version: 2015
Default engine: Chrome
IE Version: 11
Skin: Stickers
Location: Ohio, USA
Contact:

Add-on to replace a known string in a URL

Post by hornakapopolis » Fri Jul 10, 2009 1:58 am

I've never really been into scripting, so if there's an easier way to do this, feel free to throw a rock at my head and point it out.

Could an add-on be made to replace a known string within a URL with something else?

I've been doing a lot of wallpaper searching lately and started running across a lot of imagevenue (I think) links that were loading to ad pages, but one of my blockers was blocking everything on the page so I couldn't click a link and I wasn't being redirected. Replacing a string in the URL would take me to the image, though, and I was figuring that there is probably some way to do that automatically.

If it matters, in this example, the entire first part of the URL could be substituted since any part of the address that changes is that the end.

User avatar
sulpherdragon
Contributor
Contributor
Posts: 222
Joined: Sat Dec 15, 2007 9:51 pm
Windows Version: Windows 7
Avant Version: 2013 Build 23
Default engine: Firefox
IE Version:
Skin:
Contact:

Re: Add-on to replace a known string in a URL

Post by sulpherdragon » Sat Jul 11, 2009 5:51 am

Hi.

Theres a few different ways to do this. One simple method is by using the following code:

Code: Select all

// loop through all links
for (var i = 0; i < document.links.length; i++)
{
             //replace microsoft with W3Schools
	document.links[i].replace(/microsoft/gi, "W3Schools");
}
I took the code from http://www.w3schools.com/jsref/jsref_replace.asp so you can read and learn how it works

the /gi means it will replace several occurances of the string and it will also be case in-sensitive.
change "microsoft" to the string you want to replace, and change "W3Schools" to the new string you need.
If you want, you can give more specific instructions and one of us could make a plugin.
I didnt get a chance to formally test it, but if it doesnt work it shouldnt be too hard to fix.

Heres hoping it solves your problem!
Image

User avatar
hornakapopolis
AvantGuard
AvantGuard
Posts: 11318
Joined: Thu Jul 31, 2003 2:09 pm
Windows Version: Windows 10 Pro 64
Avant Version: 2015
Default engine: Chrome
IE Version: 11
Skin: Stickers
Location: Ohio, USA
Contact:

Re: Add-on to replace a known string in a URL

Post by hornakapopolis » Sat Jul 11, 2009 2:17 pm

That's seems to have worked. Thanks!

I remembered it was imagevenue, so changing the code to this:

Code: Select all

// loop through all links
for (var i = 0; i < document.links.length; i++)
{
             //replace microsoft with W3Schools
   document.links[i].replace(/tempfull-aff.php?loc=loc703&/gi, "img.php?");
}
...seems to have removed their ad pages.

Of course, since the ad pages are random, you don't really know until you've gone awhile without.

Thanks again!

User avatar
hornakapopolis
AvantGuard
AvantGuard
Posts: 11318
Joined: Thu Jul 31, 2003 2:09 pm
Windows Version: Windows 10 Pro 64
Avant Version: 2015
Default engine: Chrome
IE Version: 11
Skin: Stickers
Location: Ohio, USA
Contact:

Re: Add-on to replace a known string in a URL

Post by hornakapopolis » Sat Jul 11, 2009 6:33 pm

Well, nope... doesn't work.

Like I said, I don't really know anything when it comes to scripting, but looking at this code, is it replacing a string found within a link on a page? If that's the case, then it's not working because the link that are clicked to get to these pages don't include the string.

It's one of those cases when you click a thumbnail of an image, but before you are taken to the image, you get an ad page and you must click it before you can continue.

Here's an example:

Link is posted to: http://img31.imagevenue.com/img.php?ima ... _584lo.jpg

Clicking the link first takes you to: http://img31.imagevenue.com/tempfull-af ... _584lo.jpg

Which then immediately redirects to: http://img31.imagevenue.com/uploading-aff.php

I didn't realize it was going to the last link until I just tried it on another computer. My main system's security software stops it at the second link, which is a step you don't even see when no blockers are involved.

I'm going to play around a bit more with my security software, too, but I was hoping this was something that could be done. It's going to have to either be catching the URL or making a change in the Address bar.

edit: Also, I didn't think about it until I was copying and pasting the addresses, but it might be possible that that number changes after the loc

User avatar
kudos
Support Staff²
Support Staff²
Posts: 3384
Joined: Wed Mar 22, 2006 10:35 am
Avant Version:

Re: Add-on to replace a known string in a URL

Post by kudos » Mon Jul 13, 2009 10:40 pm

Try ImageHost Grabber - a firefox extension that will download all images on a page that are hosted on an image host. Works well with Orca.
 
.:Volunteer support staff (regular user):.
Image
I am not a member of the Avant / Orca development team
Please search this forum / the Wiki before posting questions
Forum Rules | Frequently Asked Questions | Active Topics

User avatar
hornakapopolis
AvantGuard
AvantGuard
Posts: 11318
Joined: Thu Jul 31, 2003 2:09 pm
Windows Version: Windows 10 Pro 64
Avant Version: 2015
Default engine: Chrome
IE Version: 11
Skin: Stickers
Location: Ohio, USA
Contact:

Re: Add-on to replace a known string in a URL

Post by hornakapopolis » Tue Jul 14, 2009 2:31 am

Unfortunately, I don't work with Orca. ;) ...and it's something I usually do to pass the time while waiting on other things, not something I sit down specifically to do. Also, many of the times I want to see the full image before saving it.

Post Reply