mirror of
https://github.com/the1812/Bilibili-Evolved.git
synced 2025-11-04 21:22:45 +08:00
1 line
1.6 KiB
JavaScript
1 line
1.6 KiB
JavaScript
(()=>{return(e,o)=>{class t{setCookie(e,o){document.cookie=`${e}=${o};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(){}useNewLayout(){}useOldLayout(){}setLayout(e){if(e){this.useNewLayout()}else{this.useOldLayout()}}}class s extends t{checkCookies(){super.checkCookies();const o=this.getValue(this.cookieKey);if(o===""||parseInt(o)<0&&e.defaultPlayerLayout!=="旧版"){console.log(`default/old -> new`);this.useNewLayout()}else if(e.defaultPlayerLayout!=="新版"){console.log(`new -> old`);this.useOldLayout()}}constructor(){super();this.cookieKey="stardustvideo";this.checkCookies()}useNewLayout(){super.useNewLayout();this.setCookie(this.cookieKey,1)}useOldLayout(){super.useOldLayout();this.setCookie(this.cookieKey,-1)}}class u extends t{checkCookies(){super.checkCookies();const o=this.getValue(this.cookieKey);if(o===""||parseInt(o)<=0&&e.defaultBangumiLayout!=="旧版"){console.log(`default/old -> new`);this.useNewLayout()}else if(e.defaultBangumiLayout!=="新版"){console.log(`new -> old`);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 i=new s;addSettingsListener("defaultPlayerLayout",e=>{i.setLayout(e==="新版")});const a=new u;addSettingsListener("defaultBangumiLayout",e=>{a.setLayout(e==="新版")})}})(); |