Old codes I do not remember but better commit them than loosing it 😬
This commit is contained in:
parent
677ef8d233
commit
d522f7c96f
|
@ -1,21 +1,16 @@
|
|||
const starIcon = "star";
|
||||
const scripts = [
|
||||
changeFollowedStarColor,
|
||||
changeOwnBorderColor,
|
||||
]
|
||||
|
||||
executeAfterPreload(initScripts);
|
||||
|
||||
function initScripts() {
|
||||
registerScript(() => {
|
||||
// run the scripts
|
||||
runScripts();
|
||||
handleListAfterLoad();
|
||||
|
||||
// because of late loading in the request list we have to run the codes each time the list changes
|
||||
document.querySelector("md-list").addEventListener("DOMNodeInserted", event => runScripts(event), false);
|
||||
}
|
||||
//document.querySelector("md-list").addEventListener("DOMNodeInserted", event => handleListAfterLoad(event), false);
|
||||
});
|
||||
|
||||
function runScripts() {
|
||||
scripts.forEach(script => script());
|
||||
function handleListAfterLoad() {
|
||||
changeFollowedStarColor();
|
||||
changeOwnBorderColor();
|
||||
}
|
||||
|
||||
function changeFollowedStarColor() {
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
},
|
||||
{
|
||||
"matches": [
|
||||
"*://aniwatch.me/requests"
|
||||
"*://aniwatch.me/*"
|
||||
],
|
||||
"js": [
|
||||
"enhancements/animeRequests.js"
|
||||
|
|
|
@ -1,10 +1,27 @@
|
|||
function executeAfterPreload(func){
|
||||
let __scripts = [];
|
||||
|
||||
function registerScript(func){
|
||||
__scripts.push(func);
|
||||
}
|
||||
|
||||
function runScripts(){
|
||||
console.log("RUN");
|
||||
__scripts.forEach(script => script());
|
||||
}
|
||||
|
||||
function awaitPageLoaded(){
|
||||
let preLoader = document.getElementById('preloader');
|
||||
|
||||
let loop = setInterval(() => {
|
||||
if(preLoader.style.display==="none"){
|
||||
clearInterval(loop);
|
||||
func();
|
||||
runScripts();
|
||||
}
|
||||
}, 100);
|
||||
}
|
||||
}
|
||||
|
||||
// RUN AT INITIALIZATION
|
||||
window.addEventListener("hashchange", event => runScripts(), false);
|
||||
document.addEventListener("DOMContentLoaded", event => awaitPageLoaded(), false);
|
||||
|
||||
document.querySelector('.main-section').
|
Loading…
Reference in a new issue