// ==UserScript== // @name Force Wikipedia Theme to OS // @namespace Violentmonkey Scripts // @icon // @version 1.0.0 // // @match https://*.wikipedia.org/* // @match https://*.wikimedia.org/* // @grant none // // @author - // @description // ==/UserScript== (function () { 'use strict'; // 1. Immediately update class on to avoid initial white flash const docEl = document.documentElement; docEl.classList.remove('skin-theme-clientpref-day', 'skin-theme-clientpref-night'); docEl.classList.add('skin-theme-clientpref-os'); // 2. Invoke MediaWiki clientPrefs API once loaded to save state function setMwPref() { if (window.mw && window.mw.user && window.mw.user.clientPrefs) { window.mw.user.clientPrefs.set('skin-theme', 'os'); } else { setTimeout(setMwPref, 20); } } if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', setMwPref); } else { setMwPref(); } })();