Skip to content

Instantly share code, notes, and snippets.

@heavyLobster2
Last active June 26, 2016 18:26
Show Gist options
  • Save heavyLobster2/cc3ee6205e96c3f9c76c to your computer and use it in GitHub Desktop.
Save heavyLobster2/cc3ee6205e96c3f9c76c to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Redirect Mobile Pages
// @description Redirects mobile pages to the desktop version
// @version 1.0.6
// @author heavyLobster2
// @namespace github.com/heavyLobster2
// @downloadURL https://gist.github.com/heavyLobster2/cc3ee6205e96c3f9c76c/raw/RedirectMobilePages.user.js
// @include *://*.m.wikipedia.org/*
// @include *://m.reddit.com/*
// @run-at document-start
// @grant none
// ==/UserScript==
(function () {
"use strict";
var oldUrl = window.location.href;
var newUrl = null;
var hostname = (new URL(oldUrl)).hostname;
if (hostname.includes(".m.wikipedia.org")) {
newUrl = oldUrl.replace(".m.wikipedia.org", ".wikipedia.org");
} else if (hostname === "m.reddit.com") {
newUrl = oldUrl.replace("m.reddit.com", "www.reddit.com");
}
if (newUrl !== null) {
window.location.replace(newUrl);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment