dcsimg
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,968
    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 );
    STOP using $ prefix on JavaScript variable names...
    Please remember to wrap any code you have in forum tags:-

    [CODE]...[/CODE] [HTML]...[/HTML] [PHP]...[/PHP]

    If you can't think outside the box, you will be trapped forever with no escape...

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