Last active
September 27, 2023 13:31
-
-
Save kompowiec/db10ba80ceceabc612a99abb1979b581 to your computer and use it in GitHub Desktop.
simple script to change wiki skin to monobook for Violentmonkey/tampermonkey/greasemonkey
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 change wiki skin to monobook | |
// Wikimedia projects | |
// @source Zera's userscripts | |
// @include *wikipedia.org* | |
// @include *wiktionary.org* | |
// @include *commons.wikimedia.org* | |
// @include *wikiquote.org* | |
// @include *wikibooks.org* | |
// @include *wikisource.org* | |
// @include *species.wikimedia.org* | |
// @include *wikiversity.org* | |
// @include *wikivoyage.org* | |
// @include *wikifunctions.org* | |
// @include *wikinews.org* | |
// Wikimedia | |
// @include *meta.wikimedia.org* | |
// @include **.wikimedia.org* | |
// @include *mediawiki.org* | |
// Other | |
// @include *wikiless.org* | |
// @include *wiki.archlinux.org* | |
// @grant none | |
// @run-at document-start | |
// ==/UserScript== | |
// Other skins which are supported by wikipedia: timeless, minerva, vector, vector-2022 (by default) | |
// wikiless works fine only on vector | |
// store the current URL in a variable | |
url = location.href; | |
// remove "www." from the URL if it exists | |
url = url.replace(/^https?:\/\/www\./, "https://"); | |
url = url.replace('?wprov=srpw1_0',''); | |
// check if the URL includes "wikipedia.org", includes a "#" symbol, and does not include "&useskin=monobook" | |
if (url.includes("wikipedia.org") && url.includes("#") && !url.includes("&useskin=monobook")) { | |
// find the index of the "#" symbol | |
var hashIndex = url.indexOf("#"); | |
// make sure the hash value exists | |
if (hashIndex !== -1) { | |
// extract the hash value from the URL | |
var hash = url.substring(hashIndex); | |
// remove the hash value from the URL | |
url = url.substring(0, hashIndex); | |
// replace "wikipedia.org/wiki/" with "wikipedia.org/w/index.php?title=" | |
url = url.replace("wikipedia.org/wiki/", "wikipedia.org/w/index.php?title="); | |
// append "&useskin=monobook" and the hash value to the URL | |
url = url + "&useskin=monobook" + hash; | |
// redirect the page to the updated URL | |
location.href = url; | |
} | |
} | |
// check if the URL includes "wikipedia.org" and does not include "&useskin=monobook" | |
else if (url.includes("wikipedia.org") && !url.includes("&useskin=monobook")) { | |
// replace "wikipedia.org/wiki/" with "wikipedia.org/w/index.php?title=" | |
url = url.replace("wikipedia.org/wiki/", "wikipedia.org/w/index.php?title="); | |
// append "&useskin=monobook" to the URL | |
url = url + "&useskin=monobook"; | |
// redirect the page to the updated URL | |
location.href = url; | |
} | |
if (url.includes("wiktionary.org") && url.includes("#") && !url.includes("&useskin=monobook")) { | |
var hashIndex = url.indexOf("#"); | |
if (hashIndex !== -1) { | |
var hash = url.substring(hashIndex); | |
url = url.substring(0, hashIndex); | |
url = url.replace("wiktionary.org/wiki/", "wiktionary.org/w/index.php?title="); | |
url = url + "&useskin=monobook" + hash; | |
location.href = url; | |
} | |
} | |
else if (url.includes("wiktionary.org") && !url.includes("&useskin=monobook")) { | |
url = url.replace("wiktionary.org/wiki/", "wiktionary.org/w/index.php?title="); | |
url = url + "&useskin=monobook"; | |
location.href = url; | |
} | |
if (url.includes("commons.wikimedia.org") && url.includes("#") && !url.includes("&useskin=monobook")) { | |
var hashIndex = url.indexOf("#"); | |
if (hashIndex !== -1) { | |
var hash = url.substring(hashIndex); | |
url = url.substring(0, hashIndex); | |
url = url.replace("commons.wikimedia.org/wiki/", "commons.wikimedia.org/w/index.php?title="); | |
url = url + "&useskin=monobook" + hash; | |
location.href = url; | |
} | |
} | |
else if (url.includes("commons.wikimedia.org") && !url.includes("&useskin=monobook")) { | |
url = url.replace("commons.wikimedia.org/wiki/", "commons.wikimedia.org/w/index.php?title="); | |
url = url + "&useskin=monobook"; | |
location.href = url; | |
} | |
if (url.includes("wikiquote.org") && url.includes("#") && !url.includes("&useskin=monobook")) { | |
var hashIndex = url.indexOf("#"); | |
if (hashIndex !== -1) { | |
var hash = url.substring(hashIndex); | |
url = url.substring(0, hashIndex); | |
url = url.replace("wikiquote.org/wiki/", "wikiquote.org/w/index.php?title="); | |
url = url + "&useskin=monobook" + hash; | |
location.href = url; | |
} | |
} | |
else if (url.includes("wikiquote.org") && !url.includes("&useskin=monobook")) { | |
url = url.replace("wikiquote.org/wiki/", "wikiquote.org/w/index.php?title="); | |
url = url + "&useskin=monobook"; | |
location.href = url; | |
} | |
if (url.includes("wikibooks.org") && url.includes("#") && !url.includes("&useskin=monobook")) { | |
var hashIndex = url.indexOf("#"); | |
if (hashIndex !== -1) { | |
var hash = url.substring(hashIndex); | |
url = url.substring(0, hashIndex); | |
url = url.replace("wikibooks.org/wiki/", "wikibooks.org/w/index.php?title="); | |
url = url + "&useskin=monobook" + hash; | |
location.href = url; | |
} | |
} | |
else if (url.includes("wikibooks.org") && !url.includes("&useskin=monobook")) { | |
url = url.replace("wikibooks.org/wiki/", "wikibooks.org/w/index.php?title="); | |
url = url + "&useskin=monobook"; | |
location.href = url; | |
} | |
if (url.includes("wikisource.org") && url.includes("#") && !url.includes("&useskin=monobook")) { | |
var hashIndex = url.indexOf("#"); | |
if (hashIndex !== -1) { | |
var hash = url.substring(hashIndex); | |
url = url.substring(0, hashIndex); | |
url = url.replace("wikisource.org/wiki/", "wikisource.org/w/index.php?title="); | |
url = url + "&useskin=monobook" + hash; | |
location.href = url; | |
} | |
} | |
else if (url.includes("wikisource.org") && !url.includes("&useskin=monobook")) { | |
url = url.replace("wikisource.org/wiki/", "wikisource.org/w/index.php?title="); | |
url = url + "&useskin=monobook"; | |
location.href = url; | |
} | |
if (url.includes("species.wikimedia.org") && url.includes("#") && !url.includes("&useskin=monobook")) { | |
var hashIndex = url.indexOf("#"); | |
if (hashIndex !== -1) { | |
var hash = url.substring(hashIndex); | |
url = url.substring(0, hashIndex); | |
url = url.replace("species.wikimedia.org/wiki/", "species.wikimedia.org/w/index.php?title="); | |
url = url + "&useskin=monobook" + hash; | |
location.href = url; | |
} | |
} | |
else if (url.includes("species.wikimedia.org") && !url.includes("&useskin=monobook")) { | |
url = url.replace("species.wikimedia.org/wiki/", "species.wikimedia.org/w/index.php?title="); | |
url = url + "&useskin=monobook"; | |
location.href = url; | |
} | |
if (url.includes("wikiversity.org") && url.includes("#") && !url.includes("&useskin=monobook")) { | |
var hashIndex = url.indexOf("#"); | |
if (hashIndex !== -1) { | |
var hash = url.substring(hashIndex); | |
url = url.substring(0, hashIndex); | |
url = url.replace("wikiversity.org/wiki/", "wikiversity.org/w/index.php?title="); | |
url = url + "&useskin=monobook" + hash; | |
location.href = url; | |
} | |
} | |
else if (url.includes("wikiversity.org") && !url.includes("&useskin=monobook")) { | |
url = url.replace("wikiversity.org/wiki/", "wikiversity.org/w/index.php?title="); | |
url = url + "&useskin=monobook"; | |
location.href = url; | |
} | |
if (url.includes("wikivoyage.org") && url.includes("#") && !url.includes("&useskin=monobook")) { | |
var hashIndex = url.indexOf("#"); | |
if (hashIndex !== -1) { | |
var hash = url.substring(hashIndex); | |
url = url.substring(0, hashIndex); | |
url = url.replace("wikivoyage.org/wiki/", "wikivoyage.org/w/index.php?title="); | |
url = url + "&useskin=monobook" + hash; | |
location.href = url; | |
} | |
} | |
else if (url.includes("wikivoyage.org") && !url.includes("&useskin=monobook")) { | |
url = url.replace("wikivoyage.org/wiki/", "wikivoyage.org/w/index.php?title="); | |
url = url + "&useskin=monobook"; | |
location.href = url; | |
} | |
if (url.includes("wikifunctions.org") && url.includes("#") && !url.includes("&useskin=monobook")) { | |
var hashIndex = url.indexOf("#"); | |
if (hashIndex !== -1) { | |
var hash = url.substring(hashIndex); | |
url = url.substring(0, hashIndex); | |
url = url.replace("wikifunctions.org/wiki/", "wikifunctions.org/w/index.php?title="); | |
url = url + "&useskin=monobook" + hash; | |
location.href = url; | |
} | |
} | |
else if (url.includes("wikifunctions.org") && !url.includes("&useskin=monobook")) { | |
url = url.replace("wikifunctions.org/wiki/", "wikifunctions.org/w/index.php?title="); | |
url = url + "&useskin=monobook"; | |
location.href = url; | |
} | |
if (url.includes("wikinews.org") && url.includes("#") && !url.includes("&useskin=monobook")) { | |
var hashIndex = url.indexOf("#"); | |
if (hashIndex !== -1) { | |
var hash = url.substring(hashIndex); | |
url = url.substring(0, hashIndex); | |
url = url.replace("wikinews.org/wiki/", "wikinews.org/w/index.php?title="); | |
url = url + "&useskin=monobook" + hash; | |
location.href = url; | |
} | |
} | |
else if (url.includes("wikinews.org") && !url.includes("&useskin=monobook")) { | |
url = url.replace("wikinews.org/wiki/", "wikinews.org/w/index.php?title="); | |
url = url + "&useskin=monobook"; | |
location.href = url; | |
} | |
if (url.includes("mediawiki.org") && url.includes("#") && !url.includes("&useskin=monobook")) { | |
var hashIndex = url.indexOf("#"); | |
if (hashIndex !== -1) { | |
var hash = url.substring(hashIndex); | |
url = url.substring(0, hashIndex); | |
url = url.replace("mediawiki.org/wiki/", "mediawiki.org/w/index.php?title="); | |
url = url + "&useskin=monobook" + hash; | |
location.href = url; | |
} | |
} | |
else if (url.includes("mediawiki.org") && !url.includes("&useskin=monobook")) { | |
url = url.replace("mediawiki.org/wiki/", "mediawiki.org/w/index.php?title="); | |
url = url + "&useskin=monobook"; | |
location.href = url; | |
} | |
if (url.includes(".wikimedia.org") && url.includes("#") && !url.includes("&useskin=monobook")) { | |
var hashIndex = url.indexOf("#"); | |
if (hashIndex !== -1) { | |
var hash = url.substring(hashIndex); | |
url = url.substring(0, hashIndex); | |
url = url.replace(".wikimedia.org/wiki/", ".wikimedia.org/w/index.php?title="); | |
url = url + "&useskin=monobook" + hash; | |
location.href = url; | |
} | |
} | |
else if (url.includes(".wikimedia.org") && !url.includes("&useskin=monobook")) { | |
url = url.replace(".wikimedia.org/wiki/", ".wikimedia.org/w/index.php?title="); | |
url = url + "&useskin=monobook"; | |
location.href = url; | |
} | |
//wikiless | |
if (url.includes("wikiless.org") && url.includes("#") && !url.includes("&useskin=vector")) { | |
var hashIndex = url.indexOf("#"); | |
if (hashIndex !== -1) { | |
var hash = url.substring(hashIndex); | |
url = url.substring(0, hashIndex); | |
url = url.replace("wikiless.org/wiki/", "wikiless.org/w/index.php?title="); | |
url = url + "&useskin=vector" + hash; | |
location.href = url; | |
} | |
} | |
else if (url.includes("wikiless.org") && !url.includes("&useskin=vector")) { | |
url = url.replace("wikiless.org/wiki/", "wikiless.org/w/index.php?title="); | |
url = url + "&useskin=vector"; | |
location.href = url; | |
} | |
//other | |
if (url.includes("wiki.archlinux.org") && url.includes("#") && !url.includes("&useskin=monobook")) { | |
var hashIndex = url.indexOf("#"); | |
if (hashIndex !== -1) { | |
var hash = url.substring(hashIndex); | |
url = url.substring(0, hashIndex); | |
url = url.replace("wiki.archlinux.org/title/", "wiki.archlinux.org/index.php?title="); | |
url = url + "&useskin=monobook" + hash; | |
location.href = url; | |
} | |
} | |
else if (url.includes("wiki.archlinux.org") && !url.includes("&useskin=monobook")) { | |
url = url.replace("wiki.archlinux.org/title/", "wiki.archlinux.org/index.php?title="); | |
url = url + "&useskin=monobook"; | |
location.href = url; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment