javascript - Greasemonkey script to remove parameters from URL -



javascript - Greasemonkey script to remove parameters from URL -

i have url:

http://website.com/wp-content/uploads/2014/11/this-is-an-image_0120(pp_w820_h548).jpg

i want delete parameter url this:

http://website.com/wp-content/uploads/2014/11/this-is-an-image_0120.jpg

how possible greasemonkey?

var links = document.getelementsbytagname("a"); for(var = 0, l = links.length; < l; i++) { var elements = links[i]; elements.innerhtml = document.body.innerhtml.replace(/(pp_w820_h548)/gi, ''); }

i want width , height numbers unknown variables. images png, deleting after (, , adding ".jpg" 1 time again end not best solution.

sorry! meant targeting img element, not a. image, not link.

also pp need in there, because want remove on prophoto wp blogs.

so, it:

var links = document.getelementsbytagname("img"); for(var = 0, l = links.length; < l; i++) { var images = links[i]; images.src= images.src.replace(/\(pp_w\d+_h\d+\)/gi, ''); }

update

the script works images near viewport. lazyloaded elements on page still using plus strings in url.

is possible greasemonkey phisically alter html, not in dom?

var links = document.getelementsbytagname("a"); for(var = 0, l = links.length; < l; i++) { var = links[i]; a.href= a.href.replace(/\(pp_w\d+_h\d+\)/gi, ''); }

example: http://jsfiddle.net/houp0qv0/

javascript wordpress greasemonkey

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -