MCPcopy Create free account
hub / github.com/XIU2/UserScript / setTheme

Function setTheme

Zhihu-Beautification.user.js:536–549  ·  view source on GitHub ↗
(theme)

Source from the content-addressed store, hash-verified

534
535 // 修改知乎 Cookie 中的主题类型
536 function setTheme(theme) {
537 switch(theme) {
538 case 'light':
539 document.cookie='theme=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/';
540 document.lastChild.setAttribute('data-theme', 'light');
541 location.reload(); // 刷新网页
542 break;
543 case 'dark':
544 document.cookie='theme=dark; expires=Thu, 18 Dec 2031 12:00:00 GMT; path=/';
545 document.lastChild.setAttribute('data-theme', 'dark');
546 if (GM_getValue('menu_darkMode')) location.reload(); // 刷新网页
547 break;
548 }
549 }
550})();

Callers 3

menu_toggleFunction · 0.85
menu_switchFunction · 0.85
addStyleFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected