jadefin/mods/FixStuck.js
2024-03-01 21:01:22 +01:00

40 lines
1.0 KiB
JavaScript

//@ts-check
import JadefinIntegrity from '../JadefinIntegrity.js';
import JadefinMod from "../JadefinMod.js";
export default JadefinIntegrity("FixStuck", import.meta.url, () => new (class FixStuck extends JadefinMod {
constructor() {
super();
}
async init(name, url) {
await super.init(name, url);
const time =
window.location.hash.startsWith("#!/dialog?") ? 500 :
2500;
setTimeout(() => {
if (this.isStuck) {
this.log.w("Checked, stuck - reloading");
window.location.hash = "";
window.location.reload();
} else {
this.log.i("Checked, not stuck");
}
}, time);
this.log.i("Ready");
}
get isStuck() {
return (
(document.querySelector(".mainAnimatedPages.skinBody")?.childElementCount ?? 0) == 0 &&
!document.querySelector(".mainDrawer > .mainDrawer-scrollContainer > .userMenuOptions")
);
}
})());