From c82a2655c4f4369f1c7090acd249723dbd44238f Mon Sep 17 00:00:00 2001 From: the1812 Date: Sun, 30 Sep 2018 23:07:57 +0800 Subject: [PATCH] Fix scroll trembling when mini video is on --- bilibili-evolved.offline.user.js | 4 ++-- bilibili-evolved.preview-offline.user.js | 4 ++-- min/new-styles.min.js | 2 +- style/new-styles.js | 3 +++ 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/bilibili-evolved.offline.user.js b/bilibili-evolved.offline.user.js index 992cb1e0b..c2f4b7602 100644 --- a/bilibili-evolved.offline.user.js +++ b/bilibili-evolved.offline.user.js @@ -1,6 +1,6 @@ // ==UserScript== // @name Bilibili Evolved (Offline) -// @version 76.12 +// @version 76.31 // @description 增强哔哩哔哩Web端体验.(离线版) // @author Grant Howard, Coulomb-G // @match *://*.bilibili.com/* @@ -542,7 +542,7 @@ offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/u offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/version.txt"] = `1.5.1`; offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/gui-settings.min.js"] = (()=>{return(e,t)=>{const n={red:"#e57373",pink:"#F06292",purple:"#BA68C8",deepPurple:"#9575CD",indigo:"#7986CB",blue:"#2196F3",lightBlue:"#00A0D8",cyan:"#00ACC1",teal:"#26A69A",green:"#81C784",lightGreen:"#9CCC65",orange:"#FF9800",deepOrange:"#FF7043",brown:"#A1887F",grey:"#757575",blueGrey:"#78909C"};const i={settings:"M12,15.5A3.5,3.5 0 0,1 8.5,12A3.5,3.5 0 0,1 12,8.5A3.5,3.5 0 0,1 15.5,12A3.5,3.5 0 0,1 12,15.5M19.43,12.97C19.47,12.65 19.5,12.33 19.5,12C19.5,11.67 19.47,11.34 19.43,11L21.54,9.37C21.73,9.22 21.78,8.95 21.66,8.73L19.66,5.27C19.54,5.05 19.27,4.96 19.05,5.05L16.56,6.05C16.04,5.66 15.5,5.32 14.87,5.07L14.5,2.42C14.46,2.18 14.25,2 14,2H10C9.75,2 9.54,2.18 9.5,2.42L9.13,5.07C8.5,5.32 7.96,5.66 7.44,6.05L4.95,5.05C4.73,4.96 4.46,5.05 4.34,5.27L2.34,8.73C2.21,8.95 2.27,9.22 2.46,9.37L4.57,11C4.53,11.34 4.5,11.67 4.5,12C4.5,12.33 4.53,12.65 4.57,12.97L2.46,14.63C2.27,14.78 2.21,15.05 2.34,15.27L4.34,18.73C4.46,18.95 4.73,19.03 4.95,18.95L7.44,17.94C7.96,18.34 8.5,18.68 9.13,18.93L9.5,21.58C9.54,21.82 9.75,22 10,22H14C14.25,22 14.46,21.82 14.5,21.58L14.87,18.93C15.5,18.67 16.04,18.34 16.56,17.94L19.05,18.95C19.27,19.03 19.54,18.95 19.66,18.73L21.66,15.27C21.78,15.05 21.73,14.78 21.54,14.63L19.43,12.97Z",close:"M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z",ok:"M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"};const s={customStyleColor:t=>{const n=t.match(/^#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$/);if(n){if(t.length<7){return`#${t[1]}${t[1]}${t[2]}${t[2]}${t[3]}${t[3]}`}else{return t}}else{return e.customStyleColor}},blurBackgroundOpacity:t=>{const n=t.match(/^([-\+]?\d+)(\.\d+)?$/);if(n){const e=parseFloat(t);if(e>=0&&e<=1){return t}}return e.blurBackgroundOpacity}};function o(e,t){const n=e.match(/^([\d]{1,2}):([\d]{1,2})$/);if(n&&n.length>=3){const e={hour:parseInt(n[1]),minute:parseInt(n[2])};(function(){while(this.minute<0){this.minute+=60;this.hour-=1}while(this.minute>=60){this.minute-=60;this.hour+=1}while(this.hour<0){this.hour+=24}while(this.hour>=24){this.hour-=24}}).call(e);return`${e.hour}:${e.minute<10?"0"+e.minute:e.minute}`}else{return t}}s.darkScheduleStart=(t=>o(t,e.darkScheduleStart));s.darkScheduleEnd=(t=>o(t,e.darkScheduleEnd));function c(e,t,n){$(`input[type='checkbox'][key='${e}']`).prop("checked",n).change();$(`input[type='text'][key='${e}']`).val(n)}function r(){for(const t in e){c(t,undefined,e[t])}}function a(){$(".gui-settings-header .gui-settings-close").on("click",()=>{$(".gui-settings-panel").removeClass("opened")});$("input[key='customStyleColor']").on("input",()=>{const e=s.customStyleColor($("input[key='customStyleColor']").val());$("div.custom-color-preview").css("background",e)});$("input[type='text'][key]").each((t,n)=>{$(n).attr("placeholder",e[$(n).attr("key")])});$("div.custom-color-preview").on("click",()=>{const e=$(".predefined-colors");e.toggleClass("opened")});const t=document.querySelector("button.save");const n=document.querySelector(".gui-settings-footer svg.gui-settings-ok");const i="save-complete";const o=()=>{n.classList.remove(i);t.classList.remove(i)};t.addEventListener("animationend",o);n.addEventListener("animationend",o);t.addEventListener("click",()=>{$("input[type='checkbox'][key]").each((t,n)=>{e[$(n).attr("key")]=$(n).prop("checked")});$("input[type='text'][key]").each((t,n)=>{const i=$(n).attr("key");const o=$(n).val();e[i]=s[i](o)});saveSettings(e);if([n,t].every(e=>!e.classList.contains(i))){t.classList.add(i);n.classList.add(i)}r()});onSettingsChange(c)}function l(){$(".gui-settings-close path").attr("d",i.close);$(".gui-settings-ok path").attr("d",i.ok);$(".gui-settings svg path").attr("d",i.settings)}function u(){const e={};$(`input[dependencies]`).each((t,n)=>{const i=$(n).attr("dependencies");if(i){e[$(n).attr("key")]=i}});$(`input[type='checkbox'][key]`).on("change",t=>{const n=$(t.target);const i=n.prop("checked");for(const t in e){const s=e[t].split(" ");if(s.indexOf(n.attr("key"))!==-1){let e=true;if(i&&s.every(e=>$(`input[key='${e}']`).prop("checked"))){e=false}$(`input[key='${t}']`).prop("disabled",e);if(e){$(`input[key='${t}'][type='text']`).parent().addClass("disabled")}else{$(`input[key='${t}'][type='text']`).parent().removeClass("disabled")}}}const s=$(".predefined-colors");if(s.hasClass("opened")){s.removeClass("opened")}})}function d(e){if($(".gui-settings").length===0){e.append(`
\n \n \n \n
`);$(".gui-settings").on("click",()=>{$(".gui-settings-panel").addClass("opened")})}t.applyStyle("guiSettingsStyle","gui-settings-style")}function p(){const e=$(".predefined-colors-grid");for(const t of Object.values(n)){$(`
`).appendTo(e).css("background",t).attr("data-color",t).on("click",e=>{$(`input[key='customStyleColor']`).val($(e.target).attr("data-color")).trigger("input");$("div.custom-color-preview").on("click")})}}function g(){$(".gui-settings-content ul li.category, .gui-settings-content").addClass("blur")}new SpinQuery(()=>$("body"),e=>e.length>0&&!unsafeWindow.frameElement&&unsafeWindow.$,n=>{d(n);const i=t.data.guiSettingsDom.text;if(i){$("body").append(i);a();l();u();r();p();if(e.blurSettingsPanel){g()}if(typeof offlineData!=="undefined"){$("input[key=useCache]").prop("disabled",true)}}}).start();return{ajaxReload:false}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/dark-styles.min.js"] = (()=>{return(l,e)=>{if(l.useDarkStyle){e.applyStyle("scrollbarStyle","bilibili-scrollbar-style");SpinQuery.any(()=>$(".custom-scrollbar"),l=>l.removeClass("custom-scrollbar"));if($("#banner_link").length===0||$("#banner_link").length>0&&l.overrideNavBar&&!l.showBanner){e.applyImportantStyle("darkStyleNavBar","bilibili-new-style-dark-nav-bar")}e.applyStyle("darkStyle","bilibili-new-style-dark");e.applyImportantStyle("darkStyleImportant","bilibili-new-style-dark-important")}else{$("#bilibili-scrollbar-style,#bilibili-new-style-dark-nav-bar,#bilibili-new-style-dark,#bilibili-new-style-dark-important").remove()}return{ajaxReload:false}}})(); -offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/new-styles.min.js"] = (()=>{return(e,l)=>{l.applyStyle("scrollbarStyle","bilibili-scrollbar-style");SpinQuery.any(()=>$(".custom-scrollbar"),e=>e.removeClass("custom-scrollbar"));SpinQuery.any(()=>$(".bili-wrapper,#link-navbar-vm,.link-navbar"),()=>{const e=document.getElementsByClassName("bili-wrapper")[0]||document.getElementById("link-navbar-vm")||document.getElementsByClassName("link-navbar")[0];let t=false;if(e instanceof Element){const l=parseInt(window.getComputedStyle(e).height);t=l===50||l===0||l===56}if(t){l.applyStyle("style","bilibili-new-style")}else{l.applyStyle("oldStyle","bilibili-new-style")}});return{ajaxReload:false}}})(); +offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/new-styles.min.js"] = (()=>{return(e,l)=>{l.applyStyle("scrollbarStyle","bilibili-scrollbar-style");SpinQuery.any(()=>$(".custom-scrollbar"),e=>e.removeClass("custom-scrollbar"));SpinQuery.any(()=>$(".bili-wrapper,#link-navbar-vm,.link-navbar"),()=>{const e=document.getElementsByClassName("bili-wrapper")[0]||document.getElementById("link-navbar-vm")||document.getElementsByClassName("link-navbar")[0];let t=false;if(e instanceof Element){const l=parseInt(window.getComputedStyle(e).height);t=l===50||l===0||l===56}if(t){l.applyStyle("style","bilibili-new-style")}else{l.applyStyle("oldStyle","bilibili-new-style")}});new SpinQuery(()=>$(".player-wrap,.danmaku-box"),e=>e.attr("style"),e=>e.attr("style","")).start();return{ajaxReload:false}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/override-navbar.min.js"] = (()=>{return(e,r)=>{new SpinQuery(()=>$(".head-content.bili-wrapper>div.search").not(".filter-item"),e=>e.length>0&&$(".nav-con.fr").length>0,e=>{e.detach().insertAfter(".nav-con.fr")}).start();r.applyStyle("navbarOverrideStyle","bilibili-nav-bar-override");if(!e.showBanner){r.applyStyle("noBannerStyle","bilibili-banner-override")}return{ajaxReload:false}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/touch-navbar.min.js"] = (()=>{return()=>{SpinQuery.count(()=>$("ul.fr>li.nav-item").not(".profile-info"),6,r=>{const e=(r,e)=>{const n=$(e);n.css("cursor","pointer");const t=n.find("a.t");t.removeAttr("href")};r.each(e)});return{ajaxReload:false}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/touch-player.min.js"] = (()=>{return(t,i)=>{const e=t=>{let i=0;let e=0;while(t&&!isNaN(t.offsetLeft)&&!isNaN(t.offsetTop)){i+=t.offsetLeft-t.scrollLeft;e+=t.offsetTop-t.scrollTop;t=t.offsetParent}return{x:i,y:e}};const s=(t,i=1)=>{const e=t.toString();const s=e.indexOf(".");if(s!==-1){if(e.length-s>i+1){return e.substring(0,s+i+1)}else{return e}}else{return e+".0"}};const o=t=>{t=Math.abs(t);const i=Math.floor(t/3600);const e=Math.floor((t-i*3600)/60);const o=t-i*3600-e*60;let n=s(o)+"秒";if(e>0){n=e+"分"+n}if(i>0){n=i+"时"+n}return n};const n=t=>{t=Math.abs(t);const i=Math.floor(t/3600);const e=Math.floor((t-i*3600)/60);const o=t-i*3600-e*60;let n=(o<10?"0":"")+s(o);n=(e<10?"0":"")+e+":"+n;n=(i<10?"0":"")+i+":"+n;return n};class a{constructor(t){this.action=new l(t);this.onTouchStart=null;this.onTouchEnd=null;this._direction=null;t.addEventListener("touchstart",t=>{this._xDown=t.touches[0].clientX;this._yDown=t.touches[0].clientY;if(this.onTouchStart){this.onTouchStart(t)}});t.addEventListener("touchmove",i=>{if(!this._xDown||!this._yDown){return}const s=i.touches[0].clientX;const o=i.touches[0].clientY;const n=e(t);const a={x:(i.touches[0].pageX-n.x)/t.clientWidth,y:(i.touches[0].pageY-n.y)/t.clientHeight,width:t.clientWidth,height:t.clientHeight};const l=this._xDown-s;const c=this._yDown-o;if(!this._direction){let t="";if(Math.abs(l)>Math.abs(c)){t="horizontal"}else{t="vertical"}this._direction=t;i.preventDefault()}else{if(this._direction==="vertical"){this.action.startAction(this._direction,c,a)}else if(this._direction==="horizontal"){this.action.startAction(this._direction,-l,a)}i.preventDefault()}});t.addEventListener("touchend",t=>{this._xDown=null;this._yDown=null;this._direction=null;if(this.onTouchEnd){this.onTouchEnd(t)}})}}class l{constructor(t){this.lowSpeedForward=null;this.lowSpeedBackward=null;this.mediumSpeedForward=null;this.mediumSpeedBackward=null;this.highSpeedForward=null;this.highSpeedBackward=null;this.lowVolumeUp=null;this.lowVolumeDown=null;this.mediumVolumeUp=null;this.mediumVolumeDown=null;this.highVolumeUp=null;this.highVolumeDown=null;this.speedCancel=null;this.volumeCancel=null;this.minSwipeDistance=20;this.onActionStart=null;this.onActionEnd=null;this._element=t;this._touchStart=false;this._startPosition=null;this._lastAction=null;t.addEventListener("touchstart",t=>{this._touchStart=true});t.addEventListener("touchend",t=>{this._startPosition=null;this.onActionEnd&&this.onActionEnd(this._lastAction);this._lastAction=null})}startAction(t,i,e){if(this._touchStart){this.onActionStart&&this.onActionStart(t);this._startPosition=e;this._touchStart=false}if(t==="vertical"){if(Math.abs(i)=1/3&&this._startPosition.x<=2/3){t=1;s=this.mediumVolumeUp;o=this.mediumVolumeDown}else{t=2;s=this.highVolumeUp;o=this.highVolumeDown}if(i>0){const o=Math.round(t*100*(i-this.minSwipeDistance)/(1.5*e.height));s&&s(o);this._lastAction={type:"volume",volume:o}}else{const s=Math.round(t*100*(i+this.minSwipeDistance)/(1.5*e.height));o&&o(s);this._lastAction={type:"volume",volume:s}}}}else if(t==="horizontal"){if(e.y<1/3&&(e.x<.1||e.x>.9)||Math.abs(i)=1/3&&this._startPosition.y<=2/3){t=.2;e=this.mediumSpeedForward;s=this.mediumSpeedBackward}else{t=1;e=this.highSpeedForward;s=this.highSpeedBackward}if(i>0){const s=(i-this.minSwipeDistance)*t;e&&e(s);this._lastAction={type:"playback",seconds:s}}else{const e=(i+this.minSwipeDistance)*t;s&&s(e);this._lastAction={type:"playback",seconds:e}}}}}}class c{constructor(){const t=window.location.href;const i=t.match(/av([\d]+)/);this.aid=i[1];const e=t.match(/p=([\d]+)/);this.page=e?e[1]:1;this.pagesData=null;this.cidMap={};this.cidData={};this.supportWebp=c.supportWebp;downloadText(t,t=>this.findCid(t))}findCid(t){const i=t.match(/"pages":(\[[^\0]*\]),"embedPlayer"/);if(i){this.pagesData=JSON.parse(i[1]);this.pagesData.forEach(t=>{this.cidMap[t.page]=t.cid})}}getVideoshot(t,i){if(!this.cidData[this.page]){downloadText(`https://api.bilibili.com/x/player/videoshot?aid=${this.aid}&cid=${this.cidMap[this.page]}&index=1`,e=>{this.cidData[this.page]=JSON.parse(e).data;this.getVideoshot(t,i)})}else{const e=this.cidData[this.page];const s=e.index;let o=0;for(let i=0;i=s[i]&&tt.replace(".jpg",".jpg@.webp"))}const a=parseInt(e.pv_x_len)||10;const l=parseInt(e.pv_y_len)||10;const c=parseInt(e.pv_x_size)||160;const r=parseInt(e.pv_y_size)||90;const h=-(o%100%a)*c;const d=-Math.floor(o%100/l)*r;i({width:c,height:r,backgroundImage:`url(${n[Math.floor(o/100)]})`,backgroundPosition:`${h}px ${d}px`})}}static get supportWebp(){try{const t=document.createElement("canvas");if(t.getContext&&t.getContext("2d"))try{return t.toDataURL("image/webp").indexOf("data:image/webp")===0}catch(t){return false}else return false}catch(t){return false}}}function r(t){t.unbind("click")}function h(i){if($(".touch-video-box").length!==0){return}$(".bilibili-player-video-subtitle").before(`\n
\n
\n
\n
\n
\n
`);const e=$("video");const l=e.prop("duration");const r=new a(i.get(0));const h=document.getElementsByClassName("touch-video-info")[0];const d=document.getElementsByClassName("touch-video-box")[0];let u=Math.round(e.prop("volume")*100);const p=t=>{t/=100;if(t<0){t=0}else if(t>1){t=1}e.prop("volume",t);$(".bilibili-player-video-volume-num").text(Math.round(t*100));$(".bui-thumb").css("transform",`translateY(-${48*t}px)`);$(".bui-track-vertical .bui-bar").css("transform",`scaleY(${t})`);if(t===0){$(".bilibili-player-video-btn-volume").addClass(".video-state-volume-min");$(".bilibili-player-video-btn-volume").removeClass(".video-state-volume-max");e.prop("muted",true)}else if(t===1){$(".bilibili-player-video-btn-volume").removeClass(".video-state-volume-min");$(".bilibili-player-video-btn-volume").addClass(".video-state-volume-max");e.prop("muted",false)}else{$(".bilibili-player-video-btn-volume").removeClass(".video-state-volume-min");$(".bilibili-player-video-btn-volume").removeClass(".video-state-volume-max");e.prop("muted",false)}};if(t.touchVideoPlayerAnimation){d.classList.add("animation")}r.action.onActionStart=(t=>{d.classList.add("adjust-opened");h.innerHTML="";u=Math.round(e.prop("volume")*100)});const m=new c;const v=t=>{return i=>{const a=e.prop("currentTime");let c=a+i;let r=s(100*c/l);let d=i;if(c>l){c=l;r=100;d=l-a}else if(c<0){c=0;r=0;d=a}const u=`${n(a)} →
${n(c)} (${r}%)`;const p=`\n
\n
\n ${t}速\n
\n
\n 进度: ${i>0?"+":"-"}${o(d)}\n
\n
\n
\n
\n
\n
\n
\n ${u}\n
\n
\n `;h.innerHTML=p;m.getVideoshot(c,t=>$(".videoshot").css(t));$(".touch-progress").css("transform",`scaleX(${r/100})`)}};r.action.lowSpeedBackward=v("低");r.action.lowSpeedForward=v("低");r.action.mediumSpeedBackward=v("中");r.action.mediumSpeedForward=v("中");r.action.highSpeedBackward=v("高");r.action.highSpeedForward=v("高");const f=t=>{return i=>{let e=u+i;let s=Math.abs(i);if(e>100){e=100;s=100-u}else if(e<0){e=0;s=u}const o=`${u} → ${e}`;p(e);const n=`\n
\n
\n ${t}速\n
\n
\n 音量: ${i>0?"+":"-"}${s}\n
\n
\n
\n
\n ${o}\n
\n
\n `;h.innerHTML=n;$(".touch-progress").css("transform",`scaleX(${e/100})`)}};r.action.lowVolumeUp=f("低");r.action.lowVolumeDown=f("低");r.action.mediumVolumeUp=f("中");r.action.mediumVolumeDown=f("中");r.action.highVolumeUp=f("高");r.action.highVolumeDown=f("高");r.action.speedCancel=(()=>{h.innerHTML=`松开手指,取消进退`;$(".touch-progress").css("transform","scaleX(0)")});r.action.volumeCancel=(()=>{h.innerHTML=`松开手指,取消调整`;$(".touch-progress").css("transform","scaleX(0)");p(u)});if(!unsafeWindow.TOUCH_PLAYER_DEBUG){r.action.onActionEnd=(t=>{h.innerHTML="";if(t){if(t.type==="playback"){let i=e.prop("currentTime");i+=t.seconds;if(i<0){i=0}else if(i>l){i=l}e.prop("currentTime",i)}}d.classList.remove("adjust-opened")})}}function d(t){if(!t.hasClass("disable-original-hover")){t.addClass("disable-original-hover");const i=unsafeWindow.$(".bilibili-player-video");const e="touch-video-control-show";const s=i.data("events").click[0].handler;let o=false;const n=(i,o)=>{if(i){s(o)}else{t.toggleClass(e)}};const a=t=>{if(!o){o=true;setTimeout(()=>{if(o){o=false;n(false,t)}},160)}else{o=false;n(true,t)}};i.unbind("click");i.on("click",a)}}function u(){SpinQuery.any(()=>$(".bilibili-player-iconfont,.bilibili-player-video-quality-menu"),r);new SpinQuery(()=>$(".bilibili-player-video"),t=>t.length>0&&$("video").length>0&&$("video").prop("duration"),h).start();if(t.touchVideoPlayerDoubleTapControl){new SpinQuery(()=>$(".bilibili-player-area"),t=>t.length>0&&unsafeWindow.$&&unsafeWindow.$(".bilibili-player-video").data("events"),d).start()}}runAndObserveDomMutation("#bofqi",()=>u());i.applyStyle("touchPlayerStyle","bilibili-touch-video-player");return{ajaxReload:false}}})(); diff --git a/bilibili-evolved.preview-offline.user.js b/bilibili-evolved.preview-offline.user.js index 337c2cce9..167908e4f 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 76.12 +// @version 76.31 // @description 增强哔哩哔哩Web端体验.(预览离线版) // @author Grant Howard, Coulomb-G // @match *://*.bilibili.com/* @@ -542,7 +542,7 @@ offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/u offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/version.txt"] = `1.5.1`; offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/gui-settings.min.js"] = (()=>{return(e,t)=>{const n={red:"#e57373",pink:"#F06292",purple:"#BA68C8",deepPurple:"#9575CD",indigo:"#7986CB",blue:"#2196F3",lightBlue:"#00A0D8",cyan:"#00ACC1",teal:"#26A69A",green:"#81C784",lightGreen:"#9CCC65",orange:"#FF9800",deepOrange:"#FF7043",brown:"#A1887F",grey:"#757575",blueGrey:"#78909C"};const i={settings:"M12,15.5A3.5,3.5 0 0,1 8.5,12A3.5,3.5 0 0,1 12,8.5A3.5,3.5 0 0,1 15.5,12A3.5,3.5 0 0,1 12,15.5M19.43,12.97C19.47,12.65 19.5,12.33 19.5,12C19.5,11.67 19.47,11.34 19.43,11L21.54,9.37C21.73,9.22 21.78,8.95 21.66,8.73L19.66,5.27C19.54,5.05 19.27,4.96 19.05,5.05L16.56,6.05C16.04,5.66 15.5,5.32 14.87,5.07L14.5,2.42C14.46,2.18 14.25,2 14,2H10C9.75,2 9.54,2.18 9.5,2.42L9.13,5.07C8.5,5.32 7.96,5.66 7.44,6.05L4.95,5.05C4.73,4.96 4.46,5.05 4.34,5.27L2.34,8.73C2.21,8.95 2.27,9.22 2.46,9.37L4.57,11C4.53,11.34 4.5,11.67 4.5,12C4.5,12.33 4.53,12.65 4.57,12.97L2.46,14.63C2.27,14.78 2.21,15.05 2.34,15.27L4.34,18.73C4.46,18.95 4.73,19.03 4.95,18.95L7.44,17.94C7.96,18.34 8.5,18.68 9.13,18.93L9.5,21.58C9.54,21.82 9.75,22 10,22H14C14.25,22 14.46,21.82 14.5,21.58L14.87,18.93C15.5,18.67 16.04,18.34 16.56,17.94L19.05,18.95C19.27,19.03 19.54,18.95 19.66,18.73L21.66,15.27C21.78,15.05 21.73,14.78 21.54,14.63L19.43,12.97Z",close:"M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z",ok:"M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"};const s={customStyleColor:t=>{const n=t.match(/^#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$/);if(n){if(t.length<7){return`#${t[1]}${t[1]}${t[2]}${t[2]}${t[3]}${t[3]}`}else{return t}}else{return e.customStyleColor}},blurBackgroundOpacity:t=>{const n=t.match(/^([-\+]?\d+)(\.\d+)?$/);if(n){const e=parseFloat(t);if(e>=0&&e<=1){return t}}return e.blurBackgroundOpacity}};function o(e,t){const n=e.match(/^([\d]{1,2}):([\d]{1,2})$/);if(n&&n.length>=3){const e={hour:parseInt(n[1]),minute:parseInt(n[2])};(function(){while(this.minute<0){this.minute+=60;this.hour-=1}while(this.minute>=60){this.minute-=60;this.hour+=1}while(this.hour<0){this.hour+=24}while(this.hour>=24){this.hour-=24}}).call(e);return`${e.hour}:${e.minute<10?"0"+e.minute:e.minute}`}else{return t}}s.darkScheduleStart=(t=>o(t,e.darkScheduleStart));s.darkScheduleEnd=(t=>o(t,e.darkScheduleEnd));function c(e,t,n){$(`input[type='checkbox'][key='${e}']`).prop("checked",n).change();$(`input[type='text'][key='${e}']`).val(n)}function r(){for(const t in e){c(t,undefined,e[t])}}function a(){$(".gui-settings-header .gui-settings-close").on("click",()=>{$(".gui-settings-panel").removeClass("opened")});$("input[key='customStyleColor']").on("input",()=>{const e=s.customStyleColor($("input[key='customStyleColor']").val());$("div.custom-color-preview").css("background",e)});$("input[type='text'][key]").each((t,n)=>{$(n).attr("placeholder",e[$(n).attr("key")])});$("div.custom-color-preview").on("click",()=>{const e=$(".predefined-colors");e.toggleClass("opened")});const t=document.querySelector("button.save");const n=document.querySelector(".gui-settings-footer svg.gui-settings-ok");const i="save-complete";const o=()=>{n.classList.remove(i);t.classList.remove(i)};t.addEventListener("animationend",o);n.addEventListener("animationend",o);t.addEventListener("click",()=>{$("input[type='checkbox'][key]").each((t,n)=>{e[$(n).attr("key")]=$(n).prop("checked")});$("input[type='text'][key]").each((t,n)=>{const i=$(n).attr("key");const o=$(n).val();e[i]=s[i](o)});saveSettings(e);if([n,t].every(e=>!e.classList.contains(i))){t.classList.add(i);n.classList.add(i)}r()});onSettingsChange(c)}function l(){$(".gui-settings-close path").attr("d",i.close);$(".gui-settings-ok path").attr("d",i.ok);$(".gui-settings svg path").attr("d",i.settings)}function u(){const e={};$(`input[dependencies]`).each((t,n)=>{const i=$(n).attr("dependencies");if(i){e[$(n).attr("key")]=i}});$(`input[type='checkbox'][key]`).on("change",t=>{const n=$(t.target);const i=n.prop("checked");for(const t in e){const s=e[t].split(" ");if(s.indexOf(n.attr("key"))!==-1){let e=true;if(i&&s.every(e=>$(`input[key='${e}']`).prop("checked"))){e=false}$(`input[key='${t}']`).prop("disabled",e);if(e){$(`input[key='${t}'][type='text']`).parent().addClass("disabled")}else{$(`input[key='${t}'][type='text']`).parent().removeClass("disabled")}}}const s=$(".predefined-colors");if(s.hasClass("opened")){s.removeClass("opened")}})}function d(e){if($(".gui-settings").length===0){e.append(`
\n \n \n \n
`);$(".gui-settings").on("click",()=>{$(".gui-settings-panel").addClass("opened")})}t.applyStyle("guiSettingsStyle","gui-settings-style")}function p(){const e=$(".predefined-colors-grid");for(const t of Object.values(n)){$(`
`).appendTo(e).css("background",t).attr("data-color",t).on("click",e=>{$(`input[key='customStyleColor']`).val($(e.target).attr("data-color")).trigger("input");$("div.custom-color-preview").on("click")})}}function g(){$(".gui-settings-content ul li.category, .gui-settings-content").addClass("blur")}new SpinQuery(()=>$("body"),e=>e.length>0&&!unsafeWindow.frameElement&&unsafeWindow.$,n=>{d(n);const i=t.data.guiSettingsDom.text;if(i){$("body").append(i);a();l();u();r();p();if(e.blurSettingsPanel){g()}if(typeof offlineData!=="undefined"){$("input[key=useCache]").prop("disabled",true)}}}).start();return{ajaxReload:false}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/dark-styles.min.js"] = (()=>{return(l,e)=>{if(l.useDarkStyle){e.applyStyle("scrollbarStyle","bilibili-scrollbar-style");SpinQuery.any(()=>$(".custom-scrollbar"),l=>l.removeClass("custom-scrollbar"));if($("#banner_link").length===0||$("#banner_link").length>0&&l.overrideNavBar&&!l.showBanner){e.applyImportantStyle("darkStyleNavBar","bilibili-new-style-dark-nav-bar")}e.applyStyle("darkStyle","bilibili-new-style-dark");e.applyImportantStyle("darkStyleImportant","bilibili-new-style-dark-important")}else{$("#bilibili-scrollbar-style,#bilibili-new-style-dark-nav-bar,#bilibili-new-style-dark,#bilibili-new-style-dark-important").remove()}return{ajaxReload:false}}})(); -offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/new-styles.min.js"] = (()=>{return(e,l)=>{l.applyStyle("scrollbarStyle","bilibili-scrollbar-style");SpinQuery.any(()=>$(".custom-scrollbar"),e=>e.removeClass("custom-scrollbar"));SpinQuery.any(()=>$(".bili-wrapper,#link-navbar-vm,.link-navbar"),()=>{const e=document.getElementsByClassName("bili-wrapper")[0]||document.getElementById("link-navbar-vm")||document.getElementsByClassName("link-navbar")[0];let t=false;if(e instanceof Element){const l=parseInt(window.getComputedStyle(e).height);t=l===50||l===0||l===56}if(t){l.applyStyle("style","bilibili-new-style")}else{l.applyStyle("oldStyle","bilibili-new-style")}});return{ajaxReload:false}}})(); +offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/new-styles.min.js"] = (()=>{return(e,l)=>{l.applyStyle("scrollbarStyle","bilibili-scrollbar-style");SpinQuery.any(()=>$(".custom-scrollbar"),e=>e.removeClass("custom-scrollbar"));SpinQuery.any(()=>$(".bili-wrapper,#link-navbar-vm,.link-navbar"),()=>{const e=document.getElementsByClassName("bili-wrapper")[0]||document.getElementById("link-navbar-vm")||document.getElementsByClassName("link-navbar")[0];let t=false;if(e instanceof Element){const l=parseInt(window.getComputedStyle(e).height);t=l===50||l===0||l===56}if(t){l.applyStyle("style","bilibili-new-style")}else{l.applyStyle("oldStyle","bilibili-new-style")}});new SpinQuery(()=>$(".player-wrap,.danmaku-box"),e=>e.attr("style"),e=>e.attr("style","")).start();return{ajaxReload:false}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/override-navbar.min.js"] = (()=>{return(e,r)=>{new SpinQuery(()=>$(".head-content.bili-wrapper>div.search").not(".filter-item"),e=>e.length>0&&$(".nav-con.fr").length>0,e=>{e.detach().insertAfter(".nav-con.fr")}).start();r.applyStyle("navbarOverrideStyle","bilibili-nav-bar-override");if(!e.showBanner){r.applyStyle("noBannerStyle","bilibili-banner-override")}return{ajaxReload:false}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/touch-navbar.min.js"] = (()=>{return()=>{SpinQuery.count(()=>$("ul.fr>li.nav-item").not(".profile-info"),6,r=>{const e=(r,e)=>{const n=$(e);n.css("cursor","pointer");const t=n.find("a.t");t.removeAttr("href")};r.each(e)});return{ajaxReload:false}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/touch-player.min.js"] = (()=>{return(t,i)=>{const e=t=>{let i=0;let e=0;while(t&&!isNaN(t.offsetLeft)&&!isNaN(t.offsetTop)){i+=t.offsetLeft-t.scrollLeft;e+=t.offsetTop-t.scrollTop;t=t.offsetParent}return{x:i,y:e}};const s=(t,i=1)=>{const e=t.toString();const s=e.indexOf(".");if(s!==-1){if(e.length-s>i+1){return e.substring(0,s+i+1)}else{return e}}else{return e+".0"}};const o=t=>{t=Math.abs(t);const i=Math.floor(t/3600);const e=Math.floor((t-i*3600)/60);const o=t-i*3600-e*60;let n=s(o)+"秒";if(e>0){n=e+"分"+n}if(i>0){n=i+"时"+n}return n};const n=t=>{t=Math.abs(t);const i=Math.floor(t/3600);const e=Math.floor((t-i*3600)/60);const o=t-i*3600-e*60;let n=(o<10?"0":"")+s(o);n=(e<10?"0":"")+e+":"+n;n=(i<10?"0":"")+i+":"+n;return n};class a{constructor(t){this.action=new l(t);this.onTouchStart=null;this.onTouchEnd=null;this._direction=null;t.addEventListener("touchstart",t=>{this._xDown=t.touches[0].clientX;this._yDown=t.touches[0].clientY;if(this.onTouchStart){this.onTouchStart(t)}});t.addEventListener("touchmove",i=>{if(!this._xDown||!this._yDown){return}const s=i.touches[0].clientX;const o=i.touches[0].clientY;const n=e(t);const a={x:(i.touches[0].pageX-n.x)/t.clientWidth,y:(i.touches[0].pageY-n.y)/t.clientHeight,width:t.clientWidth,height:t.clientHeight};const l=this._xDown-s;const c=this._yDown-o;if(!this._direction){let t="";if(Math.abs(l)>Math.abs(c)){t="horizontal"}else{t="vertical"}this._direction=t;i.preventDefault()}else{if(this._direction==="vertical"){this.action.startAction(this._direction,c,a)}else if(this._direction==="horizontal"){this.action.startAction(this._direction,-l,a)}i.preventDefault()}});t.addEventListener("touchend",t=>{this._xDown=null;this._yDown=null;this._direction=null;if(this.onTouchEnd){this.onTouchEnd(t)}})}}class l{constructor(t){this.lowSpeedForward=null;this.lowSpeedBackward=null;this.mediumSpeedForward=null;this.mediumSpeedBackward=null;this.highSpeedForward=null;this.highSpeedBackward=null;this.lowVolumeUp=null;this.lowVolumeDown=null;this.mediumVolumeUp=null;this.mediumVolumeDown=null;this.highVolumeUp=null;this.highVolumeDown=null;this.speedCancel=null;this.volumeCancel=null;this.minSwipeDistance=20;this.onActionStart=null;this.onActionEnd=null;this._element=t;this._touchStart=false;this._startPosition=null;this._lastAction=null;t.addEventListener("touchstart",t=>{this._touchStart=true});t.addEventListener("touchend",t=>{this._startPosition=null;this.onActionEnd&&this.onActionEnd(this._lastAction);this._lastAction=null})}startAction(t,i,e){if(this._touchStart){this.onActionStart&&this.onActionStart(t);this._startPosition=e;this._touchStart=false}if(t==="vertical"){if(Math.abs(i)=1/3&&this._startPosition.x<=2/3){t=1;s=this.mediumVolumeUp;o=this.mediumVolumeDown}else{t=2;s=this.highVolumeUp;o=this.highVolumeDown}if(i>0){const o=Math.round(t*100*(i-this.minSwipeDistance)/(1.5*e.height));s&&s(o);this._lastAction={type:"volume",volume:o}}else{const s=Math.round(t*100*(i+this.minSwipeDistance)/(1.5*e.height));o&&o(s);this._lastAction={type:"volume",volume:s}}}}else if(t==="horizontal"){if(e.y<1/3&&(e.x<.1||e.x>.9)||Math.abs(i)=1/3&&this._startPosition.y<=2/3){t=.2;e=this.mediumSpeedForward;s=this.mediumSpeedBackward}else{t=1;e=this.highSpeedForward;s=this.highSpeedBackward}if(i>0){const s=(i-this.minSwipeDistance)*t;e&&e(s);this._lastAction={type:"playback",seconds:s}}else{const e=(i+this.minSwipeDistance)*t;s&&s(e);this._lastAction={type:"playback",seconds:e}}}}}}class c{constructor(){const t=window.location.href;const i=t.match(/av([\d]+)/);this.aid=i[1];const e=t.match(/p=([\d]+)/);this.page=e?e[1]:1;this.pagesData=null;this.cidMap={};this.cidData={};this.supportWebp=c.supportWebp;downloadText(t,t=>this.findCid(t))}findCid(t){const i=t.match(/"pages":(\[[^\0]*\]),"embedPlayer"/);if(i){this.pagesData=JSON.parse(i[1]);this.pagesData.forEach(t=>{this.cidMap[t.page]=t.cid})}}getVideoshot(t,i){if(!this.cidData[this.page]){downloadText(`https://api.bilibili.com/x/player/videoshot?aid=${this.aid}&cid=${this.cidMap[this.page]}&index=1`,e=>{this.cidData[this.page]=JSON.parse(e).data;this.getVideoshot(t,i)})}else{const e=this.cidData[this.page];const s=e.index;let o=0;for(let i=0;i=s[i]&&tt.replace(".jpg",".jpg@.webp"))}const a=parseInt(e.pv_x_len)||10;const l=parseInt(e.pv_y_len)||10;const c=parseInt(e.pv_x_size)||160;const r=parseInt(e.pv_y_size)||90;const h=-(o%100%a)*c;const d=-Math.floor(o%100/l)*r;i({width:c,height:r,backgroundImage:`url(${n[Math.floor(o/100)]})`,backgroundPosition:`${h}px ${d}px`})}}static get supportWebp(){try{const t=document.createElement("canvas");if(t.getContext&&t.getContext("2d"))try{return t.toDataURL("image/webp").indexOf("data:image/webp")===0}catch(t){return false}else return false}catch(t){return false}}}function r(t){t.unbind("click")}function h(i){if($(".touch-video-box").length!==0){return}$(".bilibili-player-video-subtitle").before(`\n
\n
\n
\n
\n
\n
`);const e=$("video");const l=e.prop("duration");const r=new a(i.get(0));const h=document.getElementsByClassName("touch-video-info")[0];const d=document.getElementsByClassName("touch-video-box")[0];let u=Math.round(e.prop("volume")*100);const p=t=>{t/=100;if(t<0){t=0}else if(t>1){t=1}e.prop("volume",t);$(".bilibili-player-video-volume-num").text(Math.round(t*100));$(".bui-thumb").css("transform",`translateY(-${48*t}px)`);$(".bui-track-vertical .bui-bar").css("transform",`scaleY(${t})`);if(t===0){$(".bilibili-player-video-btn-volume").addClass(".video-state-volume-min");$(".bilibili-player-video-btn-volume").removeClass(".video-state-volume-max");e.prop("muted",true)}else if(t===1){$(".bilibili-player-video-btn-volume").removeClass(".video-state-volume-min");$(".bilibili-player-video-btn-volume").addClass(".video-state-volume-max");e.prop("muted",false)}else{$(".bilibili-player-video-btn-volume").removeClass(".video-state-volume-min");$(".bilibili-player-video-btn-volume").removeClass(".video-state-volume-max");e.prop("muted",false)}};if(t.touchVideoPlayerAnimation){d.classList.add("animation")}r.action.onActionStart=(t=>{d.classList.add("adjust-opened");h.innerHTML="";u=Math.round(e.prop("volume")*100)});const m=new c;const v=t=>{return i=>{const a=e.prop("currentTime");let c=a+i;let r=s(100*c/l);let d=i;if(c>l){c=l;r=100;d=l-a}else if(c<0){c=0;r=0;d=a}const u=`${n(a)} →
${n(c)} (${r}%)`;const p=`\n
\n
\n ${t}速\n
\n
\n 进度: ${i>0?"+":"-"}${o(d)}\n
\n
\n
\n
\n
\n
\n
\n ${u}\n
\n
\n `;h.innerHTML=p;m.getVideoshot(c,t=>$(".videoshot").css(t));$(".touch-progress").css("transform",`scaleX(${r/100})`)}};r.action.lowSpeedBackward=v("低");r.action.lowSpeedForward=v("低");r.action.mediumSpeedBackward=v("中");r.action.mediumSpeedForward=v("中");r.action.highSpeedBackward=v("高");r.action.highSpeedForward=v("高");const f=t=>{return i=>{let e=u+i;let s=Math.abs(i);if(e>100){e=100;s=100-u}else if(e<0){e=0;s=u}const o=`${u} → ${e}`;p(e);const n=`\n
\n
\n ${t}速\n
\n
\n 音量: ${i>0?"+":"-"}${s}\n
\n
\n
\n
\n ${o}\n
\n
\n `;h.innerHTML=n;$(".touch-progress").css("transform",`scaleX(${e/100})`)}};r.action.lowVolumeUp=f("低");r.action.lowVolumeDown=f("低");r.action.mediumVolumeUp=f("中");r.action.mediumVolumeDown=f("中");r.action.highVolumeUp=f("高");r.action.highVolumeDown=f("高");r.action.speedCancel=(()=>{h.innerHTML=`松开手指,取消进退`;$(".touch-progress").css("transform","scaleX(0)")});r.action.volumeCancel=(()=>{h.innerHTML=`松开手指,取消调整`;$(".touch-progress").css("transform","scaleX(0)");p(u)});if(!unsafeWindow.TOUCH_PLAYER_DEBUG){r.action.onActionEnd=(t=>{h.innerHTML="";if(t){if(t.type==="playback"){let i=e.prop("currentTime");i+=t.seconds;if(i<0){i=0}else if(i>l){i=l}e.prop("currentTime",i)}}d.classList.remove("adjust-opened")})}}function d(t){if(!t.hasClass("disable-original-hover")){t.addClass("disable-original-hover");const i=unsafeWindow.$(".bilibili-player-video");const e="touch-video-control-show";const s=i.data("events").click[0].handler;let o=false;const n=(i,o)=>{if(i){s(o)}else{t.toggleClass(e)}};const a=t=>{if(!o){o=true;setTimeout(()=>{if(o){o=false;n(false,t)}},160)}else{o=false;n(true,t)}};i.unbind("click");i.on("click",a)}}function u(){SpinQuery.any(()=>$(".bilibili-player-iconfont,.bilibili-player-video-quality-menu"),r);new SpinQuery(()=>$(".bilibili-player-video"),t=>t.length>0&&$("video").length>0&&$("video").prop("duration"),h).start();if(t.touchVideoPlayerDoubleTapControl){new SpinQuery(()=>$(".bilibili-player-area"),t=>t.length>0&&unsafeWindow.$&&unsafeWindow.$(".bilibili-player-video").data("events"),d).start()}}runAndObserveDomMutation("#bofqi",()=>u());i.applyStyle("touchPlayerStyle","bilibili-touch-video-player");return{ajaxReload:false}}})(); diff --git a/min/new-styles.min.js b/min/new-styles.min.js index 70217ec4e..8810789e6 100644 --- a/min/new-styles.min.js +++ b/min/new-styles.min.js @@ -1 +1 @@ -(()=>{return(e,l)=>{l.applyStyle("scrollbarStyle","bilibili-scrollbar-style");SpinQuery.any(()=>$(".custom-scrollbar"),e=>e.removeClass("custom-scrollbar"));SpinQuery.any(()=>$(".bili-wrapper,#link-navbar-vm,.link-navbar"),()=>{const e=document.getElementsByClassName("bili-wrapper")[0]||document.getElementById("link-navbar-vm")||document.getElementsByClassName("link-navbar")[0];let t=false;if(e instanceof Element){const l=parseInt(window.getComputedStyle(e).height);t=l===50||l===0||l===56}if(t){l.applyStyle("style","bilibili-new-style")}else{l.applyStyle("oldStyle","bilibili-new-style")}});return{ajaxReload:false}}})(); \ No newline at end of file +(()=>{return(e,l)=>{l.applyStyle("scrollbarStyle","bilibili-scrollbar-style");SpinQuery.any(()=>$(".custom-scrollbar"),e=>e.removeClass("custom-scrollbar"));SpinQuery.any(()=>$(".bili-wrapper,#link-navbar-vm,.link-navbar"),()=>{const e=document.getElementsByClassName("bili-wrapper")[0]||document.getElementById("link-navbar-vm")||document.getElementsByClassName("link-navbar")[0];let t=false;if(e instanceof Element){const l=parseInt(window.getComputedStyle(e).height);t=l===50||l===0||l===56}if(t){l.applyStyle("style","bilibili-new-style")}else{l.applyStyle("oldStyle","bilibili-new-style")}});new SpinQuery(()=>$(".player-wrap,.danmaku-box"),e=>e.attr("style"),e=>e.attr("style","")).start();return{ajaxReload:false}}})(); \ No newline at end of file diff --git a/style/new-styles.js b/style/new-styles.js index 6b9ba5c21..109cb12c5 100644 --- a/style/new-styles.js +++ b/style/new-styles.js @@ -32,6 +32,9 @@ resources.applyStyle("oldStyle", "bilibili-new-style"); } }); + new SpinQuery(() => $(".player-wrap,.danmaku-box"), + it => it.attr("style"), + it => it.attr("style", "")).start(); return { ajaxReload: false };