// ==UserScript== // @name Vector Layout for Wikipedia (Fast) // @namespace - // @version 1.0.0 // @description returns old wikipedia layout. (layout before 2023 redesign of website) // @author NotYou // @match *://wikipedia.org/* // @match *://*.wikipedia.org/* // @run-at document-start // @license GPL-3.0-or-later // @grant none // @downloadURL none // ==/UserScript== (function() { 'use strict'; const IS_DEBUG_MODE = false; const DEBUG_TITLE = 'DEBUG - Vector Layout for Wikipedia\n'; let href = location.href; redirect(href); window.addEventListener('click', onClick); function redirect(inputUrl) { let url = typeof inputUrl === 'string' ? new URL(inputUrl) : inputUrl; let searchParams = new URLSearchParams(url.search); let cleanURL = url.origin + url.pathname; if(searchParams.get('useskin') !== 'vector') { searchParams.set('useskin', 'vector'); let hash = location.hash; let params = '?' + searchParams.toString(); if(IS_DEBUG_MODE) { console.log(DEBUG_TITLE, cleanURL + params + hash); } else { location.replace(cleanURL + params + hash); } } } function onClick(e) { let node = e.target; let link = getLink(node); if(link) { let url = new URL(link.href); let isWikiLink = url.hostname.indexOf('wikipedia.org') > -1; if(isWikiLink) { e.preventDefault(); redirect(url); } } } function getLink(node) { if(node.tagName === 'A') { return node; } else if(node.tagName === 'HTML' || !node.tagName) { return null; } return getLink(node.parentNode); } })();