From bbecb5884fd6945c2e5d277b9f0fe961551b1cb2 Mon Sep 17 00:00:00 2001 From: Serraniel Date: Wed, 29 Jul 2020 12:12:16 +0200 Subject: [PATCH 1/2] #9 Added pattern parameter when registering scripts --- utils/aniwatchCore.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/utils/aniwatchCore.js b/utils/aniwatchCore.js index e274d01..fb7587a 100644 --- a/utils/aniwatchCore.js +++ b/utils/aniwatchCore.js @@ -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 => { -- 2.43.5 From 7b61cf09b1e7b75925aa0c984bb5a20ce688dd01 Mon Sep 17 00:00:00 2001 From: Serraniel Date: Wed, 29 Jul 2020 12:14:25 +0200 Subject: [PATCH 2/2] #9 added Pattern for requests script --- enhancements/animeRequests.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/enhancements/animeRequests.js b/enhancements/animeRequests.js index f03e7ea..f4f6fbd 100644 --- a/enhancements/animeRequests.js +++ b/enhancements/animeRequests.js @@ -5,7 +5,7 @@ registerScript(node => { changeBorderColor(node); removeUnknownUsers(node); } -}); +}, "/requests"); function changeFollowedStarColor(node) { const starIcon = 'star'; -- 2.43.5