start on checking slop on search result pages
This commit is contained in:
@@ -17,6 +17,12 @@
|
|||||||
"show_matches": ["<all_urls>"]
|
"show_matches": ["<all_urls>"]
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"browser_action": {
|
||||||
|
"default_icon": "icons/virus-slash.png",
|
||||||
|
"default_title": "Slop Farmer",
|
||||||
|
"default_popup": "pages/action_popup.html"
|
||||||
|
},
|
||||||
|
|
||||||
"background": {
|
"background": {
|
||||||
"scripts": ["scripts/report-slop.js"],
|
"scripts": ["scripts/report-slop.js"],
|
||||||
"persistent": false,
|
"persistent": false,
|
||||||
|
|||||||
15
pages/action_popup.html
Normal file
15
pages/action_popup.html
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<!-- <meta name="viewport" content="width=device-width, initial-scale=1.0"> -->
|
||||||
|
<title>Slop Farmer</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Hello, world!</h1>
|
||||||
|
<form action="" method="post">
|
||||||
|
<label for="email">email:</label>
|
||||||
|
<input type="email" name="username" required />
|
||||||
|
<label for="password">password:</label>
|
||||||
|
<input type="password" name="password" required />
|
||||||
|
</form>
|
||||||
|
</body>
|
||||||
@@ -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)
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
const API_URL = ""
|
||||||
|
|
||||||
function setup_storage_db() {
|
function setup_storage_db() {
|
||||||
/* create indexeddb object store to retain objects in the form of
|
/* create indexeddb object store to retain objects in the form of
|
||||||
* {"domain": "domain.tld",
|
* {"domain": "domain.tld",
|
||||||
@@ -145,6 +147,18 @@ async function update_page_action_icon(details) {
|
|||||||
console.log(is_slop)
|
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.runtime.onInstalled.addListener(on_install_handler)
|
||||||
browser.pageAction.onClicked.addListener(on_button_clicked_handler)
|
browser.pageAction.onClicked.addListener(on_button_clicked_handler)
|
||||||
browser.webNavigation.onCommitted.addListener(update_page_action_icon)
|
browser.webNavigation.onCommitted.addListener(update_page_action_icon)
|
||||||
|
browser.runtime.onMessage.addListener(message_listener)
|
||||||
|
|||||||
Reference in New Issue
Block a user