Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
// @name Redirect from WikiTravel to WikiVoyage
// @description Automatically switch from a article to the same article on
// @namespace
// @include*
// @version v20130218.1
// ==/UserScript==
(function _wikivoyage_redir (win) {
// Example
// Before:
// After:
var currUrl = win.location.href,
travRegex = /\/\/wikitravel\.org\/(\w+)\/(.+)/i,
// Make sure it's a valid, parse-able WikiTravel article URL
if (!travRegex.test(currUrl)) { return; }
// Split into [full url, language, article name]
pieces = travRegex.exec(currUrl);
// Redirect immediately
win.location.href = 'http://' + pieces[1] + '' + pieces[2];

This comment has been minimized.

Copy link

@gotson gotson commented Sep 8, 2015

Thanks !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment