Merge pull request #1 from ouuan/firefox-api-permissions
Firefox api permissions
This commit is contained in:
@@ -38,6 +38,7 @@
|
|||||||
"chrome_style": false,
|
"chrome_style": false,
|
||||||
"page": "options.html"
|
"page": "options.html"
|
||||||
},
|
},
|
||||||
"permissions": ["alarms", "tabs", "storage", "activeTab"],
|
"permissions": ["alarms", "tabs", "storage", "activeTab", "https://api.wakatime.com/*", "https://wakatime.com/*"],
|
||||||
|
"optional_permissions": ["<all_urls>"],
|
||||||
"version": "4.0.12"
|
"version": "4.0.12"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,7 +81,12 @@ export const getSettings = async (): Promise<Settings> => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const saveSettings = async (settings: Settings): Promise<void> => {
|
export const saveSettings = async (settings: Settings): Promise<void> => {
|
||||||
return browser.storage.sync.set(settings);
|
// permissions.request must be the first await, not after the browser.storage.sync.set
|
||||||
|
// See https://stackoverflow.com/a/47729896/12601364
|
||||||
|
await browser.permissions.request({
|
||||||
|
origins: [`${settings.apiUrl}/*`],
|
||||||
|
});
|
||||||
|
await browser.storage.sync.set(settings);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getApiUrl = async () => {
|
export const getApiUrl = async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user