add permission check to formRead

This commit is contained in:
siikamiika 2020-01-26 04:16:02 +02:00
parent 90a5d79570
commit 91682dd633

View File

@ -28,7 +28,22 @@ function getOptionsFullMutable() {
async function formRead(options) {
options.general.enable = $('#enable').prop('checked');
options.general.enableClipboardPopups = $('#enable-clipboard-popups').prop('checked');
const enableClipboardPopups = $('#enable-clipboard-popups').prop('checked');
if (enableClipboardPopups) {
options.general.enableClipboardPopups = await new Promise((resolve, _reject) => {
chrome.permissions.request(
{permissions: ['clipboardRead']},
(granted) => {
if (!granted) {
$('#enable-clipboard-popups').prop('checked', false);
}
resolve(granted);
}
);
});
} else {
options.general.enableClipboardPopups = false;
}
options.general.showGuide = $('#show-usage-guide').prop('checked');
options.general.compactTags = $('#compact-tags').prop('checked');
options.general.compactGlossaries = $('#compact-glossaries').prop('checked');