navchandar / Twitter Auto Night Mode

// ==UserScript==
// @name            Twitter Auto Night Mode
// @description     Auto-enables Night Mode on Twitter.com after 8 pm
// @author          navchandar
// @version         1.3
// @grant           none
// @match           *://*.twitter.com/*
// @run-at          document-start
// @copyright       2018, navchandar(https://openuserjs.org/users/navchandar)
// @updateURL       https://openuserjs.org/meta/navchandar/Twitter_Auto_Night_Mode.meta.js
// @icon            data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAABTVBMVEUdofIcofIaoPIboPIvqfNHs/RCsPQnpfMfovIho/I7rvQeofIjo/J4x/fU7f3w+f7s9/7A5ftYuvU6rfRyxPdEsfQ5rfTJ6Pxmv/Z/yvj4/P/////t+P7j8/204PtAsPROtfX0+v57yPclpPI4rPTd8f3J6fxuw/ceovJDsfTr9/624ftXufUlpfIWnvL5/f+S0vkmpfMkpPK24Pvy+v7B5fuHzfhcu/Z9yfj6/f/h8/01q/MuqPN3x/fm9f71+/7+///Z7/1GsvTe8f3z+v7C5vy64vuY1PlJs/XS7Pz2+/9kvvbO6vz+/v/F5/wqpvP2+/5nwPYopvOe1/mj2fpbu/a54vv9/v+84/syqvMgovKFzPj7/f+x3/s2q/NUuPWh2PrM6vyAyvgppvNNtfXH6Pzv+P7y+f7c8f18yPdHsvRLtPUzqvMio/IcoPJuec6iAAAAAWJLR0QbAmDUpAAAAAd0SU1FB+IEAxMjDa4VD/IAAAEXSURBVDjLY2AYpoCRiZkRU5QZLs3MwsrGzszMzIEiz8nFDZXn4eXjFxAUEhYRZUbWLyYuATGXUVJKGghkZOXkkY1gUlAUUFJmYmRgVlGVBgMpNXUNZBM0taSltHV0mfR0pCAK9A0MkV3KaGQMFDQxNTO3sIQosLJGdgIDo42tHUSjvQNEgSMLileZnJxdpFGAqxFq2Bi6ocpLu6PYAHSlh6cDsryXORN6+Hr7+CIp8PNHD21m2wAk+YBAdAMYGIOCkVSE8GBGFzNnaFg4VD4ikhldmjOKXTPaGSIdExuHIc8Rn5AoA/FGuGpSMoY8AwNPikGqbFq6QEZYphi25AIMS2ZDlaxszZxcJmYGHICRmYmJOY9heAIA9ZQq6UkXW+AAAAAldEVYdGRhdGU6Y3JlYXRlADIwMTgtMDQtMDNUMTk6MzU6MTMrMDI6MDAxgFSMAAAAJXRFWHRkYXRlOm1vZGlmeQAyMDE4LTA0LTAzVDE5OjM1OjEzKzAyOjAwQN3sMAAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAABXelRYdFJhdyBwcm9maWxlIHR5cGUgaXB0YwAAeJzj8gwIcVYoKMpPy8xJ5VIAAyMLLmMLEyMTS5MUAxMgRIA0w2QDI7NUIMvY1MjEzMQcxAfLgEigSi4A6hcRdPJCNZUAAAAASUVORK5CYII=
// @license         MIT
// ==/UserScript==

function createCookie(name, value, days) {
  var expires = ""
  if (days) {
    var date = new Date();
    date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
    expires = "; expires=" + date.toGMTString();
  }
  else {
    expires = "";
  }
  document.cookie = name + "=" + value + expires + "; path=/";
}

function eraseCookie(name) {
    document.cookie = name + '=; Path=/; expires=Thu, 01 Jan 1970 00:00:01 GMT;';
}

var d = new Date(); // for now
var time = d.getHours();
if (time >= 20 || time < 8 ){
    createCookie('night_mode', 1, 100);
}
else{
    eraseCookie('night_mode');
}