mirror of
https://github.com/the1812/Bilibili-Evolved.git
synced 2025-11-04 21:22:45 +08:00
1 line
1.4 KiB
JavaScript
1 line
1.4 KiB
JavaScript
(()=>{return(t,n)=>{class e{constructor(n="",e="",s="0 0 auto",i=false,a=false,o=null,r=null,u=null,l=0,c=t.touchNavBar,h=false){this.html=n;this.popupHtml=e;this.flex=s;this.disabled=i;this.requestedPopup=a;this.initialPopup=o;this.onPopup=r;this.href=u;this.notifyCount=l;this.touch=c;this.active=h;this.noPadding=false;this.transparent=false;this.boundingWidth=0}get name(){return"blank1"}get order(){return t.customNavbarOrder[this.name]}get hidden(){return t.customNavbarHidden.includes(this.name)}get element(){return dq(`.custom-navbar li[data-name='${this.name}']`)}async setNotifyCount(t){const n=await SpinQuery.select(`.custom-navbar li[data-name='${this.name}'] .notify-count`);if(!n||!t){n.innerHTML="";return}n.innerHTML=t.toString()}async setNotifyStyle(t){const n=await SpinQuery.select(`.custom-navbar li[data-name='${this.name}'] .notify-count`);if(!n){return}const e={1:"number",2:"dot",3:"hidden"};n.classList.remove(...Object.values(e));n.classList.add(e[t])}async checkPosition(){if(this.boundingWidth===0){return}const t=this.element;const n=t.querySelector(".main-content ~ .popup-container");if(!n){return}const e=t.getBoundingClientRect();const s=e.left+e.width/2;const i=document.documentElement.clientWidth;const a=s-this.boundingWidth/2;const o=s+this.boundingWidth/2;if(a<0){n.style.transform=`translateX(${Math.abs(a)+1}px)`}else if(o>i){n.style.transform=`translateX(${-(o-i)-1}px)`}else{n.style.transform=""}}}return{export:{NavbarComponent:e}}}})(); |