Skip to content

Instantly share code, notes, and snippets.

@LOuroboros
Created November 18, 2022 16:42
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 LOuroboros/7e7204e14dd5612f3486af29b66fae97 to your computer and use it in GitHub Desktop.
Save LOuroboros/7e7204e14dd5612f3486af29b66fae97 to your computer and use it in GitHub Desktop.
Force Mobile Bulbapedia
// ==UserScript==
// @name Force Mobile Bulbapedia
// @match *://bulbapedia.bulbagarden.net/*
// @run-at document-start
// @grant none
// ==/UserScript==
var oldUrlPath = window.location.pathname;
// Check if ".m" is present in the URL. If not, append it before the host.
if (window.location.href.indexOf(".m") <= -1)
{
var newURL = window.location.protocol + "//" + "m."
+ window.location.host
+ oldUrlPath
+ window.location.search
+ window.location.hash
;
// replace() puts the good page in the history instead of the bad page.
window.location.replace (newURL);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment