Last active
October 27, 2021 08:08
-
-
Save kfatehi/6253953ded8c24b895013477da1e2675 to your computer and use it in GitHub Desktop.
Dark Wikipedia - Userscript for iOS & macOS Safari
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 Dark Wikipedia | |
// @description Darkens Wikipedia on iOS & macOS Safari, for use with https://github.com/quoid/userscripts | |
// @match https://en.m.wikipedia.org/* | |
// @match https://en.wikipedia.org/* | |
// @updateURL | |
// @version 1.3 | |
// ==/UserScript== | |
function darkenChrome() { | |
let metas = document.getElementsByTagName('meta'); | |
for (let i=0; i<metas.length;i++) { | |
console.log(metas[i].attributes.name); | |
let meta = metas[i]; | |
let attrs = meta.attributes; | |
if (attrs.name && attrs.name.value === "theme-color") { | |
attrs.content.value = "#000" | |
} | |
} | |
} | |
function injectCSS(css) { | |
let style = document.createElement('style'); | |
let head = document.getElementsByTagName('head')[0] | |
style.textContent = css; | |
head.appendChild(style); | |
} | |
let bg = 'background: black;' | |
let fg = 'color: white'; | |
let a = 'color: cornflowerblue;' | |
darkenChrome(); | |
injectCSS(` | |
#mw-page-base { ${bg+fg} } | |
body { ${bg+fg} } | |
.vector-menu-portal .vector-menu-content li a { ${a} } | |
.header-container.header-chrome { ${bg+fg} } | |
.mw-body { ${bg+fg} } | |
.content .infobox { ${bg} } | |
.minerva-footer { ${bg+fg} } | |
.mw-parser-output #mp-topbanner { ${bg+fg} } | |
h1, h2, h3, h4, h5, h6 { ${fg} } | |
a,a:visited { ${a} } | |
div.thumbinner { ${bg} } | |
.toc, .toccolours { ${bg+fg} } | |
.tocnumber { ${fg} } | |
table.ambox { ${bg} } | |
`); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment