// ==UserScript==
// @license MIT
// @name 简单的青柠起始页优化
// @namespace https://bbs.tampermonkey.net.cn/
// @version 0.4.0
// @description 默认去掉青柠起始页的页脚,使用 alt + t 控制搜索框的显示隐藏 使用alt + g切换时钟显示隐藏,变量全局存储,不需要每次打开都关闭或者显示了 alt+b 显示隐藏 B站热搜
// @author Hei
// @match *://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
// @downloadURL https://update.greasyfork.icu/scripts/488956/%E7%AE%80%E5%8D%95%E7%9A%84%E9%9D%92%E6%9F%A0%E8%B5%B7%E5%A7%8B%E9%A1%B5%E4%BC%98%E5%8C%96.user.js
// @updateURL https://update.greasyfork.icu/scripts/488956/%E7%AE%80%E5%8D%95%E7%9A%84%E9%9D%92%E6%9F%A0%E8%B5%B7%E5%A7%8B%E9%A1%B5%E4%BC%98%E5%8C%96.meta.js
// ==/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
}
}
//消息弹窗
const Message = {
info(msg) {
const delay = 2000; //多少毫秒后隐藏
const greetingContainer = document.createElement("div")
greetingContainer.id = "greetingContainer"
const greetingBox = document.createElement("div")
greetingBox.id = "greetingBox"
greetingBox.textContent = msg
greetingContainer.append(greetingBox)
document.body.append(greetingContainer)
greetingContainer.offsetLeft; // reflow
greetingBox.style.opacity = 1
greetingBox.style.transform = `translateY(0)`
setTimeout(() => {
greetingBox.style.opacity = 0;
greetingBox.style.transform = `translateY(-100%)`;
greetingBox.addEventListener("transitionend", () => {
greetingContainer.remove();
})
greetingBox.addEventListener("webkitTransitionEnd", () => {
greetingContainer.remove();
})
}, delay)
}
}
// 加载B站热搜
// 去除脚标
const timer = setInterval(() => {
const footer = document.querySelector("footer");
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();
// 如果隐藏输入框,那就失去焦点 + 不要cover
if (!showSearch) {
document.getElementById("inputSearch").blur()
document.getElementById("cover").click()
}
// 显示/隐藏时间框
let showTimer = ls.get("showTimer", true)
function showTimerCb() {
const timeContainer = document.getElementById("timeContainer");
if (timeContainer) {
timeContainer.style.display = showTimer ? 'block' : 'none';
}
}
showTimerCb()
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 `