mirror of
https://github.com/the1812/Bilibili-Evolved.git
synced 2025-11-04 21:22:45 +08:00
Update watchlater redirect for new homepage
This commit is contained in:
parent
5bd3c0a348
commit
8a6c6bf9da
@ -1,6 +1,6 @@
|
||||
// ==UserScript==
|
||||
// @name Bilibili Evolved (Offline)
|
||||
// @version 402.91
|
||||
// @version 402.94
|
||||
// @description Bilibili Evolved 的离线版, 所有功能都已内置于脚本中.
|
||||
// @author Grant Howard, Coulomb-G
|
||||
// @copyright 2019, Grant Howard (https://github.com/the1812) & Coulomb-G (https://github.com/Coulomb-G)
|
||||
@ -1108,7 +1108,7 @@ offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/m
|
||||
offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/video-story.min.js"] = (()=>{return(t,i)=>{class e{constructor(t){this.title=t.option;this.nodeID=t.node_id;this.cid=t.cid;this.default=t.is_default===1}}class s{constructor(t,i,e){this.title=t.title;this.nodeID=t.node_id;this.aid=i;this.cid=t.cid;this.graphVersion=e;this.choices=[];this.choiceTime=-1}async getChoices(){if(this.choices.length>0){return}const t=`https://api.bilibili.com/x/stein/nodeinfo?aid=${this.aid}&node_id=${this.nodeID}&graph_version=504`;const i=await Ajax.getJsonWithCredentials(t);if(i.code!==0){console.error(`获取选项失败: ${i.message}`);return}this.choices=i.data.edges.choices.map(t=>new e(t))}}class o{constructor(t,i){this.nodeList=t;if(i){this.startingNode=i}else{[this.startingNode]=t}}async getAllChoices(){return await Promise.all(this.nodeList.map(t=>t.getChoices()))}}const n=async(t,i)=>{const n=`https://api.bilibili.com/x/stein/nodeinfo?aid=${t}&graph_version=${i}`;const c=await Ajax.getJsonWithCredentials(n);if(c.code!==0){return c.message}const a=c.data.story_list.map(e=>new s(e,t,i));const d=a.find(t=>t.nodeID===c.data.node_id);if(!d){return"获取起始结点失败"}d.choiceTime=c.data.edges.show_time;const r=c.data.edges.choices.map(t=>new e(t));d.choices=r;return new o(a,d)};return{export:{StoryChoice:e,StoryNode:s,Story:o,getStoryNodes:n}}}})();
|
||||
offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/view-cover.min.js"] = (()=>{return(e,t)=>{const{VideoInfo:i}=t.import("video-info");const{getFriendlyTitle:n}=t.import("title");class o{constructor(e){this.url=e;if(document.querySelector(".image-viewer")===null){this.createContainer()}this.viewer=document.querySelector(".image-viewer-container");this.downloadImage();addSettingsListener("filenameFormat",()=>{this.viewer.querySelector(".download").setAttribute("download",this.filename)})}createContainer(){document.body.insertAdjacentHTML("beforeend",t.import("imageViewerHtml"));document.querySelector(".image-viewer-container .close").addEventListener("click",()=>this.hide());t.applyStyle("imageViewerStyle")}downloadImage(){document.querySelector("#view-cover").style.display=this.url?"flex":"none";if(this.url===""){return}const e=new XMLHttpRequest;e.open("GET",this.url.replace("http:","https:"),true);e.responseType="blob";e.onload=(()=>{const t=URL.createObjectURL(e.response);if(this.imageData){URL.revokeObjectURL(this.imageData)}this.imageData=t;const i=this.viewer.querySelector(".download");i.setAttribute("href",t);i.setAttribute("download",this.filename);this.viewer.querySelector(".copy-link").addEventListener("click",()=>GM_setClipboard(this.url));this.viewer.querySelector(".new-tab").setAttribute("href",this.url);this.viewer.querySelector(".image").src=t});e.send()}show(){this.viewer.classList.add("opened")}hide(){this.viewer.classList.remove("opened")}get filename(){return n(document.URL.includes("/www.bilibili.com/bangumi/"))+this.url.substring(this.url.lastIndexOf("."))}}return(()=>{if(!document.URL.includes("live.bilibili.com")){return{widget:{content:`\n <button\n class="gui-settings-flat-button"\n id="view-cover">\n <i class="icon-view"></i>\n <span>查看封面</span>\n </button>`,condition:async()=>{const e=await SpinQuery.select(()=>(unsafeWindow||window).aid);return Boolean(e)},success:async()=>{async function e(){const e=(unsafeWindow||window).aid;const t=new i(e);try{await t.fetchInfo()}catch(e){return""}return t.coverUrl}let t=new o(await e());document.querySelector("#view-cover").addEventListener("click",()=>{t.show()});const n=async()=>{t=new o(await e())};Observer.videoChange(n)}}}}else{return{widget:{content:`\n <button\n class="gui-settings-flat-button"\n id="view-cover">\n <i class="icon-view"></i>\n <span>查看封面</span>\n </button>`,condition:async()=>{const e=await SpinQuery.select(()=>document.querySelector(".header-info-ctnr .room-cover"));return Boolean(e)},success:async()=>{const e=document.querySelector(".header-info-ctnr .room-cover");const t=e.getAttribute("href").match(/space\.bilibili\.com\/([\d]+)/);if(t&&t[1]){const e=t[1];const i=`https://api.live.bilibili.com/room/v1/Room/getRoomInfoOld?mid=${e}`;const n=await Ajax.getJson(i);const r=n.data.cover;const s=new o(r);document.querySelector("#view-cover").addEventListener("click",()=>{s.show()})}}}}}})()}})();
|
||||
offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/watchlater-api.min.js"] = (()=>{return(t,i)=>{const e=async(t,i)=>{const e=i?"https://api.bilibili.com/x/v2/history/toview/add":"https://api.bilibili.com/x/v2/history/toview/del";const s=document.cookie.replace(/(?:(?:^|.*\s*)bili_jct\s*\=\s*([^]*).*$)|^.*$/,"$1");const a=await Ajax.postTextWithCredentials(e,`aid=${t}&csrf=${s}`);const o=JSON.parse(a);if(o.code!==0){throw new Error(`稍后再看操作失败: ${o.message}`)}};const s=async(t=false)=>{const i=`https://api.bilibili.com/x/v2/history/toview/web`;const e=await Ajax.getJsonWithCredentials(i);if(e.code!==0){throw new Error(`获取稍后再看列表失败: ${e.message}`)}if(t===true){return e.data}if(!e.data.list){return[]}return e.data.list.map(t=>t.aid)};return{export:{toggleWatchlater:e,getWatchlaterList:s}}}})();
|
||||
offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/watchlater.min.js"] = (()=>{return(e,t)=>{const r=e=>{const t=e.match(/(av[\d]+)\/p([\d]+)/);if(t){return`https://www.bilibili.com/video/${t[1]}/?p=${t[2]}`}else{return"javascript:;"}};const a=e=>{const t=e.map(e=>{const t=e.getAttribute("href");if(!t){return"javascript:;"}if(t.match(/.*watchlater.*|javascript:;/g)){return r(t)}if(t.indexOf("video/av")!==-1){return t}});e.forEach((e,r)=>$(e).attr("href",t[r]).attr("target","_blank"))};const i=(...e)=>{for(const t of e){SpinQuery.select(()=>document.querySelectorAll(t),e=>a([...e]))}};SpinQuery.any(()=>$(".watch-later-list"),()=>{(Observer.childListSubtree||Observer.subtree)("#viewlater-app",()=>{SpinQuery.condition(()=>document.URL.match(/(av[\d]+)\/p([\d]+)/),e=>e&&document.URL.indexOf("watchlater")!==-1,()=>{const e=r(document.URL);if(e!==null){window.location.replace(e)}});SpinQuery.any(()=>$("#viewlater-app .s-btn[href='#/']"),e=>e.remove());i(".av-pic",".av-about>a")})});SpinQuery.any(()=>$("li.nav-item[report-id*=watchlater]"),()=>{(Observer.childListSubtree||Observer.subtree)("li.nav-item[report-id*=watchlater]",()=>{i(".av-item>a",".av-about>a","div.watch-later-m>ul>div>li>a");SpinQuery.any(()=>$(".read-more.mr"),e=>e.remove());SpinQuery.any(()=>$(".read-more-grp>.read-more"),e=>e.css({float:"none",width:"auto"}))})})}})();
|
||||
offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/watchlater.min.js"] = (()=>{return(e,t)=>{const i=e=>{const t=e.match(/(av[\d]+)\/p([\d]+)/);if(t){return`https://www.bilibili.com/video/${t[1]}/?p=${t[2]}`}else{return"javascript:;"}};const r=e=>{const t=e.map(e=>{const t=e.getAttribute("href");if(!t){return"javascript:;"}if(t.match(/.*watchlater.*|javascript:;/g)){return i(t)}if(t.indexOf("video/av")!==-1){return t}});e.forEach((e,i)=>{e.setAttribute("href",t[i]);e.setAttribute("target","_blank")})};const a=(...e)=>{for(const t of e){SpinQuery.select(()=>document.querySelectorAll(t),e=>r([...e]))}};SpinQuery.select(".watch-later-list").then(()=>{Observer.childListSubtree("#viewlater-app",()=>{SpinQuery.condition(()=>document.URL.match(/(av[\d]+)\/p([\d]+)/),e=>e&&document.URL.indexOf("watchlater")!==-1,()=>{const e=i(document.URL);if(e!==null){window.location.replace(e)}});SpinQuery.select("#viewlater-app .s-btn[href='#/']",e=>e.remove());a(".av-pic",".av-about>a")})});SpinQuery.select("li.nav-item[report-id*=watchlater]").then(()=>{Observer.childListSubtree("li.nav-item[report-id*=watchlater]",()=>{a(".av-item>a",".av-about>a","div.watch-later-m>ul>div>li>a");SpinQuery.select(".read-more.mr",e=>e.remove());SpinQuery.select(".read-more-grp>.read-more",e=>{e.style.width="auto";e.style.float="none"})})});SpinQuery.select(".van-popper-favorite").then(async e=>{if(!e){return}const t=Observer.childListSubtree(e,()=>{const i=e.querySelector(".play-all");if(i){const e="//www.bilibili.com/watchlater/#/list";Observer.attributes(i,()=>{if(i.getAttribute("href")==="//www.bilibili.com/watchlater/"){console.log("watchlater");i.setAttribute("href",e);i.firstChild.classList.remove("bili-icon_dingdao_bofang");i.firstChild.classList.add("bili-icon_xinxi_yuedushu");i.lastChild.nodeValue="查看全部"}else if(i.getAttribute("href")!==e){console.log("not watchlater");i.firstChild.classList.add("bili-icon_dingdao_bofang");i.firstChild.classList.remove("bili-icon_xinxi_yuedushu");i.lastChild.nodeValue="播放全部"}});t.forEach(e=>e.stop())}})})}})();
|
||||
|
||||
class ResourceType
|
||||
{
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
// ==UserScript==
|
||||
// @name Bilibili Evolved (Preview Offline)
|
||||
// @version 402.91
|
||||
// @version 402.94
|
||||
// @description Bilibili Evolved 的预览离线版, 可以抢先体验新功能, 并且所有功能都已内置于脚本中.
|
||||
// @author Grant Howard, Coulomb-G
|
||||
// @copyright 2019, Grant Howard (https://github.com/the1812) & Coulomb-G (https://github.com/Coulomb-G)
|
||||
@ -1108,7 +1108,7 @@ offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/m
|
||||
offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/video-story.min.js"] = (()=>{return(t,i)=>{class e{constructor(t){this.title=t.option;this.nodeID=t.node_id;this.cid=t.cid;this.default=t.is_default===1}}class s{constructor(t,i,e){this.title=t.title;this.nodeID=t.node_id;this.aid=i;this.cid=t.cid;this.graphVersion=e;this.choices=[];this.choiceTime=-1}async getChoices(){if(this.choices.length>0){return}const t=`https://api.bilibili.com/x/stein/nodeinfo?aid=${this.aid}&node_id=${this.nodeID}&graph_version=504`;const i=await Ajax.getJsonWithCredentials(t);if(i.code!==0){console.error(`获取选项失败: ${i.message}`);return}this.choices=i.data.edges.choices.map(t=>new e(t))}}class o{constructor(t,i){this.nodeList=t;if(i){this.startingNode=i}else{[this.startingNode]=t}}async getAllChoices(){return await Promise.all(this.nodeList.map(t=>t.getChoices()))}}const n=async(t,i)=>{const n=`https://api.bilibili.com/x/stein/nodeinfo?aid=${t}&graph_version=${i}`;const c=await Ajax.getJsonWithCredentials(n);if(c.code!==0){return c.message}const a=c.data.story_list.map(e=>new s(e,t,i));const d=a.find(t=>t.nodeID===c.data.node_id);if(!d){return"获取起始结点失败"}d.choiceTime=c.data.edges.show_time;const r=c.data.edges.choices.map(t=>new e(t));d.choices=r;return new o(a,d)};return{export:{StoryChoice:e,StoryNode:s,Story:o,getStoryNodes:n}}}})();
|
||||
offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/view-cover.min.js"] = (()=>{return(e,t)=>{const{VideoInfo:i}=t.import("video-info");const{getFriendlyTitle:n}=t.import("title");class o{constructor(e){this.url=e;if(document.querySelector(".image-viewer")===null){this.createContainer()}this.viewer=document.querySelector(".image-viewer-container");this.downloadImage();addSettingsListener("filenameFormat",()=>{this.viewer.querySelector(".download").setAttribute("download",this.filename)})}createContainer(){document.body.insertAdjacentHTML("beforeend",t.import("imageViewerHtml"));document.querySelector(".image-viewer-container .close").addEventListener("click",()=>this.hide());t.applyStyle("imageViewerStyle")}downloadImage(){document.querySelector("#view-cover").style.display=this.url?"flex":"none";if(this.url===""){return}const e=new XMLHttpRequest;e.open("GET",this.url.replace("http:","https:"),true);e.responseType="blob";e.onload=(()=>{const t=URL.createObjectURL(e.response);if(this.imageData){URL.revokeObjectURL(this.imageData)}this.imageData=t;const i=this.viewer.querySelector(".download");i.setAttribute("href",t);i.setAttribute("download",this.filename);this.viewer.querySelector(".copy-link").addEventListener("click",()=>GM_setClipboard(this.url));this.viewer.querySelector(".new-tab").setAttribute("href",this.url);this.viewer.querySelector(".image").src=t});e.send()}show(){this.viewer.classList.add("opened")}hide(){this.viewer.classList.remove("opened")}get filename(){return n(document.URL.includes("/www.bilibili.com/bangumi/"))+this.url.substring(this.url.lastIndexOf("."))}}return(()=>{if(!document.URL.includes("live.bilibili.com")){return{widget:{content:`\n <button\n class="gui-settings-flat-button"\n id="view-cover">\n <i class="icon-view"></i>\n <span>查看封面</span>\n </button>`,condition:async()=>{const e=await SpinQuery.select(()=>(unsafeWindow||window).aid);return Boolean(e)},success:async()=>{async function e(){const e=(unsafeWindow||window).aid;const t=new i(e);try{await t.fetchInfo()}catch(e){return""}return t.coverUrl}let t=new o(await e());document.querySelector("#view-cover").addEventListener("click",()=>{t.show()});const n=async()=>{t=new o(await e())};Observer.videoChange(n)}}}}else{return{widget:{content:`\n <button\n class="gui-settings-flat-button"\n id="view-cover">\n <i class="icon-view"></i>\n <span>查看封面</span>\n </button>`,condition:async()=>{const e=await SpinQuery.select(()=>document.querySelector(".header-info-ctnr .room-cover"));return Boolean(e)},success:async()=>{const e=document.querySelector(".header-info-ctnr .room-cover");const t=e.getAttribute("href").match(/space\.bilibili\.com\/([\d]+)/);if(t&&t[1]){const e=t[1];const i=`https://api.live.bilibili.com/room/v1/Room/getRoomInfoOld?mid=${e}`;const n=await Ajax.getJson(i);const r=n.data.cover;const s=new o(r);document.querySelector("#view-cover").addEventListener("click",()=>{s.show()})}}}}}})()}})();
|
||||
offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/watchlater-api.min.js"] = (()=>{return(t,i)=>{const e=async(t,i)=>{const e=i?"https://api.bilibili.com/x/v2/history/toview/add":"https://api.bilibili.com/x/v2/history/toview/del";const s=document.cookie.replace(/(?:(?:^|.*\s*)bili_jct\s*\=\s*([^]*).*$)|^.*$/,"$1");const a=await Ajax.postTextWithCredentials(e,`aid=${t}&csrf=${s}`);const o=JSON.parse(a);if(o.code!==0){throw new Error(`稍后再看操作失败: ${o.message}`)}};const s=async(t=false)=>{const i=`https://api.bilibili.com/x/v2/history/toview/web`;const e=await Ajax.getJsonWithCredentials(i);if(e.code!==0){throw new Error(`获取稍后再看列表失败: ${e.message}`)}if(t===true){return e.data}if(!e.data.list){return[]}return e.data.list.map(t=>t.aid)};return{export:{toggleWatchlater:e,getWatchlaterList:s}}}})();
|
||||
offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/watchlater.min.js"] = (()=>{return(e,t)=>{const r=e=>{const t=e.match(/(av[\d]+)\/p([\d]+)/);if(t){return`https://www.bilibili.com/video/${t[1]}/?p=${t[2]}`}else{return"javascript:;"}};const a=e=>{const t=e.map(e=>{const t=e.getAttribute("href");if(!t){return"javascript:;"}if(t.match(/.*watchlater.*|javascript:;/g)){return r(t)}if(t.indexOf("video/av")!==-1){return t}});e.forEach((e,r)=>$(e).attr("href",t[r]).attr("target","_blank"))};const i=(...e)=>{for(const t of e){SpinQuery.select(()=>document.querySelectorAll(t),e=>a([...e]))}};SpinQuery.any(()=>$(".watch-later-list"),()=>{(Observer.childListSubtree||Observer.subtree)("#viewlater-app",()=>{SpinQuery.condition(()=>document.URL.match(/(av[\d]+)\/p([\d]+)/),e=>e&&document.URL.indexOf("watchlater")!==-1,()=>{const e=r(document.URL);if(e!==null){window.location.replace(e)}});SpinQuery.any(()=>$("#viewlater-app .s-btn[href='#/']"),e=>e.remove());i(".av-pic",".av-about>a")})});SpinQuery.any(()=>$("li.nav-item[report-id*=watchlater]"),()=>{(Observer.childListSubtree||Observer.subtree)("li.nav-item[report-id*=watchlater]",()=>{i(".av-item>a",".av-about>a","div.watch-later-m>ul>div>li>a");SpinQuery.any(()=>$(".read-more.mr"),e=>e.remove());SpinQuery.any(()=>$(".read-more-grp>.read-more"),e=>e.css({float:"none",width:"auto"}))})})}})();
|
||||
offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/watchlater.min.js"] = (()=>{return(e,t)=>{const i=e=>{const t=e.match(/(av[\d]+)\/p([\d]+)/);if(t){return`https://www.bilibili.com/video/${t[1]}/?p=${t[2]}`}else{return"javascript:;"}};const r=e=>{const t=e.map(e=>{const t=e.getAttribute("href");if(!t){return"javascript:;"}if(t.match(/.*watchlater.*|javascript:;/g)){return i(t)}if(t.indexOf("video/av")!==-1){return t}});e.forEach((e,i)=>{e.setAttribute("href",t[i]);e.setAttribute("target","_blank")})};const a=(...e)=>{for(const t of e){SpinQuery.select(()=>document.querySelectorAll(t),e=>r([...e]))}};SpinQuery.select(".watch-later-list").then(()=>{Observer.childListSubtree("#viewlater-app",()=>{SpinQuery.condition(()=>document.URL.match(/(av[\d]+)\/p([\d]+)/),e=>e&&document.URL.indexOf("watchlater")!==-1,()=>{const e=i(document.URL);if(e!==null){window.location.replace(e)}});SpinQuery.select("#viewlater-app .s-btn[href='#/']",e=>e.remove());a(".av-pic",".av-about>a")})});SpinQuery.select("li.nav-item[report-id*=watchlater]").then(()=>{Observer.childListSubtree("li.nav-item[report-id*=watchlater]",()=>{a(".av-item>a",".av-about>a","div.watch-later-m>ul>div>li>a");SpinQuery.select(".read-more.mr",e=>e.remove());SpinQuery.select(".read-more-grp>.read-more",e=>{e.style.width="auto";e.style.float="none"})})});SpinQuery.select(".van-popper-favorite").then(async e=>{if(!e){return}const t=Observer.childListSubtree(e,()=>{const i=e.querySelector(".play-all");if(i){const e="//www.bilibili.com/watchlater/#/list";Observer.attributes(i,()=>{if(i.getAttribute("href")==="//www.bilibili.com/watchlater/"){console.log("watchlater");i.setAttribute("href",e);i.firstChild.classList.remove("bili-icon_dingdao_bofang");i.firstChild.classList.add("bili-icon_xinxi_yuedushu");i.lastChild.nodeValue="查看全部"}else if(i.getAttribute("href")!==e){console.log("not watchlater");i.firstChild.classList.add("bili-icon_dingdao_bofang");i.firstChild.classList.remove("bili-icon_xinxi_yuedushu");i.lastChild.nodeValue="播放全部"}});t.forEach(e=>e.stop())}})})}})();
|
||||
|
||||
class ResourceType
|
||||
{
|
||||
|
||||
2
min/watchlater.min.js
vendored
2
min/watchlater.min.js
vendored
@ -1 +1 @@
|
||||
(()=>{return(e,t)=>{const r=e=>{const t=e.match(/(av[\d]+)\/p([\d]+)/);if(t){return`https://www.bilibili.com/video/${t[1]}/?p=${t[2]}`}else{return"javascript:;"}};const a=e=>{const t=e.map(e=>{const t=e.getAttribute("href");if(!t){return"javascript:;"}if(t.match(/.*watchlater.*|javascript:;/g)){return r(t)}if(t.indexOf("video/av")!==-1){return t}});e.forEach((e,r)=>$(e).attr("href",t[r]).attr("target","_blank"))};const i=(...e)=>{for(const t of e){SpinQuery.select(()=>document.querySelectorAll(t),e=>a([...e]))}};SpinQuery.any(()=>$(".watch-later-list"),()=>{(Observer.childListSubtree||Observer.subtree)("#viewlater-app",()=>{SpinQuery.condition(()=>document.URL.match(/(av[\d]+)\/p([\d]+)/),e=>e&&document.URL.indexOf("watchlater")!==-1,()=>{const e=r(document.URL);if(e!==null){window.location.replace(e)}});SpinQuery.any(()=>$("#viewlater-app .s-btn[href='#/']"),e=>e.remove());i(".av-pic",".av-about>a")})});SpinQuery.any(()=>$("li.nav-item[report-id*=watchlater]"),()=>{(Observer.childListSubtree||Observer.subtree)("li.nav-item[report-id*=watchlater]",()=>{i(".av-item>a",".av-about>a","div.watch-later-m>ul>div>li>a");SpinQuery.any(()=>$(".read-more.mr"),e=>e.remove());SpinQuery.any(()=>$(".read-more-grp>.read-more"),e=>e.css({float:"none",width:"auto"}))})})}})();
|
||||
(()=>{return(e,t)=>{const i=e=>{const t=e.match(/(av[\d]+)\/p([\d]+)/);if(t){return`https://www.bilibili.com/video/${t[1]}/?p=${t[2]}`}else{return"javascript:;"}};const r=e=>{const t=e.map(e=>{const t=e.getAttribute("href");if(!t){return"javascript:;"}if(t.match(/.*watchlater.*|javascript:;/g)){return i(t)}if(t.indexOf("video/av")!==-1){return t}});e.forEach((e,i)=>{e.setAttribute("href",t[i]);e.setAttribute("target","_blank")})};const a=(...e)=>{for(const t of e){SpinQuery.select(()=>document.querySelectorAll(t),e=>r([...e]))}};SpinQuery.select(".watch-later-list").then(()=>{Observer.childListSubtree("#viewlater-app",()=>{SpinQuery.condition(()=>document.URL.match(/(av[\d]+)\/p([\d]+)/),e=>e&&document.URL.indexOf("watchlater")!==-1,()=>{const e=i(document.URL);if(e!==null){window.location.replace(e)}});SpinQuery.select("#viewlater-app .s-btn[href='#/']",e=>e.remove());a(".av-pic",".av-about>a")})});SpinQuery.select("li.nav-item[report-id*=watchlater]").then(()=>{Observer.childListSubtree("li.nav-item[report-id*=watchlater]",()=>{a(".av-item>a",".av-about>a","div.watch-later-m>ul>div>li>a");SpinQuery.select(".read-more.mr",e=>e.remove());SpinQuery.select(".read-more-grp>.read-more",e=>{e.style.width="auto";e.style.float="none"})})});SpinQuery.select(".van-popper-favorite").then(async e=>{if(!e){return}const t=Observer.childListSubtree(e,()=>{const i=e.querySelector(".play-all");if(i){const e="//www.bilibili.com/watchlater/#/list";Observer.attributes(i,()=>{if(i.getAttribute("href")==="//www.bilibili.com/watchlater/"){console.log("watchlater");i.setAttribute("href",e);i.firstChild.classList.remove("bili-icon_dingdao_bofang");i.firstChild.classList.add("bili-icon_xinxi_yuedushu");i.lastChild.nodeValue="查看全部"}else if(i.getAttribute("href")!==e){console.log("not watchlater");i.firstChild.classList.add("bili-icon_dingdao_bofang");i.firstChild.classList.remove("bili-icon_xinxi_yuedushu");i.lastChild.nodeValue="播放全部"}});t.forEach(e=>e.stop())}})})}})();
|
||||
@ -1,92 +1,87 @@
|
||||
const getRedirectLink = text =>
|
||||
{
|
||||
const match = text.match(/(av[\d]+)\/p([\d]+)/);
|
||||
if (match)
|
||||
{
|
||||
return `https://www.bilibili.com/video/${match[1]}/?p=${match[2]}`;
|
||||
const getRedirectLink = text => {
|
||||
const match = text.match(/(av[\d]+)\/p([\d]+)/)
|
||||
if (match) {
|
||||
return `https://www.bilibili.com/video/${match[1]}/?p=${match[2]}`
|
||||
} else {
|
||||
return 'javascript:;'
|
||||
}
|
||||
}
|
||||
const redirectLinks = items => {
|
||||
const watchlaterList = items
|
||||
.map(it => {
|
||||
const href = it.getAttribute('href')
|
||||
if (!href) {
|
||||
return 'javascript:;'
|
||||
}
|
||||
if (href.match(/.*watchlater.*|javascript:;/g)) {
|
||||
return getRedirectLink(href)
|
||||
}
|
||||
if (href.indexOf('video/av') !== -1) {
|
||||
return href
|
||||
}
|
||||
})
|
||||
items.forEach((it, index) => {
|
||||
it.setAttribute('href', watchlaterList[index])
|
||||
it.setAttribute('target', '_blank')
|
||||
})
|
||||
}
|
||||
const redirectSelectors = (...selectors) => {
|
||||
for (const selector of selectors) {
|
||||
SpinQuery.select(
|
||||
() => document.querySelectorAll(selector),
|
||||
it => redirectLinks([...it])
|
||||
)
|
||||
}
|
||||
}
|
||||
SpinQuery.select('.watch-later-list').then(() => {
|
||||
Observer.childListSubtree('#viewlater-app', () => {
|
||||
SpinQuery.condition(
|
||||
() => document.URL.match(/(av[\d]+)\/p([\d]+)/),
|
||||
it => it && document.URL.indexOf('watchlater') !== -1,
|
||||
() => {
|
||||
const url = getRedirectLink(document.URL)
|
||||
if (url !== null) {
|
||||
window.location.replace(url)
|
||||
}
|
||||
}
|
||||
)
|
||||
SpinQuery.select("#viewlater-app .s-btn[href='#/']", it => it.remove())
|
||||
redirectSelectors('.av-pic', '.av-about>a')
|
||||
})
|
||||
})
|
||||
SpinQuery.select('li.nav-item[report-id*=watchlater]').then(() => {
|
||||
Observer.childListSubtree('li.nav-item[report-id*=watchlater]', () => {
|
||||
redirectSelectors('.av-item>a', '.av-about>a', 'div.watch-later-m>ul>div>li>a')
|
||||
SpinQuery.select('.read-more.mr', it => it.remove())
|
||||
SpinQuery.select('.read-more-grp>.read-more', it => {
|
||||
it.style.width = 'auto'
|
||||
it.style.float = 'none'
|
||||
})
|
||||
})
|
||||
})
|
||||
SpinQuery.select('.van-popper-favorite').then(async favoritePopup => {
|
||||
if (!favoritePopup) {
|
||||
return
|
||||
}
|
||||
const observers = Observer.childListSubtree(favoritePopup, () => {
|
||||
const playAll = favoritePopup.querySelector('.play-all')
|
||||
if (playAll) {
|
||||
const url = '//www.bilibili.com/watchlater/#/list'
|
||||
Observer.attributes(playAll, () => {
|
||||
if (playAll.getAttribute('href') === '//www.bilibili.com/watchlater/') {
|
||||
console.log('watchlater')
|
||||
playAll.setAttribute('href', url)
|
||||
playAll.firstChild.classList.remove('bili-icon_dingdao_bofang')
|
||||
playAll.firstChild.classList.add('bili-icon_xinxi_yuedushu')
|
||||
playAll.lastChild.nodeValue = '查看全部'
|
||||
} else if (playAll.getAttribute('href') !== url) {
|
||||
console.log('not watchlater')
|
||||
playAll.firstChild.classList.add('bili-icon_dingdao_bofang')
|
||||
playAll.firstChild.classList.remove('bili-icon_xinxi_yuedushu')
|
||||
playAll.lastChild.nodeValue = '播放全部'
|
||||
}
|
||||
})
|
||||
observers.forEach(it => it.stop())
|
||||
}
|
||||
else
|
||||
{
|
||||
return "javascript:;";
|
||||
}
|
||||
};
|
||||
const redirectLinks = items =>
|
||||
{
|
||||
const watchlaterList = items
|
||||
.map(it =>
|
||||
{
|
||||
const href = it.getAttribute("href");
|
||||
if (!href)
|
||||
{
|
||||
return "javascript:;";
|
||||
}
|
||||
if (href.match(/.*watchlater.*|javascript:;/g))
|
||||
{
|
||||
return getRedirectLink(href);
|
||||
}
|
||||
if (href.indexOf("video/av") !== -1)
|
||||
{
|
||||
return href;
|
||||
}
|
||||
});
|
||||
items.forEach((it, index) => $(it)
|
||||
.attr("href", watchlaterList[index])
|
||||
.attr("target", "_blank"));
|
||||
};
|
||||
const redirectSelectors = (...selectors) =>
|
||||
{
|
||||
for (const selector of selectors)
|
||||
{
|
||||
SpinQuery.select(
|
||||
() => document.querySelectorAll(selector),
|
||||
it => redirectLinks([...it]),
|
||||
);
|
||||
}
|
||||
};
|
||||
SpinQuery.any(
|
||||
() => $(".watch-later-list"),
|
||||
() =>
|
||||
{
|
||||
(Observer.childListSubtree || Observer.subtree)("#viewlater-app", () =>
|
||||
{
|
||||
SpinQuery.condition(
|
||||
() => document.URL.match(/(av[\d]+)\/p([\d]+)/),
|
||||
it => it && document.URL.indexOf("watchlater") !== -1,
|
||||
() =>
|
||||
{
|
||||
const url = getRedirectLink(document.URL);
|
||||
if (url !== null)
|
||||
{
|
||||
window.location.replace(url);
|
||||
}
|
||||
}
|
||||
);
|
||||
SpinQuery.any(
|
||||
() => $("#viewlater-app .s-btn[href='#/']"),
|
||||
it => it.remove(),
|
||||
);
|
||||
redirectSelectors(".av-pic", ".av-about>a");
|
||||
});
|
||||
}
|
||||
);
|
||||
SpinQuery.any(
|
||||
() => $("li.nav-item[report-id*=watchlater]"),
|
||||
() =>
|
||||
{
|
||||
(Observer.childListSubtree || Observer.subtree)("li.nav-item[report-id*=watchlater]", () =>
|
||||
{
|
||||
redirectSelectors(".av-item>a", ".av-about>a", "div.watch-later-m>ul>div>li>a");
|
||||
SpinQuery.any(
|
||||
() => $(".read-more.mr"),
|
||||
it => it.remove()
|
||||
);
|
||||
SpinQuery.any(
|
||||
() => $(".read-more-grp>.read-more"),
|
||||
it => it.css({
|
||||
float: "none",
|
||||
width: "auto"
|
||||
})
|
||||
);
|
||||
});
|
||||
}
|
||||
);
|
||||
})
|
||||
})
|
||||
|
||||
Loading…
Reference in New Issue
Block a user