regex - Replace parts of a URL in Greasemonkey -


I'm trying to change a portion of the URL using Greasemonkey script, but what I try to do To am doing

The same as the original Urls:

  http://x1.example.to/images/thumb/50/157/1571552600.jpg http: // X2. Example.to/images/thumb/50/120/1201859695.jpg http://x3.example.to/images/thumb/50/210/2109983330.jpg  

Do I have to I want to get:

  http://example.to/images/full/50/157/1571552600.jpg http://example.to/images/full/50/ 120 / 1201859695.jpg http://example.to/images/full/50/210/2109983330.jpg  

I just thumb < x2 < / Strong> .example.to, x3 .example.to, x4 .example.to etc. Originally a completely new URL like example.to/images/full /

will start from the original URL, how do I get it?

I have got a Gramzakki script and I tried to work but failed.

Here's what I have done here.

  // == Ususcript == // @name Examples Images Fixer // @namespace Example // @ Descriptive Image Gallery Resolves // @ Include http: // *. Example.to/* // ==/userscript == var links = document.getElementsByTagName ("a"); // array var regex = /^(http:\/\/)([^]]+)(\.example\.to\/images\/thumb/\)(.+)$/i; (Var i = 0, imax = links.length; i & lt; imax; i ++) {link [i] .href = links [i]. Href.replace (regex, "$ 4full / $ 5"); }  

Any help on that?

You are forgetting entering http: // in your replacement URL To:

  / ^ (https ?: \ / \ /) [^.] + \. (Example \ .to \ / images \ /) thumbs \ / (. +) $ / I  

and after:

  .replace (regex , "$ 1 $ 2full / $ 3");  

You can see the results.


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -