duckduckgo_dark_theme.user.js 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. // ==UserScript==
  2. // @name DuckDuckGo Always Terminal Theme
  3. // @namespace DuckDuckGoDarkTheme
  4. // @description Enables Therminal Theme Forever.
  5. // @author Jesús E.
  6. // @version 0.1.1
  7. // @grant none
  8. // @include /^http(s|)://(www[.]|)duckduckgo[.]com/.*$/
  9. // @include /^http(s|)://3g2upl4pq6kufc4m[.]onion/.*$/
  10. // @run-at document-start
  11. // @icon https://duckduckgo.com/favicon.ico
  12. // ==/UserScript==
  13. (function main() {
  14. 'use strict';
  15. const consoleCSS = 'background: #000; color: #00FF00; padding: 0px 7px; border: 1px solid #00FF00; line-height: 16px;';
  16. const name = GM_info.script.name;
  17. const log = (...args) => console.log('%cUSERSCRIPT | %s: %s', consoleCSS, name, ...args);
  18. log('start');
  19. // set darkmode cookie before page loaded
  20. const cookiePref = document.cookie.replace(/(?:(?:^|.*;\s*)ae\s*=\s*([^;]*).*$)|^.*$/, '$1');
  21. const cookiePrefDark = 't';
  22. const expires = 'max-age=315360000';
  23. if (!cookiePref.includes(cookiePrefDark)) {
  24. document.cookie = `ae=${cookiePrefDark}${cookiePref ? `&${cookiePref}` : ''};path=/;${expires}`;
  25. log('cookie injected');
  26. }
  27. }());