Created
May 6, 2020 06:59
-
-
Save auxiliary-character/646c0caa546539c482d45b7a75ae9e50 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Mobile Redirect | |
// @version 1.0 | |
// @description general purpose mobile->desktop redirect | |
// @author auxchar | |
// @match *://*/* | |
// @grant none | |
// ==/UserScript== | |
function redirect_mobile(matcher){ | |
var match = matcher.exec(window.location); | |
if(match != null) { | |
var uri = match[1] + match[2]; | |
window.location.replace(uri); | |
} | |
} | |
var standard_matcher = /(https?:\/\/)(?:mobile|m)\.(.*)/; | |
redirect_mobile(standard_matcher); | |
//wikipedia has en.m.whatever for it's schema, which requires its own regex | |
var wikipedia_matcher = /(https?:\/\/en\.)m\.(.*)/ | |
redirect_mobile(wikipedia_matcher); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment