navchandar / Wikipedia Auto Dark Mode

// ==UserScript==
// @name            Wikipedia Auto Dark Mode
// @description     Auto-enables Dark mode on Wikipedia sites
// @author          navchandar
// @include         https://*wikipedia.*/*
// @include         *wikipedia.*/*
// @version         1.1
// @run-at          document-start
// @license         MIT
// @homepage        https://navchandar.github.io/
// @homepage        https://github.com/navchandar/
// @homepageURL     https://navchandar.github.io/
// @copyright       2018, navchandar (https://openuserjs.org/users/navchandar)
// @updateURL       https://openuserjs.org/meta/navchandar/Wikipedia_Auto_Dark_Mode.meta.js
// @downloadURL     https://openuserjs.org/install/navchandar/Wikipedia_Auto_Dark_Mode.user.js
// @supportURL      https://openuserjs.org/scripts/navchandar/Wikipedia_Auto_Dark_Mode/issues
// @setupURL        https://openuserjs.org/install/navchandar/Wikipedia_Auto_Dark_Mode.user.js
// @icon            https://en.wikipedia.org/static/favicon/wikipedia.ico
// @grant           GM_addStyle
// ==/UserScript==

var css = document.createElement('style');
css.type = "text/css";
css.innerHTML = "html{color:#24292e!important}input,center{background:#24292e;background-image:-webkit-linear-gradient(top,#00000000,rgba(0,0,0,.02))}\
.header{width:100%;background:#24292e;height:46px}nav,body{color:grey!important;background-color:#24292e!important}\
h1,h2,h3,h4,h5,h6,div{color:grey!important;background-color:#24292e!important}ul,li{color:white!important;background-color:#24292e!important}\
li a{background-color:#24292e!important}tr,td,th,caption{color:white!important;background-color:#24292e!important}\
a,b{color:#7d9bcd!important;background-color:#24292e!important}dl,dt,dd{color:Snow!important;background-color:#24292e!important}\
textarea{color:Snow!important;background-color:#171718!important}div,span,pre{color:snow!important;background:#24292e}\
details,label,summary{background:#24292e}img{background-color:lightgrey}#fbar{background:#23282d;border-top:1px solid #e4e4e4;line-height:40px;min-width:980px}\
table{border:1px solid #5b5c5c;border-spacing:2px;background-color:#000c;color:#000}\
.mw-ui-input{background-color:#1f252bde;color:#000;border:1px solid #a2a9b1;border-radius:2px;box-shadow:inset 0 0 0 .1em #3e81f1;border:1px solid #253793;border-radius:5px}\
.infobox{border:1px solid #888;border-spacing:2px;background-color:#000000b5;color:#000;margin:.5em 0 .5em 1em}\
.oo-ui-textInputWidget input,.oo-ui-textInputWidget textarea{background-color:#070808c7;color:#000;border:1px solid #a2a9b1}\
#p-search form,#p-search input{margin:.4em 0 0}#simpleSearch{background-color:#24292e}#simpleSearch:hover{border-color:#72777d}\
#simpleSearch input{background-color:#24292e;color:#000;margin:0;padding:0;border:0}\
#simpleSearch #searchInput{width:100%;padding:.2em 0 .2em .2em;font-size:.8125em;direction:ltr;-webkit-appearance:textfield}\
#simpleSearch #searchInput:focus{outline:0}#simpleSearch #searchInput::-webkit-input-placeholder{color:#72777d;opacity:1}\
#simpleSearch #searchInput:-ms-input-placeholder{color:#72777d;opacity:1}#simpleSearch #searchInput::-moz-placeholder{color:#72777d;opacity:1}\
#simpleSearch #searchInput:-moz-placeholder{color:#72777d;opacity:1}#simpleSearch #searchInput::placeholder{color:#72777d;opacity:1}\
#simpleSearch #searchInput::-webkit-search-decoration,#simpleSearch #searchInput::-webkit-search-cancel-button,#simpleSearch #searchInput::-webkit-search-results-button,#simpleSearch #searchInput::-webkit-search-results-decoration{-webkit-appearance:textfield}\
#simpleSearch #searchButton,#simpleSearch #mw-searchButton{position:absolute;top:0;right:0;width:1.65em;height:100%;cursor:pointer;text-indent:-99999px;direction:ltr;white-space:nowrap;overflow:hidden}\
";

var d = new Date(); // for now
var time = d.getHours();
if (time >= 20 || time < 8) {
  // Run this only @ night
  document.getElementsByTagName('head')[0].appendChild(css);
  document.getElementsByTagName("body")[0].setAttribute("bgcolor", "#24292e");
  document.getElementsByTagName("body")[0].setAttribute("text", "Snow");
  document.getElementsByTagName("body")[0].setAttribute("alink", "#4285f4");
  document.getElementsByTagName("body")[0].setAttribute("link", "#4285f4");
  document.getElementsByTagName("body")[0].setAttribute("vlink", "Purple");
  document.body.style.background = "#24292e";
}