www.webdeveloper.com
Results 1 to 2 of 2

Thread: modify the URL of a web page then load the new modified URL

  1. #1
    Join Date
    Jul 2014
    Posts
    1

    Exclamation modify the URL of a web page then load the new modified URL

    i want to create a script "bookmarklet" that loads the original images instead of the watermarked ones which are loaded by default from the website "fansshare.com"

    loading the original image from the site could be done by modifying the URL of the watermarked image, & the modifications would be as follows:

    watermarked image : http://img26.fansshare.com/cached/ph...1630765198.jpg

    original image : http://us.cdn001.fansshare.com/photo...1630765198.jpg

    so basically i want to replace "http://img26.fansshare.com/cached" with "http://us.cdn001.fansshare.com" & keep the rest of the URL unattached then go to the new URL.

    I found a script that could add text to the URL but i didn't know how to make it replace text in the URL rather than just add to it

    Script:

    javascript:void((function(){location.href=location.href.replace(/^http\:\/\/([^\/\@]+)\/(?/,%22http://%22+%22$1%22.replace(%22\:%22,%22.%22)+%22.us.cdn281.fansshare.com/%22);})())

    i would be very thankful if any one could help me modify the above script to make it work as i wanted to be

  2. #2
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,346
    Code:
    url = "http://img26.fanshare.com/...";
    prefix = "us.cdn001";
    // Assuming that img26 will always be constant and the unwatermarked Url prefix is also constant, you can ...
    url=url.replace("img26",prefix);
    alert( url );
    Yes, I know I'm about as subtle as being hit by a bus..(\\.\ Aug08)
    Yep... I say it like I see it, even if it is like a baseball bat in the nutz... (\\.\ Aug08)
    I want to leave this world the same way I came into it, Screaming, Incontinent & No memory!
    I laughed that hard I burst my colostomy bag... (\\.\ May03)
    Life for some is like a car accident... Mine is like a motorway pile up...

    Problems with Vista? :: Getting Cryptic wid it. :: The 'C' word! :: Whois?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles