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