jadefin/mods/FixStuck.js

45 lines
1.1 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);
if (true) {
// 10.9 seems to have fixed any stuck scenarios.
return;
}
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")
);
}
})());