// ==UserScript== // @license MIT // @name 简单的青柠起始页优化 // @namespace https://bbs.tampermonkey.net.cn/ // @version 0.4.2 // @description 默认去掉青柠起始页的页脚,使用 alt + t 控制搜索框的显示隐藏 使用alt + g切换时钟显示隐藏,变量全局存储,不需要每次打开都关闭或者显示了 alt+b 显示隐藏 B站热搜 // @author Hei // @match *://limestart.cn/* // @match *://www.limestart.cn/* // @grant GM_setClipboard // @grant unsafeWindow // @grant GM_xmlhttpRequest // @grant GM_addStyle // @grant GM_getResourceText // @grant GM_getResourceURL // @connect api.bilibili.com // @connect at.alicdn.com // @connect i0.hdslb.com // @connect * // @require https://lib.baomitu.com/jquery/1.12.4/jquery.min.js // @resource css https://at.alicdn.com/t/c/font_4423350_7t2u8i9k77r.css // ==/UserScript== (function () { 'use strict'; const indexDBREQ = window.indexedDB.open("limestart", 1) // 数据库名称,版本号 const storeName = 'wallpaper' // 表名 let local_db = null; indexDBREQ.onupgradeneeded = (event) => { local_db = event.target.result // 数据库对象 if (local_db.objectStoreNames.includes(storeName)) { local_db.deleteObjectStore(storeName) local_db.createObjectStore(storeName) } console.log('upgrad-连接到本地limestart数据库') } indexDBREQ.onsuccess = (event) => { // 监听数据库创建成功事件 local_db = event.target.result // 数据库对象 console.log('连接到本地limestart数据库') } const indexedAction = { get(storeName, key) { return new Promise((res) => { const transaction = local_db.transaction([storeName], "readwrite"); const store = transaction.objectStore(storeName); const r = store.get(key) r.onsuccess = (e) => { res(e.target.result) } r.onerror = (e) => { res(null) } }) }, put(val, key) { return new Promise((res) => { const transaction = local_db.transaction([storeName], "readwrite"); const store = transaction.objectStore(storeName); const r = store.put(val, key) r.onsuccess = (e) => { res(true) } r.onerror = (e) => { res(false) } }) }, delete(key) { return new Promise((res) => { const transaction = local_db.transaction([storeName], "readwrite"); const store = transaction.objectStore(storeName); const r = store.delete(key) r.onsuccess = (e) => { res(true) } r.onerror = (e) => { res(false) } }) } } // 基础依赖 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 !== undefined) { try { return JSON.parse(val) } catch (err) { return defaultVal || val } } return defaultVal } } let showBilibili = false; let isBliLoading = false; //B站热搜请求 function requestBiApi() { const getRow = async (show_name, keyword, icon) => { const src = await (new Promise((res) => { if (icon) { GM_xmlhttpRequest({ url: icon, method: 'get', responseType: 'blob', onload: (data) => { var blob = new Blob([data.response], { type: 'image/png' }); const fileReader = new FileReader() fileReader.onload = (e) => { res(e.target.result) } // readAsDataURL fileReader.readAsDataURL(blob) } }) } else { res(null) } })) const img_html = src ? `` : '' return `
${show_name}${img_html}
` } if (isBliLoading) return; isBliLoading = true; $(".cover2.easy-limestart .pContent").html(`
加载中...
`) GM_xmlhttpRequest({ url: "https://api.bilibili.com/x/web-interface/wbi/search/square?limit=20&platform=web", method: "get", onload: async (data) => { const { data: { trending: { list, title, top_list } }, code, message } = JSON.parse(data.response); // console.log(code, message) if (code != 0) { Message.info(message) } else { $(".cover2.easy-limestart .pCaptionBar").html(`刷新${title}`).offset(); // console.log(list, title, top_list) $(".cover2.easy-limestart .btnClose").off().hover(() => { $(".cover2.easy-limestart .popUp").css({ display: "block", opacity: 1, transform: 'rotate3d(1, 1, 0, 5deg)' }) }, () => { $(".cover2.easy-limestart .popUp").css({ display: "block", opacity: 1, transform: 'none' }) }).click(() => { showBilibili = false; $(".cover2.easy-limestart").fadeOut(100) }) $("#btnRefreshBli").click(() => { requestBiApi() }) const rowList = [] for (const idx in list) { const { show_name, keyword, icon } = list[idx]; const row = await getRow(show_name, keyword, icon) rowList.push(row) } $(".cover2.easy-limestart .pContent .setGroup").html(rowList.join("")) isBliLoading = false; } }, onabort: () => { isBliLoading = false; }, onerror: () => { isBliLoading = false; } }) $(".cover2.easy-limestart").css({ display: "block", opacity: 1 }) $(".cover2.easy-limestart .popUp").css({ display: "block", opacity: 0, transform: 'rotate3d(1, 1, 0, 50deg)' }).offset(); $(".cover2.easy-limestart .popUp").css({ display: "block", opacity: 1, transform: 'none' }) } //B站热搜显示 function showBlibiliTrending(init = false) { // style="display: block; opacity: 1;" // style="display: block; opacity: 1; transform: none;" const dialog = `
` if (init) { GM_addStyle(`.cover2 { z-index: 100; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,.35); display: none; opacity: 0; transition: .25s; perspective: 1000px; } .icon-bilibili { color: #00AFE0; } .bilibili-trending-img { height: 16px; margin-left: 5px; vertical-align: -2px; } .pCaptionBar.scrolled { display:flex; align-items:center; border-bottom: 1px solid var(--black-alpha-5); color: transparent; font-size: 18px; padding: 6.5px 20px; text-align: center; transition: .25s; color: var(--pure-black-text-color); } .pContent { margin: 0px 5px; padding: 0px 30px 35px; box-sizing:border-box; height: calc(500px - 55px); overflow: auto; } .setGroup { display: flex; flex-direction: column; gap: 10px; padding: 10px 0; font-size: 16px; } .pCaptionBar.scrolled .title-text { margin: 0 auto; } .btnClose { align-items: center; background-color: transparent; border: none; border-radius: 5px; color: var(--black-alpha-80); cursor: pointer; display: inline-flex; font-size: 13px; height: 40px; justify-content: center; padding: 0; transition: .25s; width: 50px; } .btnClose:hover { background-color: var(--black-alpha-5); } #bilibiliTrending { background-color: var(--pure-white-background-color); border-radius: 10px; box-shadow: rgba(0, 0, 0, .05) 0 10px 20px; font-size: small; height: 500px; left: calc(50% - 300px); overflow: hidden; position: absolute; top: calc(50% - 250px); transition: .25s; width: 600px; } #btnRefreshBli { border: none; padding: 6px 20px; background-color: var(--theme-color-tint); color: var(--theme-color); border-radius: 5px; cursor: pointer; transition: .25s; white-space: nowrap; } #btnRefreshBli:hover { background-color: var(--theme-color-tint-rose); color: var(--theme-color-rose); }`) GM_addStyle(GM_getResourceText("css")) $(document.body).append(dialog); } else { showBilibili = !showBilibili; if (showBilibili) { requestBiApi() } else { $(".cover2.easy-limestart").fadeOut(100) } } } showBlibiliTrending(true); // 增加键盘事件 document.body.addEventListener("keydown", (e) => { if (e.altKey && e.key.toLowerCase() === 'b') { showBlibiliTrending() } }); console.log('start') })();