Last active
November 26, 2017 02:50
-
-
Save martindevans/2958bf8d45863b9cbc8505ccc05786fd to your computer and use it in GitHub Desktop.
This file contains 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 No more mobile links | |
// @namespace http://tampermonkey.net/ | |
// @version 0.2 | |
// @description replace mobile links with non mobile links (e.g. en.m.wikipedia with en.wikipedia) | |
// @author You | |
// @match *://*/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
function apply(mob, pc) { | |
if (window.location.href.includes(mob)) | |
{ | |
//Redirect | |
window.location.href = window.location.href.replace(mob, pc); | |
} | |
else | |
{ | |
//Replace hyperlinks | |
var links = document.links; | |
var link; | |
for(var i=links.length-1; i >=0; i--){ | |
link = links[i]; | |
link.href = link.href.replace(mob, pc); | |
} | |
} | |
} | |
apply("en.m.wikipedia.org", "en.wikipedia.org"); | |
apply("mobile.twitter.com", "twitter.com"); | |
})(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment