Automatically invoke Twitter night dark mode

Invokes the twitter night/dark mode layout automatically when this script is installed and active.

  1. // ==UserScript==
  2. // @name Automatically invoke Twitter night dark mode
  3. // @namespace TwitterNightMode
  4. // @version 0.2
  5. // @description Invokes the twitter night/dark mode layout automatically when this script is installed and active.
  6. // @author codingjoe
  7. // @match *.twitter.com/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. // find html element that invokes night mode
  15. var nightModeToggle = document.querySelector(".nightmode-toggle");
  16.  
  17. // if the night mode icon is showing not activated
  18. if (nightModeToggle.querySelector(".Icon--crescentFilled") === null) {
  19. // click the night mode toggle to activate it
  20. nightModeToggle.click();
  21. }
  22. })();