From aa5ceede6e3a8ddcce17a8d703c6b1c593ae55c4 Mon Sep 17 00:00:00 2001 From: Rudis Muiznieks Date: Mon, 25 Sep 2023 14:44:28 -0500 Subject: [PATCH] wip --- static/script.js | 29 +++++------------------------ 1 file changed, 5 insertions(+), 24 deletions(-) diff --git a/static/script.js b/static/script.js index 84eee62..33f1802 100644 --- a/static/script.js +++ b/static/script.js @@ -1,29 +1,10 @@ if (document.readyState && document.readyState !== 'loading') { - kagiSummarizeOnLoad(); + configureSummarizeButtons(); } else { - document.addEventListener('DOMContentLoaded', kagiSummarizeOnLoad, false); + document.addEventListener('DOMContentLoaded', configureSummarizeButtons, false); } -function kagiSummarizeOnLoad() { - console.log('configuring kagi observer'); - var observer = new MutationObserver(function(mutations) { - console.log('kagi observer triggered'); - mutations.forEach(function(mutation) { - if (mutation.addedNodes && mutation.addedNodes.length > 0) { - console.log(mutation.addedNodes); - var hasClass = [].some.call(mutation.addedNodes, function(el) { - return el.classList.contains('kagi-summary'); - }); - if (hasClass) { - console.log('observer found kagi class'); - } - } - }); - }); - - observer.observe(document.body, { - attributes: true, - childList: true, - characterData: true - }); +function configureSummarizeButtons() { + var buttons = document.querySelectorAll('.kagi-summary a.btn'); + console.log(`configuring ${buttons.length} buttons`); }