知乎黑暗模式

开启知乎黑暗模式

目前為 2021-01-11 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name Zhihu.com Dark Mode
  3. // @name:zh-CN 知乎黑暗模式
  4. // @name:zh-TW 知乎黑暗模式
  5. // @namespace https://www.zhihu.com/
  6. // @version 0.5
  7. // @description Enable Zhihu.com Dark Mode
  8. // @description:zh-CN 开启知乎黑暗模式
  9. // @description:zh-TW 开启知乎黑暗模式
  10. // @author 老蛤
  11. // @match *://*.zhihu.com/*
  12. // @license MIT
  13. // ==/UserScript==
  14.  
  15.  
  16. (function() {
  17. 'use strict';
  18.  
  19. const ignoreList = [
  20. 'link.zhihu.com',
  21. 'video.zhihu.com'
  22. ];
  23.  
  24. if (ignoreList.indexOf(location.host) === -1 && document.querySelector('html').getAttribute('data-theme') !== 'dark') {
  25. const url = new URL(location.href);
  26. const params = new URLSearchParams(url.search);
  27. params.set('theme', 'dark');
  28. url.search = params.toLocaleString();
  29. location.href = url.href;
  30. }
  31. })();