wip
This commit is contained in:
parent
2f412f50a6
commit
aa5ceede6e
|
@ -1,29 +1,10 @@
|
||||||
if (document.readyState && document.readyState !== 'loading') {
|
if (document.readyState && document.readyState !== 'loading') {
|
||||||
kagiSummarizeOnLoad();
|
configureSummarizeButtons();
|
||||||
} else {
|
} else {
|
||||||
document.addEventListener('DOMContentLoaded', kagiSummarizeOnLoad, false);
|
document.addEventListener('DOMContentLoaded', configureSummarizeButtons, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
function kagiSummarizeOnLoad() {
|
function configureSummarizeButtons() {
|
||||||
console.log('configuring kagi observer');
|
var buttons = document.querySelectorAll('.kagi-summary a.btn');
|
||||||
var observer = new MutationObserver(function(mutations) {
|
console.log(`configuring ${buttons.length} buttons`);
|
||||||
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
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue