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`); }