// ==UserScript== // @name 简单的青柠起始页优化 // @namespace https://bbs.tampermonkey.net.cn/ // @version 0.2.3 // @description 默认去掉青柠起始页的页脚,使用 alt + t 控制搜索框的显示隐藏,使用alt + g切换时钟显示隐藏,变量全局存储,不需要每次打开都关闭或者显示了 // @author Hei // @match https://limestart.cn/ https://limestart.cn/?from=ext // ==/UserScript== (function () { 'use strict'; // 基础依赖 const _mainKey = 'easy_limestart' const ls = { set(key, val) { let easy_limestart_obj = window.localStorage.getItem(_mainKey); if (!easy_limestart_obj) { easy_limestart_obj = {} } else { easy_limestart_obj = JSON.parse(easy_limestart_obj) } easy_limestart_obj[key] = val; window.localStorage.setItem(_mainKey, JSON.stringify(easy_limestart_obj)) }, get(key, defaultVal=null) { let easy_limestart_obj = window.localStorage.getItem(_mainKey); if (!easy_limestart_obj) { easy_limestart_obj = {} return defaultVal } else { easy_limestart_obj = JSON.parse(easy_limestart_obj) } const val = easy_limestart_obj[key]; if (val) { return JSON.parse(val) } return defaultVal } } // 去除脚标 const timer = setInterval(() => { const footer = document.querySelector("footer.brief"); if (footer) { footer.style.display = 'none' clearInterval(timer) } }, 500); /** * 显示/隐藏搜索框 */ function showSearchCb() { const searchSuggestionContainer = document.getElementById("searchSuggestionContainer"); const menuSearchEng = document.getElementById("menuSearchEng"); const searchEl = document.getElementById("searchBar"); if (searchEl) { searchEl.style.display = showSearch ? 'block' : 'none'; } if (searchSuggestionContainer) { searchSuggestionContainer.style.display = showSearch ? 'block' : 'none'; } if (menuSearchEng) { menuSearchEng.style.display = showSearch ? 'block' : 'none'; } } let showSearch = ls.get("showSearch"); showSearchCb(); // 显示/隐藏时间框 let showTimer = ls.get("showTimer", true) function showTimerCb() { const timeContainer = document.getElementById("timeContainer"); if (timeContainer) { timeContainer.style.display = showTimer ? 'block' : 'none'; } } showTimerCb() // 增加键盘事件 document.body.addEventListener("keydown", (e) => { if (e.altKey && e.key.toLowerCase() === 't') { showSearch = !showSearch; showSearchCb() ls.set("showSearch", showSearch) } if (e.altKey && e.key.toLowerCase() === 'g') { showTimer = !showTimer; showTimerCb() ls.set("showTimer", showTimer) } }); console.log('start') })();