mirror of
https://github.com/the1812/Bilibili-Evolved.git
synced 2025-11-04 21:22:45 +08:00
1 line
2.2 KiB
JavaScript
1 line
2.2 KiB
JavaScript
(()=>{return(e,t)=>{(async()=>{const t=await SpinQuery.select(()=>document.querySelector(`input[key=defaultPlayerLayout]`));const s=await SpinQuery.select(()=>document.querySelector(`input[key=defaultBangumiLayout]`));const o=await SpinQuery.select(()=>document.querySelector(`input[key=overrideNavBar]`));if(!t||!s){logError("无法加载播放器布局选项.");return}class i{setCookie(e,t){document.cookie=`${e}=${t};path=/;domain=.bilibili.com;max-age=31536000`}clearCookie(e){document.cookie=`${e}=;path=/;domain=.bilibili.com;max-age=0`}getValue(e){return document.cookie.replace(new RegExp(`(?:(?:^|.*;\\s*)${e}\\s*\\=\\s*([^;]*).*$)|^.*$`),"$1")}checkSettings(){return e.useDefaultPlayerLayout}checkCookies(){if(!this.checkSettings()){return}}useNewLayout(){if(!this.checkSettings()){return}}useOldLayout(){if(!this.checkSettings()){return}}setLayout(e){if(e){this.useNewLayout()}else{this.useOldLayout()}}}class u extends i{checkCookies(){super.checkCookies();const t=this.getValue(this.cookieKey);if(t===""||parseInt(t)<0&&e.defaultPlayerLayout!=="旧版"){this.useNewLayout()}else if(e.defaultPlayerLayout!=="新版"){this.useOldLayout()}}constructor(){super();this.cookieKey="stardustvideo";this.checkCookies()}useNewLayout(){super.useNewLayout();this.setCookie(this.cookieKey,1);o.disabled=false;$(o).change()}useOldLayout(){super.useOldLayout();this.setCookie(this.cookieKey,-1);if(e.overrideNavBar){o.checked=false;o.disabled=true;$(o).change();e.overrideNavBar=false;saveSettings(e);Toast.info(`已关闭<span>搜索栏置顶</span>功能, 因为旧版视频播放器布局不兼容此功能.`,"提示",5e3)}}}class a extends i{checkCookies(){super.checkCookies();const t=this.getValue(this.cookieKey);if(t===""||parseInt(t)<=0&&e.defaultBangumiLayout!=="旧版"){this.useNewLayout()}else if(e.defaultBangumiLayout!=="新版"){this.useOldLayout()}}constructor(){super();this.cookieKey="stardustpgcv";this.checkCookies()}useNewLayout(){super.useNewLayout();this.setCookie(this.cookieKey,"0606")}useOldLayout(){super.useOldLayout();this.setCookie(this.cookieKey,0)}}const c=new u;$(t).on("input",()=>{c.setLayout(t.value==="新版")});const r=new a;$(s).on("input",()=>{r.setLayout(s.value==="新版")})})()}})(); |