useful tweaks for bilibili.com
当前为
// ==UserScript==
// @name Make BiliBili Grate Again
// @namespace https://www.kookxiang.com/
// @version 1.0
// @description useful tweaks for bilibili.com
// @author kookxiang
// @match https://*.bilibili.com/
// @grant unsafeWindow
// ==/UserScript==
let customStyle = `
.home-content {
width: calc(100vw - 60px) !important;
min-width: 1160px;
}
.home-content .center-panel {
flex: 1 !important;
}
.home-content .center-panel .card .main-content {
width: calc(100% - 120px) !important;
}
`
// 动态页面优化
if (location.host === "t.bilibili.com") {
customStyle += `
#internationalHeader {
position: sticky !important;
top: 0;
}
.home-content .left-panel .scroll-content {
top: 56px !important;
}
.home-content .right-panel .scroll-content {
top: 64px !important;
}
`
}
// 去广告
if (unsafeWindow.__INITIAL_STATE__ && unsafeWindow.__INITIAL_STATE__.locsData) {
for (const key in unsafeWindow.__INITIAL_STATE__.locsData) {
if (!Array.isArray(unsafeWindow.__INITIAL_STATE__.locsData[key])) {
continue;
}
unsafeWindow.__INITIAL_STATE__.locsData[key] = unsafeWindow.__INITIAL_STATE__.locsData[key].filter(x => !x.is_ad)
}
}
// 修复文章区复制
if (location.href.startsWith('https://www.bilibili.com/read/cv')) {
unsafeWindow.original.reprint = "1"
document.querySelector('.article-holder').classList.remove("unable-reprint")
document.querySelector('.article-holder').addEventListener('copy', e => e.stopImmediatePropagation(), true)
}
const style = document.createElement('style')
style.textContent = customStyle
document.head.appendChild(style)