gHacks Dark Mode + Decline cookies

Dark Mode for gHacks.net, also automatically declines all cookies when dialog pops up

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        gHacks Dark Mode + Decline cookies
// @namespace   https://greasyfork.org
// @description Dark Mode for gHacks.net, also automatically declines all cookies when dialog pops up
// @author      Guillaume
// @version     1.1.1
// @icon        https://ghacks.net/favicon.ico
// @match       *://*.ghacks.net/*
// @grant       GM_addStyle
// ==/UserScript==

function declineCookies() {
  var dialog = document.getElementsByClassName('sncmp-intro_rejectAll');
  if (dialog.length) {
    clearInterval(i);
    dialog[0].click();
    setTimeout(function() {
      document.querySelectorAll('.sncmp-switch_isSelected').forEach(e => e.click());
      setTimeout(function() { document.getElementsByClassName('sncmp-details_save')[0].click() }, 100);
    }, 100);
  } else {
    c++;
    if (c > 10) clearInterval(i);
  }
}

var c = 0, i;
window.onload = function() { i = setInterval(declineCookies, 250) };

GM_addStyle(`
body {
  background: #3B3B3B;
  color: #EEE !important;
}
h2>a, .heading, .heading--huge, .heading--large, .user-content h2, .widget_text .textwidget h2, .heading--big, .heading--medium, .user-content h3, .widget_text .textwidget h3, .heading--normal, .heading--small, .user-content h5, .widget_text .textwidget h5, .heading--tiny {
  color: #F3B434 !important;
}
a { color: #FFF !important; }
.comment-item__header, input:not([type="submit"]):not([type="checkbox"]), textarea, select, #snippet-box {
  background: #272727 !important;
  color: #EEE !important;
}
.button--orange, input[type="submit"], .nav-links span.current { background-color: transparent !important }
.button--orange:hover, input[type="submit"]:hover, .nav-links span.current:hover, .button--orange:focus, input[type="submit"]:focus, .nav-links span.current:focus { background-color: #F3B434 !important }
.user-content a:not(:hover), .widget_text .textwidget a:not(:hover) { border-bottom: 2px solid #727272 !important }
`);