Skip to content

Instantly share code, notes, and snippets.

@martindevans
Last active November 26, 2017 02:50
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 martindevans/2958bf8d45863b9cbc8505ccc05786fd to your computer and use it in GitHub Desktop.
Save martindevans/2958bf8d45863b9cbc8505ccc05786fd to your computer and use it in GitHub Desktop.
// ==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