background page will automatically do an altcha challenge to get an access token
This commit is contained in:
@@ -25,9 +25,7 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
"background": {
|
"background": {
|
||||||
"scripts": ["scripts/report-slop.js"],
|
"page": "pages/background_page.html"
|
||||||
"persistent": false,
|
|
||||||
"type": "module"
|
|
||||||
},
|
},
|
||||||
|
|
||||||
"content_scripts": [
|
"content_scripts": [
|
||||||
|
|||||||
13
pages/background_page.html
Normal file
13
pages/background_page.html
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<!-- <meta name="viewport" content="width=device-width, initial-scale=1.0"> -->
|
||||||
|
<script async src="scripts/report-slop.js" type="module"></script>
|
||||||
|
<script async defer src="https://cdn.jsdelivr.net/gh/altcha-org/altcha/dist/altcha.min.js" type="module"></script>
|
||||||
|
<title>Slop Farmer</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<form action="" method="post">
|
||||||
|
<altcha-widget challengeurl="SERVER_URL/challenge" auto="onload"></altcha-widget>
|
||||||
|
</form>
|
||||||
|
</body>
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
const API_URL = "http://localhost:8000"
|
const API_URL = "http://localhost:8000"
|
||||||
|
let access_token
|
||||||
|
|
||||||
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
|
||||||
@@ -186,7 +187,16 @@ async function message_listener(message, sender) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function get_access_token() {
|
||||||
|
access_token = localStorage.getItem("accessToken")
|
||||||
|
if (!access_token) {
|
||||||
|
// get an access token from the API
|
||||||
|
}
|
||||||
|
return access_token
|
||||||
|
}
|
||||||
|
|
||||||
browser.runtime.onInstalled.addListener(on_install_handler)
|
browser.runtime.onInstalled.addListener(on_install_handler)
|
||||||
|
browser.runtime.onStartup.addListener(get_access_token)
|
||||||
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)
|
browser.runtime.onMessage.addListener(message_listener)
|
||||||
|
|||||||
Reference in New Issue
Block a user