Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bf6c96a3b1 | ||
|
|
5a4896b5b4 |
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"manifest_version": 2,
|
"manifest_version": 2,
|
||||||
"name": "Slop Farmer",
|
"name": "Slop Farmer",
|
||||||
"version": "0.1",
|
"version": "0.3",
|
||||||
|
|
||||||
"author": "Jack Case",
|
"author": "Jack Case",
|
||||||
"description": "Crowd-source AI slop pages and domains",
|
"description": "Crowd-source AI slop pages and domains",
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
<title>Slop Farmer</title>
|
<title>Slop Farmer</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>Hello, world!</h1>
|
|
||||||
<form id="login-form">
|
<form id="login-form">
|
||||||
<label for="email" id="username">user:</label>
|
<label for="email" id="username">user:</label>
|
||||||
<input type="text" name="username" required />
|
<input type="text" name="username" required />
|
||||||
@@ -16,4 +15,5 @@
|
|||||||
<input type="password" name="password" required />
|
<input type="password" name="password" required />
|
||||||
<button id="login-button">login</button>
|
<button id="login-button">login</button>
|
||||||
</form>
|
</form>
|
||||||
|
<h2 style="visibility: collapse;" id="login-status">You're logged in.</h2>
|
||||||
</body>
|
</body>
|
||||||
@@ -69,12 +69,19 @@ function check_links(search_links) {
|
|||||||
async function message_listener(message) {
|
async function message_listener(message) {
|
||||||
// handle slop reports returned from the background script
|
// handle slop reports returned from the background script
|
||||||
if(message.type === "check_result") {
|
if(message.type === "check_result") {
|
||||||
console.log(message.url, message.result)
|
if (message.domain) {
|
||||||
const link = page_links.get(message.url)
|
const paths = page_links.getDomain(message.domain)
|
||||||
if ( message.result.slop_domain ) {
|
paths.forEach((search_link) => {
|
||||||
|
search_link.node.setAttribute("style", "color: red;")
|
||||||
|
search_link.result = message.result
|
||||||
|
})
|
||||||
|
} else if (message.url) {
|
||||||
|
const link = page_links.getUrl(message.url)
|
||||||
link.node.setAttribute("style", "color: red;")
|
link.node.setAttribute("style", "color: red;")
|
||||||
|
link.result = message.result
|
||||||
}
|
}
|
||||||
link.result = message.result
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,10 @@ let access_token
|
|||||||
|
|
||||||
const login_form = document.getElementById("login-form")
|
const login_form = document.getElementById("login-form")
|
||||||
if(login_form) {
|
if(login_form) {
|
||||||
|
const login_status = document.getElementById("login-status")
|
||||||
|
if (localStorage.getItem("accessToken")) {
|
||||||
|
login_status.setAttribute("style", "visibility: visible;")
|
||||||
|
}
|
||||||
login_form.addEventListener("submit", (event) => {event.preventDefault(); submit_login_form()})
|
login_form.addEventListener("submit", (event) => {event.preventDefault(); submit_login_form()})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,7 +152,8 @@ async function on_button_clicked_handler(tab) {
|
|||||||
const domain = tab_url.hostname
|
const domain = tab_url.hostname
|
||||||
const path = tab_url.pathname
|
const path = tab_url.pathname
|
||||||
|
|
||||||
insert_slop(domain, path)
|
await insert_slop(domain, path)
|
||||||
|
update_page_action_icon({frameId: 0, tabId: tab.id, url: tab.url})
|
||||||
}
|
}
|
||||||
|
|
||||||
async function update_page_action_icon(details) {
|
async function update_page_action_icon(details) {
|
||||||
@@ -198,7 +203,7 @@ async function message_listener(message, sender) {
|
|||||||
|
|
||||||
let remote_slop = await check_remote_slop(not_found_local)
|
let remote_slop = await check_remote_slop(not_found_local)
|
||||||
remote_slop.forEach((result) => {
|
remote_slop.forEach((result) => {
|
||||||
browser.tabs.sendMessage(tabid, { type: "check_result", url: result.url, result: result })
|
browser.tabs.sendMessage(tabid, { type: "check_result", domain: result.domain_name, result: result })
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -227,6 +232,8 @@ async function submit_login_form() {
|
|||||||
const body = await response.json()
|
const body = await response.json()
|
||||||
const token = body.access_token
|
const token = body.access_token
|
||||||
localStorage.setItem("accessToken", token)
|
localStorage.setItem("accessToken", token)
|
||||||
|
const status_el = document.getElementById("login-status")
|
||||||
|
status_el.setAttribute("style", "visibility: visible;")
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user