Fanfiction.net dark theme

A dark theme for fanfiction.net. Works well for night reading.

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name        Fanfiction.net dark theme
// @namespace   Danielv123
// @description A dark theme for fanfiction.net. Works well for night reading.
// @include     https://www.fanfiction.net/s/*
// @include     https://www.fictionpress.com/s/*
// @version     1.1
// @grant       none
// ==/UserScript==
// Settings:
// Display comment section
var commentSection = false;
// End of settings
//
// Get all elements that have a style attribute
var elms = document.querySelectorAll('*[style]');
// Loop through them
Array.prototype.forEach.call(elms, function (elm) {
  // Get the color value
  var clr = elm.style.backgroundColor || '';
  // Remove all whitespace, make it all lower case
  clr = clr.replace(/\s/g, '').toLowerCase();
  // Switch on the possible values we know of
  console.log(clr)
  switch (clr) {
    case 'white':
      elm.style.backgroundColor = '#262626';
      console.log('Color set')
      break;
  }
});
document.body.style.backgroundColor = '#666'
var lightGreyStuff = document.getElementsByClassName('zmenu')
for (var i = 0; i < lightGreyStuff.length; i++) {
  lightGreyStuff[i].style.backgroundColor = '#454545'
}
document.body.style.color = 'white';
if (commentSection === false) {
  document.getElementById('review').style.display = 'none';
}

setTimeout(() => {
    console.log("Updating CSS")
document.querySelector("body > style").innerHTML += `
.lc-wrapper .xcontrast_txt {
  color:white;
}
.xcontrast_txt{
  color:lightgray;
}
.lc-wrapper .lc {
  background-color: #262626;
}
.lc-left {
  background-color: #262626;
}
`
}, 100)