Skip to content

Instantly share code, notes, and snippets.

@patik
Created February 18, 2013 18:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save patik/4979331 to your computer and use it in GitHub Desktop.
Save patik/4979331 to your computer and use it in GitHub Desktop.
// @name Redirect from WikiTravel to WikiVoyage
// @description Automatically switch from a WikiTravel.org article to the same article on WikiVoyage.org
// @namespace http://patik.com/code/user-scripts/
// @include http://wikitravel.org/*
// @version v20130218.1
// ==/UserScript==
(function _wikivoyage_redir (win) {
// Example
// Before: http://wikitravel.org/en/Bangkok/Sukhumvit
// After: http://en.wikivoyage.org/wiki/Bangkok/Sukhumvit
var currUrl = win.location.href,
travRegex = /\/\/wikitravel\.org\/(\w+)\/(.+)/i,
pieces;
// 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] + '.wikivoyage.org/wiki/' + pieces[2];
}(this));
@gotson
Copy link

gotson commented Sep 8, 2015

Thanks !

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