Old codes I do not remember but better commit them than loosing it 😬

This commit is contained in:
Serraniel 2020-07-29 10:03:25 +02:00
parent 677ef8d233
commit d522f7c96f
Signed by: Serraniel
GPG key ID: 3690B4E7364525D3
3 changed files with 28 additions and 16 deletions

View file

@ -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() {

View file

@ -18,7 +18,7 @@
},
{
"matches": [
"*://aniwatch.me/requests"
"*://aniwatch.me/*"
],
"js": [
"enhancements/animeRequests.js"

View file

@ -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').