diff --git a/manifest.json b/manifest.json index 0488e1e..36e1f1f 100644 --- a/manifest.json +++ b/manifest.json @@ -17,6 +17,12 @@ "show_matches": [""] }, + "browser_action": { + "default_icon": "icons/virus-slash.png", + "default_title": "Slop Farmer", + "default_popup": "pages/action_popup.html" + }, + "background": { "scripts": ["scripts/report-slop.js"], "persistent": false, diff --git a/pages/action_popup.html b/pages/action_popup.html new file mode 100644 index 0000000..07cfa38 --- /dev/null +++ b/pages/action_popup.html @@ -0,0 +1,15 @@ + + + + + Slop Farmer + + +

Hello, world!

+
+ + + + +
+ \ No newline at end of file diff --git a/scripts/hide-slop.js b/scripts/hide-slop.js index e69de29..a3d24a1 100644 --- a/scripts/hide-slop.js +++ b/scripts/hide-slop.js @@ -0,0 +1,12 @@ +function check_links(links) { + // send a message to background script with a list of URLs to check + browser.runtime.sendMessage({type: "check", urls: links}) +} + +async function message_listener(message) { + if(message.type === "check_result") { + console.log(message.url, message.result) + } +} + +browser.runtime.onMessage.addListener(message_listener) \ No newline at end of file diff --git a/scripts/report-slop.js b/scripts/report-slop.js index eb086d0..10cea55 100644 --- a/scripts/report-slop.js +++ b/scripts/report-slop.js @@ -1,3 +1,5 @@ +const API_URL = "" + function setup_storage_db() { /* create indexeddb object store to retain objects in the form of * {"domain": "domain.tld", @@ -145,6 +147,18 @@ async function update_page_action_icon(details) { console.log(is_slop) } +async function message_listener(message) { + if(message.type === "check") { + let check_promises = new Array() + message.urls.foreach((url) => { + check_promises.push(check_slop(url).then((result) => { + browser.tabs.sendMessage({type: "check_result", url: url, result: result}) + })) + }) + } +} + browser.runtime.onInstalled.addListener(on_install_handler) browser.pageAction.onClicked.addListener(on_button_clicked_handler) browser.webNavigation.onCommitted.addListener(update_page_action_icon) +browser.runtime.onMessage.addListener(message_listener)