From 334f60a00671f5087cb7639fec0c5c9089ea711e Mon Sep 17 00:00:00 2001 From: the1812 Date: Sun, 11 Nov 2018 19:43:26 +0800 Subject: [PATCH] Add details button on notify new version --- bilibili-evolved.offline.user.js | 2 +- bilibili-evolved.preview-offline.user.js | 2 +- min/notify-new-version.min.js | 2 +- utils/notify-new-version.js | 6 ++++++ 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/bilibili-evolved.offline.user.js b/bilibili-evolved.offline.user.js index bb19abdf1..cc9e68324 100644 --- a/bilibili-evolved.offline.user.js +++ b/bilibili-evolved.offline.user.js @@ -805,7 +805,7 @@ offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/m offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/remove-watermark.min.js"] = (()=>{return(i,l)=>{const n="bilibili-live-watermark";if($(`#${n}`).length===0){l.applyStyleFromText(`\n \n `)}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/full-tweets-title.min.js"] = (()=>{return(e,l)=>{l.applyStyle("fullTweetsTitleStyle")}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/view-cover.min.js"] = (()=>{return(e,t)=>{class i{constructor(e){this.url=e;if($(".image-viewer").length===0){this.createDom()}this.viewer=$(".image-viewer-container");this.downloadImage()}createDom(){$("body").append(t.data.imageViewerDom.text);$(".image-viewer-container .close").on("click",()=>this.hide());t.applyStyle("imageViewerStyle")}downloadImage(){const e=new XMLHttpRequest;e.open("GET",this.url.replace("http:","https:"),true);e.responseType="blob";e.onload=(()=>{const t=document.title.replace("_哔哩哔哩 (゜-゜)つロ 干杯~-bilibili","");const i=URL.createObjectURL(e.response);this.imageData=i;this.viewer.find(".download").attr("href",i).attr("download",t);this.viewer.find(".image").prop("src",i)});e.send()}show(){this.viewer.addClass("opened")}hide(){this.viewer.removeClass("opened")}}if($("meta[itemprop='image'],meta[property='og:image']").length>0){return{settingsWidget:{category:"视频与直播",content:``,success:()=>{new SpinQuery(()=>$("meta[itemprop='image'],meta[property='og:image']"),e=>e.length>0&&e.prop("content"),e=>{const t=new i(e.prop("content"));$("#view-video-cover").on("click",()=>{t.show()}).parent().removeClass("hidden")}).start()}}}}else{return{settingsWidget:{category:"视频与直播",content:``,success:()=>{SpinQuery.any(()=>$(".header-info-ctnr .room-cover"),e=>{const t=e.attr("href").match(/space\.bilibili\.com\/([\d]+)/);if(t&&t[1]){const e=t[1];const n=`https://api.live.bilibili.com/bili/getRoomInfo/${e}`;downloadText(n,e=>{const t=e.slice(1,-2);const n=JSON.parse(t).data.cover;const o=new i(n);$("#view-live-cover").on("click",()=>{o.show()}).parent().removeClass("hidden")})}})}}}}}})(); -offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/notify-new-version.min.js"] = (()=>{return(t,s)=>{const n={less:-1,equal:0,greater:1,incomparable:NaN};class e{constructor(t){this.parts=t.split(".").map(t=>parseInt(t));this.versionString=t}compareTo(t){for(let s=0;st.parts[s]){return n.greater}return n.less}if(this.parts.length!==t.parts.length){return n.less}return n.equal}greaterThan(t){return this.compareTo(t)===n.greater}lessThan(t){return this.compareTo(t)===n.less}equals(t){return this.compareTo(t)===n.equal}}const r=new e(s.data.latestVersion.text);const i=new e(t.currentVersion);if(r.greaterThan(i)){if(i.lessThan(new e("1.4.2"))){SpinQuery.any(()=>$(".gui-settings"),s=>{s.addClass("gui-settings-notification");const n=$(".gui-settings-footer");n.after(`\n `);$("#new-version-update").parent().attr("href",t.latestVersionLink)});const s=`新版本${r.versionString}已发布. 更新`;Toast.show(s,"检查更新",1e4)}else{return{settingsWidget:{after:()=>$(".gui-settings-content"),content:`
\n 新版本${r.versionString}已发布.\n \n \n 更新\n \n \n
`,success:()=>{SpinQuery.any(()=>$(".gui-settings"),t=>{t.addClass("gui-settings-notification")});const s=`新版本${r.versionString}已发布. 更新`;Toast.show(s,"检查更新")}}}}}}})(); +offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/notify-new-version.min.js"] = (()=>{return(t,n)=>{const s={less:-1,equal:0,greater:1,incomparable:NaN};class e{constructor(t){this.parts=t.split(".").map(t=>parseInt(t));this.versionString=t}compareTo(t){for(let n=0;nt.parts[n]){return s.greater}return s.less}if(this.parts.length!==t.parts.length){return s.less}return s.equal}greaterThan(t){return this.compareTo(t)===s.greater}lessThan(t){return this.compareTo(t)===s.less}equals(t){return this.compareTo(t)===s.equal}}const i=new e(n.data.latestVersion.text);const r=new e(t.currentVersion);if(i.greaterThan(r)){if(r.lessThan(new e("1.4.2"))){SpinQuery.any(()=>$(".gui-settings"),n=>{n.addClass("gui-settings-notification");const s=$(".gui-settings-footer");s.after(`\n `);$("#new-version-update").parent().attr("href",t.latestVersionLink)});const n=`新版本${i.versionString}已发布. 更新`;Toast.show(n,"检查更新",1e4)}else{return{settingsWidget:{after:()=>$(".gui-settings-content"),content:`
\n 新版本${i.versionString}已发布.\n \n \n 更新\n \n \n \n \n 详细信息\n \n \n
`,success:()=>{SpinQuery.any(()=>$(".gui-settings"),t=>{t.addClass("gui-settings-notification")});const n=`新版本${i.versionString}已发布. 更新`;Toast.show(n,"检查更新")}}}}}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/toast.min.js"] = (()=>{return(t,s)=>{class e{constructor(t="",s="",e="default"){this.type=e;this.message=t;this.title=s;this.duration=3e3;this.element=$(this.cardHtml)[0];this.$element=$(this.element);$(".toast-card-container").append(this.$element)}show(){this.element.classList.add("visible");this.$element.find(".toast-card-dismiss").on("click",()=>this.dismiss());if(this.duration){setTimeout(()=>this.dismiss(),this.duration)}}dismiss(){if(this.element.classList.contains("visible")){this.$element.on("transitionend",()=>this.$element.remove());this.element.classList.remove("visible")}}get cardHtml(){return`\n
\n
\n

${this.title}

\n \n \n \n \n
\n

${this.message}

\n
\n `}static get container(){return $(".toast-card-container")}static createToastContainer(){if($(".toast-card-container").length===0){$("body").append(`
`)}}static internalShow(t,s,i,a){const n=new e(t,s,a);n.duration=i;n.show()}static show(t,s,e){this.internalShow(t,s,e,"default")}static info(t,s,e){this.internalShow(t,s,e,"info")}static success(t,s,e){this.internalShow(t,s,e,"success")}static error(t,s,e){this.internalShow(t,s,e,"error")}}s.applyStyle("toastStyle");e.createToastContainer();return{export:e}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/remove-top-mask.min.js"] = (()=>{return(i,n)=>{const l="bilibili-video-top-mask";if($(`#${l}`).length===0){n.applyStyleFromText(`\n \n `)}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/blur-video-control.min.js"] = (()=>{return(r,o)=>{Observer.subtree("#bofqi",()=>{SpinQuery.count(()=>$(".bui-slider .bui-track.bui-track-video-progress,.bilibili-player-video-control-bottom"),2,r=>{if(!r.hasClass("video-control-blur-container")){r.addClass("video-control-blur-container");r.prepend(`
`)}})});o.applyStyle("blurVideoControlStyle")}})(); diff --git a/bilibili-evolved.preview-offline.user.js b/bilibili-evolved.preview-offline.user.js index 6ef584242..400b63dd0 100644 --- a/bilibili-evolved.preview-offline.user.js +++ b/bilibili-evolved.preview-offline.user.js @@ -805,7 +805,7 @@ offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/m offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/remove-watermark.min.js"] = (()=>{return(i,l)=>{const n="bilibili-live-watermark";if($(`#${n}`).length===0){l.applyStyleFromText(`\n \n `)}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/full-tweets-title.min.js"] = (()=>{return(e,l)=>{l.applyStyle("fullTweetsTitleStyle")}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/view-cover.min.js"] = (()=>{return(e,t)=>{class i{constructor(e){this.url=e;if($(".image-viewer").length===0){this.createDom()}this.viewer=$(".image-viewer-container");this.downloadImage()}createDom(){$("body").append(t.data.imageViewerDom.text);$(".image-viewer-container .close").on("click",()=>this.hide());t.applyStyle("imageViewerStyle")}downloadImage(){const e=new XMLHttpRequest;e.open("GET",this.url.replace("http:","https:"),true);e.responseType="blob";e.onload=(()=>{const t=document.title.replace("_哔哩哔哩 (゜-゜)つロ 干杯~-bilibili","");const i=URL.createObjectURL(e.response);this.imageData=i;this.viewer.find(".download").attr("href",i).attr("download",t);this.viewer.find(".image").prop("src",i)});e.send()}show(){this.viewer.addClass("opened")}hide(){this.viewer.removeClass("opened")}}if($("meta[itemprop='image'],meta[property='og:image']").length>0){return{settingsWidget:{category:"视频与直播",content:``,success:()=>{new SpinQuery(()=>$("meta[itemprop='image'],meta[property='og:image']"),e=>e.length>0&&e.prop("content"),e=>{const t=new i(e.prop("content"));$("#view-video-cover").on("click",()=>{t.show()}).parent().removeClass("hidden")}).start()}}}}else{return{settingsWidget:{category:"视频与直播",content:``,success:()=>{SpinQuery.any(()=>$(".header-info-ctnr .room-cover"),e=>{const t=e.attr("href").match(/space\.bilibili\.com\/([\d]+)/);if(t&&t[1]){const e=t[1];const n=`https://api.live.bilibili.com/bili/getRoomInfo/${e}`;downloadText(n,e=>{const t=e.slice(1,-2);const n=JSON.parse(t).data.cover;const o=new i(n);$("#view-live-cover").on("click",()=>{o.show()}).parent().removeClass("hidden")})}})}}}}}})(); -offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/notify-new-version.min.js"] = (()=>{return(t,s)=>{const n={less:-1,equal:0,greater:1,incomparable:NaN};class e{constructor(t){this.parts=t.split(".").map(t=>parseInt(t));this.versionString=t}compareTo(t){for(let s=0;st.parts[s]){return n.greater}return n.less}if(this.parts.length!==t.parts.length){return n.less}return n.equal}greaterThan(t){return this.compareTo(t)===n.greater}lessThan(t){return this.compareTo(t)===n.less}equals(t){return this.compareTo(t)===n.equal}}const r=new e(s.data.latestVersion.text);const i=new e(t.currentVersion);if(r.greaterThan(i)){if(i.lessThan(new e("1.4.2"))){SpinQuery.any(()=>$(".gui-settings"),s=>{s.addClass("gui-settings-notification");const n=$(".gui-settings-footer");n.after(`\n `);$("#new-version-update").parent().attr("href",t.latestVersionLink)});const s=`新版本${r.versionString}已发布. 更新`;Toast.show(s,"检查更新",1e4)}else{return{settingsWidget:{after:()=>$(".gui-settings-content"),content:`
\n 新版本${r.versionString}已发布.\n \n \n 更新\n \n \n
`,success:()=>{SpinQuery.any(()=>$(".gui-settings"),t=>{t.addClass("gui-settings-notification")});const s=`新版本${r.versionString}已发布. 更新`;Toast.show(s,"检查更新")}}}}}}})(); +offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/notify-new-version.min.js"] = (()=>{return(t,n)=>{const s={less:-1,equal:0,greater:1,incomparable:NaN};class e{constructor(t){this.parts=t.split(".").map(t=>parseInt(t));this.versionString=t}compareTo(t){for(let n=0;nt.parts[n]){return s.greater}return s.less}if(this.parts.length!==t.parts.length){return s.less}return s.equal}greaterThan(t){return this.compareTo(t)===s.greater}lessThan(t){return this.compareTo(t)===s.less}equals(t){return this.compareTo(t)===s.equal}}const i=new e(n.data.latestVersion.text);const r=new e(t.currentVersion);if(i.greaterThan(r)){if(r.lessThan(new e("1.4.2"))){SpinQuery.any(()=>$(".gui-settings"),n=>{n.addClass("gui-settings-notification");const s=$(".gui-settings-footer");s.after(`\n `);$("#new-version-update").parent().attr("href",t.latestVersionLink)});const n=`新版本${i.versionString}已发布. 更新`;Toast.show(n,"检查更新",1e4)}else{return{settingsWidget:{after:()=>$(".gui-settings-content"),content:`
\n 新版本${i.versionString}已发布.\n \n \n 更新\n \n \n \n \n 详细信息\n \n \n
`,success:()=>{SpinQuery.any(()=>$(".gui-settings"),t=>{t.addClass("gui-settings-notification")});const n=`新版本${i.versionString}已发布. 更新`;Toast.show(n,"检查更新")}}}}}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/toast.min.js"] = (()=>{return(t,s)=>{class e{constructor(t="",s="",e="default"){this.type=e;this.message=t;this.title=s;this.duration=3e3;this.element=$(this.cardHtml)[0];this.$element=$(this.element);$(".toast-card-container").append(this.$element)}show(){this.element.classList.add("visible");this.$element.find(".toast-card-dismiss").on("click",()=>this.dismiss());if(this.duration){setTimeout(()=>this.dismiss(),this.duration)}}dismiss(){if(this.element.classList.contains("visible")){this.$element.on("transitionend",()=>this.$element.remove());this.element.classList.remove("visible")}}get cardHtml(){return`\n
\n
\n

${this.title}

\n \n \n \n \n
\n

${this.message}

\n
\n `}static get container(){return $(".toast-card-container")}static createToastContainer(){if($(".toast-card-container").length===0){$("body").append(`
`)}}static internalShow(t,s,i,a){const n=new e(t,s,a);n.duration=i;n.show()}static show(t,s,e){this.internalShow(t,s,e,"default")}static info(t,s,e){this.internalShow(t,s,e,"info")}static success(t,s,e){this.internalShow(t,s,e,"success")}static error(t,s,e){this.internalShow(t,s,e,"error")}}s.applyStyle("toastStyle");e.createToastContainer();return{export:e}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/remove-top-mask.min.js"] = (()=>{return(i,n)=>{const l="bilibili-video-top-mask";if($(`#${l}`).length===0){n.applyStyleFromText(`\n \n `)}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/blur-video-control.min.js"] = (()=>{return(r,o)=>{Observer.subtree("#bofqi",()=>{SpinQuery.count(()=>$(".bui-slider .bui-track.bui-track-video-progress,.bilibili-player-video-control-bottom"),2,r=>{if(!r.hasClass("video-control-blur-container")){r.addClass("video-control-blur-container");r.prepend(`
`)}})});o.applyStyle("blurVideoControlStyle")}})(); diff --git a/min/notify-new-version.min.js b/min/notify-new-version.min.js index 0d244bd95..7507e5800 100644 --- a/min/notify-new-version.min.js +++ b/min/notify-new-version.min.js @@ -1 +1 @@ -(()=>{return(t,s)=>{const n={less:-1,equal:0,greater:1,incomparable:NaN};class e{constructor(t){this.parts=t.split(".").map(t=>parseInt(t));this.versionString=t}compareTo(t){for(let s=0;st.parts[s]){return n.greater}return n.less}if(this.parts.length!==t.parts.length){return n.less}return n.equal}greaterThan(t){return this.compareTo(t)===n.greater}lessThan(t){return this.compareTo(t)===n.less}equals(t){return this.compareTo(t)===n.equal}}const r=new e(s.data.latestVersion.text);const i=new e(t.currentVersion);if(r.greaterThan(i)){if(i.lessThan(new e("1.4.2"))){SpinQuery.any(()=>$(".gui-settings"),s=>{s.addClass("gui-settings-notification");const n=$(".gui-settings-footer");n.after(`\n `);$("#new-version-update").parent().attr("href",t.latestVersionLink)});const s=`新版本${r.versionString}已发布. 更新`;Toast.show(s,"检查更新",1e4)}else{return{settingsWidget:{after:()=>$(".gui-settings-content"),content:`
\n 新版本${r.versionString}已发布.\n \n \n 更新\n \n \n
`,success:()=>{SpinQuery.any(()=>$(".gui-settings"),t=>{t.addClass("gui-settings-notification")});const s=`新版本${r.versionString}已发布. 更新`;Toast.show(s,"检查更新")}}}}}}})(); \ No newline at end of file +(()=>{return(t,n)=>{const s={less:-1,equal:0,greater:1,incomparable:NaN};class e{constructor(t){this.parts=t.split(".").map(t=>parseInt(t));this.versionString=t}compareTo(t){for(let n=0;nt.parts[n]){return s.greater}return s.less}if(this.parts.length!==t.parts.length){return s.less}return s.equal}greaterThan(t){return this.compareTo(t)===s.greater}lessThan(t){return this.compareTo(t)===s.less}equals(t){return this.compareTo(t)===s.equal}}const i=new e(n.data.latestVersion.text);const r=new e(t.currentVersion);if(i.greaterThan(r)){if(r.lessThan(new e("1.4.2"))){SpinQuery.any(()=>$(".gui-settings"),n=>{n.addClass("gui-settings-notification");const s=$(".gui-settings-footer");s.after(`\n `);$("#new-version-update").parent().attr("href",t.latestVersionLink)});const n=`新版本${i.versionString}已发布. 更新`;Toast.show(n,"检查更新",1e4)}else{return{settingsWidget:{after:()=>$(".gui-settings-content"),content:`
\n 新版本${i.versionString}已发布.\n \n \n 更新\n \n \n \n \n 详细信息\n \n \n
`,success:()=>{SpinQuery.any(()=>$(".gui-settings"),t=>{t.addClass("gui-settings-notification")});const n=`新版本${i.versionString}已发布. 更新`;Toast.show(n,"检查更新")}}}}}}})(); \ No newline at end of file diff --git a/utils/notify-new-version.js b/utils/notify-new-version.js index 8d55bd767..0b6d38124 100644 --- a/utils/notify-new-version.js +++ b/utils/notify-new-version.js @@ -94,6 +94,12 @@ 更新 + + + `, success: () => {