Fandom auto Dark Mode switcher

Automatially redirects to dark mode on fandom wikis

  1. // ==UserScript==
  2. // @name Fandom auto Dark Mode switcher
  3. // @namespace https://github.com/Artemis-chan
  4. // @version 1.1
  5. // @description Automatially redirects to dark mode on fandom wikis
  6. // @author You
  7. // @match *.fandom.com/wiki/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=fandom.com
  9. // @grant none
  10. // @run-at document-idle
  11. // @license MIT
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16. var butt = document.getElementsByClassName("wiki-tools__theme-switch")[0];
  17. if(butt.title == "Dark Theme")
  18. {
  19. console.log("Redirecting to Dark Mode");
  20. butt.click();
  21. const retries = 5;
  22. for(var i = retries; i > 0; --i)
  23. {
  24. setTimeout(() => {
  25. console.log("Retrying dark mode switch");
  26. butt.click();
  27. }, 1000 * i);
  28. }
  29. setTimeout(() => console.logwarning("Dark mode switch failed"), (retries + 1) * 1000);
  30. }
  31. })();