Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Old Wikipedia Layout
- // @namespace http://greasyfork.org/
- // @version 0.2
- // @description Redirects Wikipedia to use the good (pre-2023) skin.
- // @author Sheer Anger
- // @match *://*.wikipedia.org/*
- // @icon https://www.google.com/s2/favicons?domain=www.wikipedia.org
- // @grant none
- // @license MIT
- // ==/UserScript==
- const skinchoice = 'vector';
- function test(url){
- return !!url.match(/(?!.*useskin)^(|http(s?):\/\/)(|www\.|\w{2,6}\.)(|m\.)wikipedia.org(\/.*|$)/gim) && url != `https://www.wikipedia.org/`;
- }
- function getNewPage(url){
- var que = '?';
- if(url.includes("?")){que = '&'};
- if(url.includes("#")) {
- const s = url.split("#");
- return s[0]+que+"useskin="+skinchoice+"#"+s[1];
- }
- return url.concat(que,"useskin=",skinchoice);
- }
- function fixWikiLinks(){
- var links = Array.prototype.slice.call(document.links, 0);
- links.filter(function(link){
- if(test(link.href)){
- var greatNewLink = getNewPage(link.href);
- if(link.hasAttribute('data-outbound-url')) link.setAttribute('data-outbound-url', greatNewLink);
- link.setAttribute('href', greatNewLink);
- }
- });
- }
- if(test(window.location.href)){window.location.assign(getNewPage(window.location.href));}
- window.onload = fixWikiLinks;
- setInterval(fixWikiLinks, 50);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement