From a0e911d4697d77c8b8a55285f7d3670392e3777e Mon Sep 17 00:00:00 2001 From: the1812 Date: Tue, 14 Jan 2020 21:17:17 +0800 Subject: [PATCH] Merge title.js and title.d.ts into title.ts --- bilibili-evolved.offline.user.js | 2 +- bilibili-evolved.preview-offline.user.js | 2 +- min/bundle.zip | Bin 1595925 -> 1595901 bytes min/custom-navbar.min.js | 2 +- min/title.min.js | 2 +- src/video/title.d.ts | 2 -- src/video/{title.js => title.ts} | 12 +++++++----- 7 files changed, 11 insertions(+), 11 deletions(-) delete mode 100644 src/video/title.d.ts rename src/video/{title.js => title.ts} (92%) diff --git a/bilibili-evolved.offline.user.js b/bilibili-evolved.offline.user.js index c45541f6b..c4e43d604 100644 --- a/bilibili-evolved.offline.user.js +++ b/bilibili-evolved.offline.user.js @@ -1,6 +1,6 @@ // ==UserScript== // @name Bilibili Evolved (Offline) -// @version 547.02 +// @version 547.23 // @description Bilibili Evolved 的离线版, 所有功能都已内置于脚本中. // @author Grant Howard, Coulomb-G // @copyright 2019, Grant Howard (https://github.com/the1812) & Coulomb-G (https://github.com/Coulomb-G) diff --git a/bilibili-evolved.preview-offline.user.js b/bilibili-evolved.preview-offline.user.js index 92677b50f..c019fb226 100644 --- a/bilibili-evolved.preview-offline.user.js +++ b/bilibili-evolved.preview-offline.user.js @@ -1,6 +1,6 @@ // ==UserScript== // @name Bilibili Evolved (Preview Offline) -// @version 547.02 +// @version 547.23 // @description Bilibili Evolved 的预览离线版, 可以抢先体验新功能, 并且所有功能都已内置于脚本中. // @author Grant Howard, Coulomb-G // @copyright 2019, Grant Howard (https://github.com/the1812) & Coulomb-G (https://github.com/Coulomb-G) diff --git a/min/bundle.zip b/min/bundle.zip index 046aaa5c8223de8b5846b745a251e2cb96e09e7e..abe4d0fbeda1ed882cc44e895569721614415040 100644 GIT binary patch delta 2359 zcmZuydr*|u75^S9u)BcZKE5Le5qz?+>@IIu-Yl>nPf-Cy2BOpuc^E`2u@=*$VofYj z6Mr#HL((`^BBuD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J&aWmAD%zEF*&3)MQmMq@=YR^?E>qQ6Zopuxk|z8p%Ff8tT&6_45kWjq%V znLApZHJ9bnht0X%4KIF`O9fKZ2E3okJeS0=Vt&1WUw_IZ78 z?nPAr6(|Qs*yZXb*GBZ)Nsr?NEN#U-d|W`8VlI?+vIaJhR%mH*j|ENL5;{I;GPc;s zCQWR|Ry(Kksh#4bTRX=#VTCNrTPQB%1n$2Tir|x>kvLk&y}f&KbT=7CYMHd6w;yq7 zM^q7uq7kklE@wLq`xiTI7O|Vm-cZc$4UND99wF2gb5nN0Q_LEjgww^8p>6tosNff+ zcZ1929UFj92Mc}f^-z5OdT2PR926`4;UIb)WW?Plngma$ZhS>+@xFr!HJcCXgx2-0 zwl;T@3;h;~L_!G5f7R5V9g4!bk6oTMK*duy$ zqNbGdY{&jmp7s$8l#*R8@6};xua00XVfNSU~6->ac zU{qIfzdov4qqpY1DyorotVW`f zXK1t^Ax=L08(5rV(_CF^5IpXdHO=njKY+84CSxBzl?J^X)qEL@9v|=@566F;R3xXr zV8Fl&1_KsVlUcqrwj+G*zqFU_F^q5XQhZWPj-cP3;sDL=HDlsVn!~;hpn48X=C3YV zc@-n^(>dI?m6%+^*WBBe+#;5C@SiauQPw4H4oX~e=R9S0Rvf_ zb!v`rd?I#Ct>r;|2McR?(LJCa#tLk%rvi;zqW`(@c#$8+pOc$> yNYfeUH@h~N8(Y_--@!RW&F6O$V4KhH{ta8^vqZ0&2-i#$g+bO$z||;XcK!>?Ncc_w diff --git a/min/custom-navbar.min.js b/min/custom-navbar.min.js index 4742d6857..582f5fa3e 100644 --- a/min/custom-navbar.min.js +++ b/min/custom-navbar.min.js @@ -1 +1 @@ -(()=>{return(t,i)=>{const a=["//www.bilibili.com","//t.bilibili.com","//search.bilibili.com","//space.bilibili.com","//account.bilibili.com","//pay.bilibili.com","//member.bilibili.com","//big.bilibili.com","//message.bilibili.com","//app.bilibili.com","//passport.bilibili.com","//game.bilibili.com","//live.bilibili.com/blackboard/"];const s=["//t.bilibili.com/lottery/h5/index/#/result","//member.bilibili.com/video/upload","//space.bilibili.com/ajax/","//www.bilibili.com/h5/comment/","//www.bilibili.com/blackboard/topic/"];const o=()=>{document.body.style.setProperty("--navbar-bounds-padding",`0 ${t.customNavbarBoundsPadding}%`);document.body.style.setProperty("--navbar-blur-opacity",(t.customNavbarBlurOpacity||.7).toString());addSettingsListener("customNavbarBlurOpacity",t=>{document.body.style.setProperty("--navbar-blur-opacity",t)})};const n=(t,i,a)=>{a.classList.toggle(t,i)};const e=t=>{dq(".custom-navbar").classList.toggle("dark",t);dq(".custom-navbar-settings").classList.toggle("dark",t)};return(()=>{if(isIframe()){return}o();const c=!(!a.some(t=>document.URL.includes(t))||s.some(t=>document.URL.includes(t)));if(c){document.body.classList.add("custom-navbar-loading");(async()=>{const a=await i.importAsync((()=>"customNavbarHtml")());document.body.insertAdjacentHTML("beforeend",a);addSettingsListener("useDarkStyle",e,true);const s=()=>dq(".custom-navbar");["Fill","Shadow","Compact","Blur"].forEach(t=>{const i="customNavbar"+t;addSettingsListener(i,i=>n(t.toLowerCase(),i,s()),true)});SpinQuery.condition(()=>dq("#banner_link,.international-header .bili-banner"),t=>t===null?false:Boolean(t.style.backgroundImage),i=>{Observer.attributes(i,()=>{const a=dqa(".custom-navbar .blur-layer");a.forEach(t=>{t.style.backgroundImage=i.style.backgroundImage;t.setAttribute("data-image",i.style.backgroundImage)});addSettingsListener("customNavbarTransparent",i=>{if(!t.hideBanner){s().classList.toggle("transparent",i)}},true);addSettingsListener("hideBanner",i=>{if(t.customNavbarTransparent){s().classList.toggle("transparent",!i)}})})});const{Blank:o}=await i.importAsync("custom-navbar-blank");const{Logo:c}=await i.importAsync("custom-navbar-logo");const{Category:r}=await i.importAsync("custom-navbar-category");const{SimpleLink:l}=await i.importAsync("custom-navbar-simple-link");const{UserInfo:m}=await i.importAsync("custom-navbar-user-info");const{SearchBox:b}=await i.importAsync("custom-navbar-search-box");const{Iframe:u}=await i.importAsync("custom-navbar-iframe");const d=[new o(1),new c,new r,new l("排行","https://www.bilibili.com/ranking","ranking"),new l("相簿","https://h.bilibili.com","drawing"),new l("音频","https://www.bilibili.com/audio/home/","music"),new u("游戏中心","https://game.bilibili.com/",{src:`https://www.bilibili.com/page-proxy/game-nav.html`,width:`680px`,height:`260px`,lazy:true,iframeName:"games"}),new u("直播","https://live.bilibili.com",{src:`https://live.bilibili.com/blackboard/dropdown-menu.html`,width:`528px`,height:`266px`,lazy:true,iframeName:"lives"}),new l("会员购","https://show.bilibili.com","shop"),new l("漫画","https://manga.bilibili.com","manga"),new o(2),new b,new m];if(getUID()){const{WatchlaterList:t}=await i.importAsync("custom-navbar-watchlater-list");const{Messages:a}=await i.importAsync("custom-navbar-messages");const{Activities:s}=await i.importAsync("custom-navbar-activities");const{Subscriptions:o}=await i.importAsync("custom-navbar-subscriptions");const{FavoritesList:n,HistoryList:e}=await i.importAsync("custom-navbar-video-list");d.push(new a,new o,new s,new t,new n,new e)}const{Upload:p}=await i.importAsync("custom-navbar-upload");d.push(new p,new o(3));new Vue({el:".custom-navbar",data:{components:d},methods:{requestPopup(t){if(!t.requestedPopup&&!t.disabled&&!t.active){this.$set(t,`requestedPopup`,true);t.initialPopup&&t.initialPopup()}t.onPopup&&t.onPopup()}},mounted(){document.body.classList.remove("custom-navbar-loading")}})})()}return{widget:{content:`\n
\n\n顶栏布局\n
`,condition:()=>c,success:async()=>{const{initSettingsPanel:t}=await i.importAsync("custom-navbar-settings");await t()}},unload:()=>{const t=dqa(".custom-navbar,.custom-navbar-settings");t.forEach(t=>t.style.display="none");i.removeStyle("customNavbarStyle")},reload:()=>{const t=dqa(".custom-navbar,.custom-navbar-settings");t.forEach(t=>t.style.display="flex");i.applyImportantStyle("customNavbarStyle")}}})()}})(); \ No newline at end of file +(()=>{return(t,i)=>{const a=["//www.bilibili.com","//t.bilibili.com","//search.bilibili.com","//space.bilibili.com","//account.bilibili.com","//pay.bilibili.com","//member.bilibili.com","//big.bilibili.com","//message.bilibili.com","//app.bilibili.com","//passport.bilibili.com","//game.bilibili.com","//live.bilibili.com/blackboard/"];const s=["//t.bilibili.com/lottery/h5/index/#/result","//member.bilibili.com/video/upload","//space.bilibili.com/ajax/","//www.bilibili.com/h5/comment/","//www.bilibili.com/blackboard/topic/"];const o=()=>{document.body.style.setProperty("--navbar-bounds-padding",`0 ${t.customNavbarBoundsPadding}%`);document.body.style.setProperty("--navbar-blur-opacity",(t.customNavbarBlurOpacity||.7).toString());addSettingsListener("customNavbarBlurOpacity",t=>{document.body.style.setProperty("--navbar-blur-opacity",t)})};const n=(t,i,a)=>{a.classList.toggle(t,i)};const e=t=>{dq(".custom-navbar").classList.toggle("dark",t);dq(".custom-navbar-settings").classList.toggle("dark",t)};return(()=>{if(isIframe()){return}o();const c=!(!a.some(t=>document.URL.includes(t))||s.some(t=>document.URL.includes(t)));if(c){document.body.classList.add("custom-navbar-loading");(async()=>{const a=await i.importAsync("customNavbarHtml");document.body.insertAdjacentHTML("beforeend",a);addSettingsListener("useDarkStyle",e,true);const s=()=>dq(".custom-navbar");["Fill","Shadow","Compact","Blur"].forEach(t=>{const i="customNavbar"+t;addSettingsListener(i,i=>n(t.toLowerCase(),i,s()),true)});SpinQuery.condition(()=>dq("#banner_link,.international-header .bili-banner"),t=>t===null?false:Boolean(t.style.backgroundImage),i=>{Observer.attributes(i,()=>{const a=dqa(".custom-navbar .blur-layer");a.forEach(t=>{t.style.backgroundImage=i.style.backgroundImage;t.setAttribute("data-image",i.style.backgroundImage)});addSettingsListener("customNavbarTransparent",i=>{if(!t.hideBanner){s().classList.toggle("transparent",i)}},true);addSettingsListener("hideBanner",i=>{if(t.customNavbarTransparent){s().classList.toggle("transparent",!i)}})})});const{Blank:o}=await i.importAsync("custom-navbar-blank");const{Logo:c}=await i.importAsync("custom-navbar-logo");const{Category:r}=await i.importAsync("custom-navbar-category");const{SimpleLink:l}=await i.importAsync("custom-navbar-simple-link");const{UserInfo:m}=await i.importAsync("custom-navbar-user-info");const{SearchBox:b}=await i.importAsync("custom-navbar-search-box");const{Iframe:u}=await i.importAsync("custom-navbar-iframe");const d=[new o(1),new c,new r,new l("排行","https://www.bilibili.com/ranking","ranking"),new l("相簿","https://h.bilibili.com","drawing"),new l("音频","https://www.bilibili.com/audio/home/","music"),new u("游戏中心","https://game.bilibili.com/",{src:`https://www.bilibili.com/page-proxy/game-nav.html`,width:`680px`,height:`260px`,lazy:true,iframeName:"games"}),new u("直播","https://live.bilibili.com",{src:`https://live.bilibili.com/blackboard/dropdown-menu.html`,width:`528px`,height:`266px`,lazy:true,iframeName:"lives"}),new l("会员购","https://show.bilibili.com","shop"),new l("漫画","https://manga.bilibili.com","manga"),new o(2),new b,new m];if(getUID()){const{WatchlaterList:t}=await i.importAsync("custom-navbar-watchlater-list");const{Messages:a}=await i.importAsync("custom-navbar-messages");const{Activities:s}=await i.importAsync("custom-navbar-activities");const{Subscriptions:o}=await i.importAsync("custom-navbar-subscriptions");const{FavoritesList:n,HistoryList:e}=await i.importAsync("custom-navbar-video-list");d.push(new a,new o,new s,new t,new n,new e)}const{Upload:p}=await i.importAsync("custom-navbar-upload");d.push(new p,new o(3));new Vue({el:".custom-navbar",data:{components:d},methods:{requestPopup(t){if(!t.requestedPopup&&!t.disabled&&!t.active){this.$set(t,`requestedPopup`,true);t.initialPopup&&t.initialPopup()}t.onPopup&&t.onPopup()}},mounted(){document.body.classList.remove("custom-navbar-loading")}})})()}return{widget:{content:`\n
\n\n顶栏布局\n
`,condition:()=>c,success:async()=>{const{initSettingsPanel:t}=await i.importAsync("custom-navbar-settings");await t()}},unload:()=>{const t=dqa(".custom-navbar,.custom-navbar-settings");t.forEach(t=>t.style.display="none");i.removeStyle("customNavbarStyle")},reload:()=>{const t=dqa(".custom-navbar,.custom-navbar-settings");t.forEach(t=>t.style.display="flex");i.applyImportantStyle("customNavbarStyle")}}})()}})(); \ No newline at end of file diff --git a/min/title.min.js b/min/title.min.js index 6fef82048..a58efb818 100644 --- a/min/title.min.js +++ b/min/title.min.js @@ -1 +1 @@ -(()=>{return(e,t)=>{function i(e=true){const t=document.title.replace("_番剧_bilibili_哔哩哔哩","").replace("_电影_bilibili_哔哩哔哩","").replace("_哔哩哔哩 (゜-゜)つロ 干杯~-bilibili","").replace(" - 哔哩哔哩直播,二次元弹幕直播平台","").replace(/[\/\\:\*\?"<>\|]/g," ").trim();if(!e||document.URL.indexOf("/bangumi")!==-1){return t}else{const e=document.querySelector("#multi_page .cur-list>ul li.on a");if(e===null){return t}else{const i=e.getAttribute("title");return t+" - "+i}}}function r(e,t=true,i={}){const r=new Date;const l={title:document.title.replace(/:([^:]+?)_番剧_bilibili_哔哩哔哩/,"").replace(/:([^:]+?)_国创_bilibili_哔哩哔哩/,"").replace(/:([^:]+?)_电影_bilibili_哔哩哔哩/,"").replace(/:([^:]+?)_纪录片_bilibili_哔哩哔哩/,"").replace("_哔哩哔哩 (゜-゜)つロ 干杯~-bilibili","").replace(/(.*?) - (.*?) - 哔哩哔哩直播,二次元弹幕直播平台/,"$1").trim(),ep:(()=>{if(!t){return null}const e=dq("#eplist_module li.cursor .ep-title");if(e!==null){return e.innerText}const i=document.querySelector("#multi_page .cur-list>ul li.on a");if(i!==null){return i.getAttribute("title")}return null})(),aid:unsafeWindow.aid,cid:unsafeWindow.cid,lid:document.URL.replace(/https:\/\/live\.bilibili\.com\/(\d+).*/,"$1"),y:r.getFullYear().toString(),M:(r.getMonth()+1).toString().padStart(2,"0"),d:r.getDate().toString().padStart(2,"0"),h:r.getHours().toString().padStart(2,"0"),m:r.getMinutes().toString().padStart(2,"0"),s:r.getSeconds().toString().padStart(2,"0"),ms:r.getMilliseconds().toString().substr(0,3)};Object.assign(l,i);const n=Object.keys(l).reduce((e,t)=>{return e.replace(new RegExp(`\\[([^\\[\\]]*?)${t}([^\\[\\]]*?)\\]`,"g"),l[t]?`$1${l[t]}$2`:"")},e);return n.replace(/[\/\\:\*\?"<>\|]/g," ")}function l(t=true){if(e.filenameFormat===undefined){return i(t)}return r(e.filenameFormat,t)}return{export:{getFriendlyTitle:l,formatTitle:r}}}})(); \ No newline at end of file +(()=>{return(e,t)=>{function i(e=true){const t=document.title.replace("_番剧_bilibili_哔哩哔哩","").replace("_电影_bilibili_哔哩哔哩","").replace("_哔哩哔哩 (゜-゜)つロ 干杯~-bilibili","").replace(" - 哔哩哔哩直播,二次元弹幕直播平台","").replace(/[\/\\:\*\?"<>\|]/g," ").trim();if(!e||document.URL.indexOf("/bangumi")!==-1){return t}else{const e=document.querySelector("#multi_page .cur-list>ul li.on a");if(e===null){return t}else{const i=e.getAttribute("title");return t+" - "+i}}}function r(e,t=true,i={}){const r=new Date;const l={title:document.title.replace(/:([^:]+?)_番剧_bilibili_哔哩哔哩/,"").replace(/:([^:]+?)_国创_bilibili_哔哩哔哩/,"").replace(/:([^:]+?)_电影_bilibili_哔哩哔哩/,"").replace(/:([^:]+?)_纪录片_bilibili_哔哩哔哩/,"").replace("_哔哩哔哩 (゜-゜)つロ 干杯~-bilibili","").replace(/(.*?) - (.*?) - 哔哩哔哩直播,二次元弹幕直播平台/,"$1").trim(),ep:(()=>{if(!t){return}const e=dq("#eplist_module li.cursor .ep-title");if(e!==null){return e.innerText}const i=document.querySelector("#multi_page .cur-list>ul li.on a");if(i!==null){return i.getAttribute("title")}})(),aid:unsafeWindow.aid,cid:unsafeWindow.cid,lid:document.URL.replace(/https:\/\/live\.bilibili\.com\/(\d+).*/,"$1"),y:r.getFullYear().toString(),M:(r.getMonth()+1).toString().padStart(2,"0"),d:r.getDate().toString().padStart(2,"0"),h:r.getHours().toString().padStart(2,"0"),m:r.getMinutes().toString().padStart(2,"0"),s:r.getSeconds().toString().padStart(2,"0"),ms:r.getMilliseconds().toString().substr(0,3)};Object.assign(l,i);const n=Object.keys(l).reduce((e,t)=>{return e.replace(new RegExp(`\\[([^\\[\\]]*?)${t}([^\\[\\]]*?)\\]`,"g"),l[t]?`$1${l[t]}$2`:"")},e);return n.replace(/[\/\\:\*\?"<>\|]/g," ")}function l(t=true){if(e.filenameFormat===undefined){return i(t)}return r(e.filenameFormat,t)}return{export:{getFriendlyTitle:l,formatTitle:r}}}})(); \ No newline at end of file diff --git a/src/video/title.d.ts b/src/video/title.d.ts deleted file mode 100644 index bd8f9c9b7..000000000 --- a/src/video/title.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -export function getFriendlyTitle(includesPageTitle?: boolean): string -export function formatTitle(format: string, includesPageTitle?: boolean, extraData?: { [key: string]: string }): string diff --git a/src/video/title.js b/src/video/title.ts similarity index 92% rename from src/video/title.js rename to src/video/title.ts index 20e2bdd9d..c107114ab 100644 --- a/src/video/title.js +++ b/src/video/title.ts @@ -18,9 +18,12 @@ function oldGetFriendlyTitle (includesPageTitle = true) { } } } -export function formatTitle (format, includesPageTitle = true, extraData = {}) { +type StringMap = { + [key: string]: string | undefined | null +} +export function formatTitle (format: string, includesPageTitle = true, extraData: StringMap = {}) { const now = new Date() - const data = { + const data: StringMap = { title: document.title .replace(/:([^:]+?)_番剧_bilibili_哔哩哔哩/, '') .replace(/:([^:]+?)_国创_bilibili_哔哩哔哩/, '') @@ -31,9 +34,9 @@ export function formatTitle (format, includesPageTitle = true, extraData = {}) { .trim(), ep: (() => { if (!includesPageTitle) { - return null + return } - const bangumiPage = dq('#eplist_module li.cursor .ep-title') + const bangumiPage = dq('#eplist_module li.cursor .ep-title') as HTMLElement if (bangumiPage !== null) { return bangumiPage.innerText } @@ -41,7 +44,6 @@ export function formatTitle (format, includesPageTitle = true, extraData = {}) { if (pageLink !== null) { return pageLink.getAttribute('title') } - return null })(), aid: unsafeWindow.aid, cid: unsafeWindow.cid,