add some helpful comments

This commit is contained in:
Jack Case
2025-10-22 14:20:11 +00:00
parent 554f1082f9
commit d730c46d8b

View File

@@ -21,6 +21,7 @@ function check_links(links) {
}
async function message_listener(message) {
// handle slop reports returned from the background script
if(message.type === "check_result") {
console.log(message.url, message.result)
page_links.get(message.url).result = message.result
@@ -28,7 +29,7 @@ async function message_listener(message) {
}
function get_initial_links() {
//get links
// get links from initial page load
const links = document.querySelectorAll(ddg_result_selector)
links.forEach((node) => {
const link = new SearchLink(node)
@@ -54,21 +55,24 @@ function update_links() {
}
function setup_result_observer() {
// observe changes in the result list to respond to newly loaded results
const config = { childList: true }
result_list_observer = new MutationObserver(update_links)
result_list_observer.observe(result_list_node, config)
}
function onload_handler() {
// get results ol node
// get results ol node to observe
result_list_node = document.querySelector(ddg_result_list_selector)
get_initial_links()
setup_result_observer()
}
// listen for messages from the background script
browser.runtime.onMessage.addListener(message_listener)
// initialize state on document load
if (document.readyState === "loading") {
document.addEventListener("DOMContentLoaded", onload_handler)
} else {