Add extend feeds live and scrollbar support

This commit is contained in:
the1812 2020-04-23 15:57:43 +08:00
parent aac0fe6c0e
commit 0a7ec1c95e
17 changed files with 177 additions and 20 deletions

View File

@ -458,6 +458,7 @@ declare global {
newVersionCheckInterval: number,
useDarkStyleAsUserStyle: boolean,
livePip: boolean,
extendFeedsLive: boolean,
latestVersionLink: string,
currentVersion: string,
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -81,6 +81,8 @@
"expand-danmaku.min.js": "B21658C40085AEA8DC49652AE62EB8610BB2EBEAF7A9C9AF69EF3B11E08EEC8D",
"expand-description.min.css": "58C7710A50521B80F7D872BDC4C652610D84C4FABC6874BA66DA37B4F8759224",
"expand-description.min.js": "A56857AD6B1C9F431B233D188E857D30DD5A2EB644986DE32A21280B1B7BC7A7",
"extend-feeds-live.min.css": "289FF668C6612FDD84B05ADB030B762EA22F8CB23D38A4954D8784194BFBA85A",
"extend-feeds-live.min.js": "C0BF0CA43264C5A9413FB1DC727EEAC4620F0EDBF3B1AB89A2E538D102BB625A",
"favorites-redirect.min.js": "70D6ECCE0402AA76387D2A3288C1148C60CC88D5378B7A2BDC813F3F78E4EE84",
"feeds-apis.min.js": "F0D840B5D85455B8E3159C6A0286CDE78E29B99A3B89DF73FCBD489B27398163",
"feeds-filter.min.js": "B0C6884958870914F6583C4BA86936C3E7A24E27570B1837BAB69F0611EA8FDD",
@ -91,7 +93,7 @@
"ffmpeg-support.min.js": "B88C5BFDC1CC582CA25098D6BA47189FF628B7323EF9F90D4CFBC4E946648927",
"fill-with-comments.min.js": "A32B6D4ADFA29C164F9675E07715EAC0A5CFE0BBB346735DD691BDA2D9F338C3",
"filter-type-switch.vue.min.js": "E06B00EF48F3CCFACC82B858A266CE0DF48F8332C5900B3AD579330D4C6D3125",
"fixed-sidebars.min.js": "A0AB37CF2219EA0008DC828C22EB6726D93B0CF320DEB503BE78ECA1B2DFEC6F",
"fixed-sidebars.min.js": "BAC6F19321BC7F75A28553B4F758B633C3FFB40A55326719C77421D90C0CCD7C",
"fix-fullscreen.min.js": "C0628A7CABB4421FCBD7663700EF9965C96F6D79979B9F7523A9F9B0B009C8B6",
"fold-comment.min.css": "74DF4566EB80AD7078E65E8B68633E05FC41D3B4E47A20D6E415E8A743F35378",
"fold-comment.min.js": "B149A9A8EA03DCB39BC4FF59591BE9D8E7BA45B2049A545F9611251EBE85FEA9",
@ -104,7 +106,7 @@
"full-tweets-title.min.css": "13A0CF1C96F374CED3FA59A532E28B4B620D7A4C374385A363F32AD1A7656764",
"full-tweets-title.min.js": "DD57BB732ABEF7739CA84AEFF97E86F8984FCC4A8A75B957213622350B2A7C37",
"gui-settings.min.css": "5413D79650A771E7ED2C2E5FBF0C70978C6BBB74A6599554B79F4295035484D7",
"gui-settings.min.html": "11001E94C551C19C1337316DB5D572903F4B472DA47786FE4209FE633A3FEC62",
"gui-settings.min.html": "E43292A60ACFE4ED684914AF7721C211AC4D651780DF2A653D7CCFCC3C31F7F0",
"gui-settings.min.js": "05E3D8E28ED1EC8B1887023EA1EA112880274224B5DB3296AFF83B6A09B52412",
"haruna-scale.min.js": "FD079C86741F614FD63E733CF9B7B896A7D20110754815A540F3341D4DC252B2",
"hide-bangumi-reviews.min.js": "7265C0CE994FDA926355A9A4F9B207E7E68E749D47332F3C537EF93E97927A23",

Binary file not shown.

1
min/extend-feeds-live.min.css vendored Normal file
View File

@ -0,0 +1 @@
.live-up-list .up-name{font-size:13px!important}.live-up-list .live-detail{color:#000}body.dark .live-up-list .live-detail{color:#eee}.live-up-list .live-detail[data-live-title]::before{content:attr(data-live-title);color:#000;font-weight:700;line-height:1.5;display:flex}body.dark .live-up-list .live-detail[data-live-title]::before{color:#eee}

1
min/extend-feeds-live.min.js vendored Normal file
View File

@ -0,0 +1 @@
(()=>{return(e,t)=>{(async()=>{if(document.URL.replace(location.search,"")!=="https://t.bilibili.com/"){return}const e=await SpinQuery.select(".live-up-list");t.applyStyle("extendFeedsLiveStyle");const i=await Ajax.getJsonWithCredentials(`https://api.live.bilibili.com/relation/v1/feed/feed_list?page=1&pagesize=24`);if(i.code!==0){logError(`加载直播列表失败: ${i.message}`);return}const n=_.get(i,"data.list",[]);const l=dqa(e,".up-name");const a=l.map(e=>e.innerText.trim());const o=n.filter(e=>a.includes(e.uname));const r=n.filter(e=>!a.includes(e.uname));l.forEach((e,t)=>{e.parentElement.setAttribute("data-live-title",o.find(e=>e.uname===a[t]).title)});const s=e.children[0];r.forEach(t=>{const i=s.cloneNode(true);dqa(i,"a[href]").forEach(e=>e.setAttribute("href",`https://live.bilibili.com/${t.roomid}`));const n=dq(i,".live-up-img");n.style.backgroundImage=`url(${t.face})`;const l=dq(i,".live-detail");l.setAttribute("data-live-title",t.title);const a=dq(i,".up-name");a.innerHTML=t.uname;e.insertAdjacentElement("beforeend",i)});console.log(o,r)})()}})();

View File

@ -1 +1 @@
(()=>{return(n,t)=>{const a=`\n.custom-navbar {\n position: fixed !important;\n}\n.sticky-bar {\n display: none !important;\n}\n.left-panel, .right-panel {\n position: fixed !important;\n}\n.center-panel {\n margin-left: calc(244px + 8px) !important;\n}\n.right-panel {\n margin-left: calc(244px + 16px + 632px) !important;\n}\n`;const e="fixed-sidebars-style";const i=()=>{if(document.URL.replace(location.search,"")==="https://t.bilibili.com/"){t.applyStyleFromText(a,e)}};const o=()=>dqa("#"+e).forEach(n=>n.remove());i();return{reload:i,unload:o}}})();
(()=>{return(n,t)=>{const e=`\n.custom-navbar {\n position: fixed !important;\n}\n.sticky-bar {\n display: none !important;\n}\n.left-panel, .right-panel {\n position: fixed !important;\n}\n.center-panel {\n margin-left: calc(244px + 8px) !important;\n}\n.right-panel {\n margin-left: calc(244px + 16px + 632px) !important;\n}\n.live-panel .live-up-list {\n max-height: calc(100vh - 200px);\n overflow: auto;\n scrollbar-width: none !important;\n}\n.live-panel .live-up-list::-webkit-scrollbar {\n height: 0 !important;\n width: 0 !important;\n}\n`;const i="fixed-sidebars-style";let a=true;if(document.URL.replace(location.search,"")==="https://t.bilibili.com/"){(async()=>{const n=await SpinQuery.select(".live-up-list");if(n!==null){n.addEventListener("mouseenter",n=>{if(a){n.stopImmediatePropagation()}},{capture:true})}})()}const l=()=>{if(document.URL.replace(location.search,"")==="https://t.bilibili.com/"){t.applyStyleFromText(e,i);a=true}};const o=()=>{dqa("#"+i).forEach(n=>n.remove());a=false};l();return{reload:l,unload:o}}})();

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,21 @@
.live-up-list {
.up-name {
font-size: 13px !important;
}
.live-detail {
color: black;
body.dark & {
color: #eee;
}
}
.live-detail[data-live-title]::before {
content: attr(data-live-title);
color: black;
font-weight: bold;
line-height: 1.5;
display: flex;
body.dark & {
color: #eee;
}
}
}

View File

@ -0,0 +1,56 @@
interface LiveInfo {
cover: string
face: string
uname: string
title: string
roomid: number
pic: string
online: number
link: string
}
(async () => {
if (document.URL.replace(location.search, '') !== 'https://t.bilibili.com/') {
return
}
const liveList = await SpinQuery.select('.live-up-list') as HTMLElement
resources.applyStyle('extendFeedsLiveStyle')
const fullListJson = await Ajax.getJsonWithCredentials(`https://api.live.bilibili.com/relation/v1/feed/feed_list?page=1&pagesize=24`)
if (fullListJson.code !== 0) {
logError(`加载直播列表失败: ${fullListJson.message}`)
return
}
const fullList = _.get(fullListJson, 'data.list', []) as LiveInfo[]
const liveListNames = dqa(liveList, '.up-name')
const presentedNames = liveListNames.map((it: HTMLElement) => it.innerText.trim())
const presented = fullList.filter(it => presentedNames.includes(it.uname))
// const fakeLiveInfo = {
// cover: "https://i1.hdslb.com/bfs/face/4209b8ebcac96b1d38b6c05492877e8b21017724.jpg",
// face: "https://i1.hdslb.com/bfs/face/4209b8ebcac96b1d38b6c05492877e8b21017724.jpg",
// link: "https://live.bilibili.com/6983385",
// online: 359,
// pic: "https://i0.hdslb.com/bfs/live/new_room_cover/dbd7025817dcbcb7478e38a062f310509109dbba.jpg",
// roomid: 6983385,
// title: "pekope",
// uname: "Snozaki筱崎",
// }
// const extend = [fakeLiveInfo, fakeLiveInfo, fakeLiveInfo, fakeLiveInfo, fakeLiveInfo, fakeLiveInfo, fakeLiveInfo, fakeLiveInfo, fakeLiveInfo, fakeLiveInfo,] as LiveInfo[]
const extend = fullList.filter(it => !presentedNames.includes(it.uname))
liveListNames.forEach((it, index) => {
it.parentElement!.setAttribute('data-live-title',
presented.find(p => p.uname === presentedNames[index])!.title
)
})
const liveDetailItem = liveList.children[0] as HTMLElement
extend.forEach(it => {
const clone = liveDetailItem.cloneNode(true) as HTMLElement
dqa(clone, 'a[href]').forEach(a => a.setAttribute('href', `https://live.bilibili.com/${it.roomid}`))
const face = dq(clone, '.live-up-img') as HTMLElement
face.style.backgroundImage = `url(${it.face})`
const detail = dq(clone, '.live-detail') as HTMLElement
detail.setAttribute('data-live-title', it.title)
const name = dq(clone, '.up-name') as HTMLElement
name.innerHTML = it.uname
liveList.insertAdjacentElement('beforeend', clone)
})
console.log(presented, extend)
})()

View File

@ -1,27 +1,53 @@
const style = `
.custom-navbar {
position: fixed !important;
position: fixed !important;
}
.sticky-bar {
display: none !important;
display: none !important;
}
.left-panel, .right-panel {
position: fixed !important;
position: fixed !important;
}
.center-panel {
margin-left: calc(244px + 8px) !important;
margin-left: calc(244px + 8px) !important;
}
.right-panel {
margin-left: calc(244px + 16px + 632px) !important;
margin-left: calc(244px + 16px + 632px) !important;
}
.live-panel .live-up-list {
max-height: calc(100vh - 200px);
overflow: auto;
scrollbar-width: none !important;
}
.live-panel .live-up-list::-webkit-scrollbar {
height: 0 !important;
width: 0 !important;
}
`
const id = 'fixed-sidebars-style'
let disableProfilePopup = true
if (document.URL.replace(location.search, '') === 'https://t.bilibili.com/') {
(async () => {
const list = await SpinQuery.select('.live-up-list') as HTMLElement
if (list !== null) {
list.addEventListener('mouseenter', e => {
if (disableProfilePopup) {
e.stopImmediatePropagation()
}
}, { capture: true })
}
})()
}
const add = () => {
if (document.URL.replace(location.search, '') === 'https://t.bilibili.com/') {
resources.applyStyleFromText(style, id)
disableProfilePopup = true
}
}
const remove = () => dqa('#' + id).forEach(it => it.remove())
const remove = () => {
dqa('#' + id).forEach(it => it.remove())
disableProfilePopup = false
}
add()
export default {
reload: add,

View File

@ -858,5 +858,12 @@ Resource.manifest = {
livePip: '直播画中画',
},
},
extendFeedsLive: {
path: 'extend-feeds-live.min.js',
style: true,
displayNames: {
extendFeedsLive: '直播信息扩充',
},
},
}
export const resourceManifest = Resource.manifest

View File

@ -225,6 +225,7 @@ export const settings = {
useDarkStyleAsUserStyle: false,
autoHideSideBar: false,
livePip: true,
extendFeedsLive: true,
cache: {},
}
const fixedSettings = {

View File

@ -118,6 +118,7 @@
<checkbox indent="0" key="feedsTranslate" dependencies=""></checkbox>
<dropdown indent="1" key="feedsTranslateProvider" dependencies="feedsTranslate"></dropdown>
<checkbox indent="0" key="fixedSidebars" dependencies=""></checkbox>
<checkbox indent="0" key="extendFeedsLive" dependencies=""></checkbox>
<category icon="video-outline">直播</category>
<checkbox indent="0" key="useDefaultLiveQuality" dependencies=""></checkbox>
<dropdown indent="1" key="defaultLiveQuality" dependencies="useDefaultLiveQuality"></dropdown>