snipt

Ctrl+h for KB shortcuts

JavaScript

Replace parts of current URL and go to it

javascript:(function() {var curloc = location.href; curloc = curloc.replace(/www/g,"cp");curloc = curloc.replace(/view/g,"edit"); location.href = curloc; })();
https://snipt.net/embed/a46bb815b13d7481c21ec93c46beae3c/
/raw/a46bb815b13d7481c21ec93c46beae3c/
a46bb815b13d7481c21ec93c46beae3c
js
JavaScript
1
2019-06-18T05:01:45
True
False
False
/api/public/snipt/43196/
replace-parts-of-current-url-and-go-to-it
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="nx">javascript</span><span class="o">:</span><span class="p">(</span><span class="kd">function</span><span class="p">()</span> <span class="p">{</span><span class="kd">var</span> <span class="nx">curloc</span> <span class="o">=</span> <span class="nx">location</span><span class="p">.</span><span class="nx">href</span><span class="p">;</span> <span class="nx">curloc</span> <span class="o">=</span> <span class="nx">curloc</span><span class="p">.</span><span class="nx">replace</span><span class="p">(</span><span class="sr">/www/g</span><span class="p">,</span><span class="s2">&quot;cp&quot;</span><span class="p">);</span><span class="nx">curloc</span> <span class="o">=</span> <span class="nx">curloc</span><span class="p">.</span><span class="nx">replace</span><span class="p">(</span><span class="sr">/view/g</span><span class="p">,</span><span class="s2">&quot;edit&quot;</span><span class="p">);</span> <span class="nx">location</span><span class="p">.</span><span class="nx">href</span> <span class="o">=</span> <span class="nx">curloc</span><span class="p">;</span> <span class="p">})();</span> </span></pre></div> </td></tr></table>
bookmarklet, javascript