Dark Theme Stackoverflow

Apply stackoverflow dark theme without login

  1. // ==UserScript==
  2. // @name Dark Theme Stackoverflow
  3. // @description Apply stackoverflow dark theme without login
  4. // @version 0.2
  5. // @run-at document-start
  6. // @match https://*.stackoverflow.com/*
  7. // @icon https://stackoverflow.com/favicon.ico
  8. // @author Fznhq
  9. // @namespace https://github.com/fznhq
  10. // @homepageURL https://github.com/fznhq/userscript-collection
  11. // @license GNU GPLv3
  12. // ==/UserScript==
  13.  
  14. (function () {
  15. "use strict";
  16.  
  17. new MutationObserver((_, observer) => {
  18. if (document.body) {
  19. document.body.classList.add("theme-dark");
  20. observer.disconnect();
  21. }
  22. }).observe(document.documentElement, { subtree: true, childList: true });
  23. })();