This commit is contained in:
Rudis Muiznieks 2023-09-25 14:44:28 -05:00
parent 2f412f50a6
commit aa5ceede6e
Signed by: rudism
GPG Key ID: CABF2F86EF7884F9
1 changed files with 5 additions and 24 deletions

View File

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