Spaces:
Running
Running
Ryan Christian D. Deniega commited on
Commit Β·
7ba7fea
1
Parent(s): 4cb413f
fix(extension): init() no longer exits when service worker returns undefined
Browse files- extension/content.js +6 -3
extension/content.js
CHANGED
|
@@ -394,12 +394,15 @@
|
|
| 394 |
// ββ Initialization ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 395 |
|
| 396 |
async function init() {
|
| 397 |
-
// Check autoScan setting before activating
|
|
|
|
| 398 |
const response = await new Promise(resolve => {
|
| 399 |
-
chrome.runtime.sendMessage({ type: 'GET_SETTINGS' },
|
|
|
|
|
|
|
| 400 |
}).catch(() => ({ autoScan: true }))
|
| 401 |
|
| 402 |
-
if (
|
| 403 |
|
| 404 |
// Process any posts already in the DOM
|
| 405 |
const existing = findPosts(document.body)
|
|
|
|
| 394 |
// ββ Initialization ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 395 |
|
| 396 |
async function init() {
|
| 397 |
+
// Check autoScan setting before activating.
|
| 398 |
+
// Default to true if the service worker hasn't responded yet (MV3 cold start).
|
| 399 |
const response = await new Promise(resolve => {
|
| 400 |
+
chrome.runtime.sendMessage({ type: 'GET_SETTINGS' }, (r) => {
|
| 401 |
+
resolve(r ?? { autoScan: true })
|
| 402 |
+
})
|
| 403 |
}).catch(() => ({ autoScan: true }))
|
| 404 |
|
| 405 |
+
if (response?.autoScan === false) return
|
| 406 |
|
| 407 |
// Process any posts already in the DOM
|
| 408 |
const existing = findPosts(document.body)
|