wip
This commit is contained in:
parent
2f412f50a6
commit
aa5ceede6e
|
@ -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`);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue