Problem: I want to replace the use of one website with another, by changing the URL.
Solution: Using Greasemonkey, rewrite the location of the browser.
For this example, Wikipedia is replaced with Infogalactic.
// Tested 2016-10-28 on Windows 10 64bit, using Pale Moon 26.5.0 (x64) and Greasemonkey 1.15.1 signed. // ==UserScript== // @name Wikipedia to Infogalactic redirector // @namespace wikipedia_to_infogalactic_redirector // @description Redirect Wikipedia links to Infogalactic // @include https://en.wikipedia.org/wiki/Main_Page* // @include https://en.wikipedia.org/wiki/Main_Page* // @version 1.0 // @grant none // ==/UserScript== //window.alert( window.location.href.replace( "en.wikipedia.org/wiki", "infogalactic.com/info" ) ); window.location = window.location.href.replace( "en.wikipedia.org/wiki", "infogalactic.com/info" );
Problems ∞
This rewrites the URL after it is visited, meaning the first website must be loaded before the second one is redirected-to. While it’s amusing to burn the bandwidth of the disliked website, it takes time to load the new page.

Nice. I was digging some JS and was looking for sth like this, and I wondered how the country code part can be generalised and incorporated. I would like to create a one-liner, that is working with any language variant of wikipedia. Sorta like a bookmark, to change over manually. Thanks for the example.
Regular expressions will do what you’re looking for. Good luck on your project!