// ==UserScript== // @name Wikipedia Vector Legacy Layout // @description Restores the old Wikipedia layout // @version 1.1.0 // @author Pabli // @namespace https://github.com/pabli24 // @license MIT // @match *://*.wikipedia.org/* // @match *://*.wiktionary.org/* // @match *://*.wikiquote.org/* // @match *://*.wikinews.org/* // @match *://*.wikidata.org/* // @match *://*.wikivoyage.org/* // @match *://*.wikiversity.org/* // @match *://*.wikifunctions.org/* // @match *://*.wikisource.org/* // @match *://*.wikibooks.org/* // @match *://*.wikimedia.org/* // @match *://*.mediawiki.org/* // @exclude *://www.wikipedia.org/* // @run-at document-start // @icon https://www.google.com/s2/favicons?sz=64&domain=wikipedia.org // @grant GM_setValue // @grant GM_getValue // @grant GM_registerMenuCommand // @downloadURL none // ==/UserScript== (async () => { 'use strict'; const SKINS = { vector: 'Vector legacy (2010)', 'vector-2022': 'Vector (2022)', minerva: 'MinervaNeue', monobook: 'MonoBook', timeless: 'Timeless' }; const SKIN = await GM_getValue('skin', 'vector'); Object.entries(SKINS).forEach(([key, label]) => { GM_registerMenuCommand( `${SKIN === key ? '◉' : '○'} ${label}`, async () => { await GM_setValue('skin', key); window.location.reload(); } ); }); let url = new URL(window.location.href); if (!url.searchParams.has('useskin')) { url.searchParams.append('useskin', SKIN); window.location.href = url; } else { url.searchParams.delete('useskin'); window.history.replaceState({}, '', url); setTimeout(() => { url = new URL(window.location.href); if (url.searchParams.has('useskin')) { url.searchParams.delete('useskin') window.history.replaceState({}, '', url); } }, 1000); } window.addEventListener('click', (e) => { if (e.button !== 0) return; let link = e.target.closest('[href^="/"]'); if (!link) return; e.preventDefault(); e.stopPropagation(); e.stopImmediatePropagation(); link = new URL(link); link.searchParams.append('useskin', SKIN); window.location.href = link; }); })();