Skip to content

Commit 02f3565

Browse files
committed
fix permission requesting inside extension
1 parent 2b2e7e7 commit 02f3565

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

config-tab.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export async function initializeConfigTab() {
2323
const statusText = document.getElementById('serverStatusText');
2424

2525
// check if we have permission to access the server
26-
const permission = await chrome.permissions.request({origins: [`${serverUrl.value}/*`]});
26+
const permission = await chrome.permissions.request({permissions: ['host_permissions'], origins: [`${serverUrl.value}/*`]});
2727
if (!permission) {
2828
alert('Permission denied.');
2929
return;

options.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ <h5 class="modal-title">Edit Tags</h5>
211211
⚙️ ADMIN UI
212212
</button>
213213
<button type="button" id="testServer" class="btn btn-outline-secondary">
214-
TEST SERVER
214+
SAVE
215215
<span class="status-indicator" id="serverStatus"></span>
216216
</button>
217217
</div>
@@ -232,7 +232,7 @@ <h5 class="modal-title">Edit Tags</h5>
232232
🔑 GENERATE
233233
</button>
234234
<button type="button" id="testApiKey" class="btn btn-outline-secondary">
235-
TEST API KEY
235+
SAVE
236236
<span class="status-indicator" id="apiKeyStatus"></span>
237237
</button>
238238
</div>

utils.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,6 @@ export function filterEntries(entries, filterText) {
1818
}
1919

2020
export async function addToArchiveBox(addCommandArgs, onComplete, onError) {
21-
// request permission to POST to the ArchiveBox server, upgrade optional_host_permissions
22-
// const permission = await chrome.permissions.request({permissions: [archivebox_server_url, 'host_permissions']});
23-
const permission = await chrome.permissions.request({origins: [`${archivebox_server_url}/*`]});
24-
if (!permission) {
25-
onError({ok: false, errorMessage: 'Permission denied.'});
26-
return;
27-
}
28-
2921
try {
3022
const { archivebox_server_url, archivebox_api_key } = await new Promise((resolve, reject) => {
3123
const vals = chrome.storage.local.get([
@@ -44,6 +36,14 @@ export async function addToArchiveBox(addCommandArgs, onComplete, onError) {
4436
throw new Error('Server not configured.');
4537
}
4638

39+
// request permission to POST to the ArchiveBox server, upgrade optional_host_permissions
40+
// const permission = await chrome.permissions.request({permissions: [archivebox_server_url, 'host_permissions']});
41+
const permission = await chrome.permissions.request({origins: [`${archivebox_server_url}/*`]});
42+
if (!permission) {
43+
onError({ok: false, errorMessage: 'Permission denied.'});
44+
return;
45+
}
46+
4747
let response = undefined;
4848
// try ArchiveBox v0.8.0+ API endpoint first
4949
if (archivebox_api_key) {

0 commit comments

Comments
 (0)