Merge pull request #13 from Serraniel/feature/#9-core-make-scripts-only-run-on-url

Feature/#9 core make scripts only run on url
This commit is contained in:
Daniel 2020-07-29 12:16:46 +02:00 committed by GitHub
commit ce23bd835a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 4 deletions

View file

@ -5,7 +5,7 @@ registerScript(node => {
changeBorderColor(node);
removeUnknownUsers(node);
}
});
}, "/requests");
function changeFollowedStarColor(node) {
const starIcon = 'star';

View file

@ -1,11 +1,15 @@
let __scripts = [];
function registerScript(func) {
__scripts.push(func);
function registerScript(func, pattern = '.*') {
__scripts.push({ "function": func, "pattern": pattern });
}
function runScripts(node) {
__scripts.forEach(script => script(node));
__scripts.forEach(script => {
if (window.location.pathname.match(script.pattern)) {
script.function(node);
}
});
}
let observer = new MutationObserver(mutations => {