remove clipboardRead permission & pretty
This commit is contained in:
parent
9ac1c902c0
commit
f1962dceb3
@ -24,8 +24,7 @@
|
||||
"optional_permissions": [
|
||||
"http://*/*",
|
||||
"https://*/*",
|
||||
"webRequest",
|
||||
"clipboardRead"
|
||||
"webRequest"
|
||||
],
|
||||
"browser_action": {
|
||||
"default_icon": {
|
||||
|
@ -27,8 +27,7 @@
|
||||
}
|
||||
},
|
||||
"optional_permissions": [
|
||||
"webRequest",
|
||||
"clipboardRead"
|
||||
"webRequest"
|
||||
],
|
||||
"host_permissions": [
|
||||
"http://*/*",
|
||||
|
@ -83,13 +83,14 @@ const hostPermissions = {
|
||||
|
||||
export function containsClipboardPermissions(): Promise<boolean> {
|
||||
return new Promise((res, rej) => {
|
||||
chrome.permissions.contains({ permissions: ["clipboardRead"] }, (resp) => {
|
||||
const le = chrome.runtime.lastError?.message;
|
||||
if (le) {
|
||||
rej(le);
|
||||
}
|
||||
res(resp);
|
||||
});
|
||||
res(false);
|
||||
// chrome.permissions.contains({ permissions: ["clipboardRead"] }, (resp) => {
|
||||
// const le = chrome.runtime.lastError?.message;
|
||||
// if (le) {
|
||||
// rej(le);
|
||||
// }
|
||||
// res(resp);
|
||||
// });
|
||||
});
|
||||
}
|
||||
|
||||
@ -107,13 +108,14 @@ export function containsHostPermissions(): Promise<boolean> {
|
||||
|
||||
export async function requestClipboardPermissions(): Promise<boolean> {
|
||||
return new Promise((res, rej) => {
|
||||
chrome.permissions.request({ permissions: ["clipboardRead"] }, (resp) => {
|
||||
const le = chrome.runtime.lastError?.message;
|
||||
if (le) {
|
||||
rej(le);
|
||||
}
|
||||
res(resp);
|
||||
});
|
||||
res(false);
|
||||
// chrome.permissions.request({ permissions: ["clipboardRead"] }, (resp) => {
|
||||
// const le = chrome.runtime.lastError?.message;
|
||||
// if (le) {
|
||||
// rej(le);
|
||||
// }
|
||||
// res(resp);
|
||||
// });
|
||||
});
|
||||
}
|
||||
|
||||
@ -187,13 +189,14 @@ export async function removeHostPermissions(): Promise<boolean> {
|
||||
|
||||
export function removeClipboardPermissions(): Promise<boolean> {
|
||||
return new Promise((res, rej) => {
|
||||
chrome.permissions.remove({ permissions: ["clipboardRead"] }, (resp) => {
|
||||
const le = chrome.runtime.lastError?.message;
|
||||
if (le) {
|
||||
rej(le);
|
||||
}
|
||||
res(resp);
|
||||
});
|
||||
res(true);
|
||||
// chrome.permissions.remove({ permissions: ["clipboardRead"] }, (resp) => {
|
||||
// const le = chrome.runtime.lastError?.message;
|
||||
// if (le) {
|
||||
// rej(le);
|
||||
// }
|
||||
// res(resp);
|
||||
// });
|
||||
});
|
||||
}
|
||||
|
||||
@ -775,21 +778,23 @@ async function timeout(ms: number): Promise<void> {
|
||||
return new Promise((resolve) => setTimeout(resolve, ms));
|
||||
}
|
||||
async function findTalerUriInClipboard(): Promise<string | undefined> {
|
||||
try {
|
||||
//It looks like clipboard promise does not return, so we need a timeout
|
||||
const textInClipboard = await Promise.any([
|
||||
timeout(100),
|
||||
window.navigator.clipboard.readText(),
|
||||
]);
|
||||
if (!textInClipboard) return;
|
||||
return textInClipboard.startsWith("taler://") ||
|
||||
textInClipboard.startsWith("taler+http://")
|
||||
? textInClipboard
|
||||
: undefined;
|
||||
} catch (e) {
|
||||
logger.error("could not read clipboard", e);
|
||||
return undefined;
|
||||
}
|
||||
//FIXME: add clipboard feature
|
||||
// try {
|
||||
// //It looks like clipboard promise does not return, so we need a timeout
|
||||
// const textInClipboard = await Promise.any([
|
||||
// timeout(100),
|
||||
// window.navigator.clipboard.readText(),
|
||||
// ]);
|
||||
// if (!textInClipboard) return;
|
||||
// return textInClipboard.startsWith("taler://") ||
|
||||
// textInClipboard.startsWith("taler+http://")
|
||||
// ? textInClipboard
|
||||
// : undefined;
|
||||
// } catch (e) {
|
||||
// logger.error("could not read clipboard", e);
|
||||
// return undefined;
|
||||
// }
|
||||
return undefined;
|
||||
}
|
||||
|
||||
async function findTalerUriInActiveTab(): Promise<string | undefined> {
|
||||
|
@ -115,12 +115,12 @@ export function SettingsView({
|
||||
error={autoOpenToggle.button.error.errorDetail}
|
||||
/>
|
||||
)}
|
||||
{clipboardToggle.button.error && (
|
||||
{/* {clipboardToggle.button.error && (
|
||||
<ErrorTalerOperation
|
||||
title={<i18n.Translate>Could not toggle clipboard</i18n.Translate>}
|
||||
error={clipboardToggle.button.error.errorDetail}
|
||||
/>
|
||||
)}
|
||||
)} */}
|
||||
<SubTitle>
|
||||
<i18n.Translate>Navigator</i18n.Translate>
|
||||
</SubTitle>
|
||||
@ -140,7 +140,7 @@ export function SettingsView({
|
||||
enabled={autoOpenToggle.value!}
|
||||
onToggle={autoOpenToggle.button.onClick!}
|
||||
/>
|
||||
<Checkbox
|
||||
{/* <Checkbox
|
||||
label={
|
||||
<i18n.Translate>
|
||||
Automatically check clipboard for Taler URI
|
||||
@ -155,7 +155,7 @@ export function SettingsView({
|
||||
}
|
||||
enabled={clipboardToggle.value!}
|
||||
onToggle={clipboardToggle.button.onClick!}
|
||||
/>
|
||||
/> */}
|
||||
|
||||
<SubTitle>
|
||||
<i18n.Translate>Trust</i18n.Translate>
|
||||
|
@ -58,9 +58,9 @@ export interface BackgroundOperations {
|
||||
response: void;
|
||||
};
|
||||
sum: {
|
||||
request: number[],
|
||||
response: number,
|
||||
}
|
||||
request: number[];
|
||||
response: number;
|
||||
};
|
||||
resetDb: {
|
||||
request: void;
|
||||
response: void;
|
||||
|
@ -164,12 +164,12 @@ async function toggleHeaderListener(
|
||||
|
||||
function freeze(time: number): Promise<void> {
|
||||
return new Promise((res, rej) => {
|
||||
setTimeout(res, time)
|
||||
})
|
||||
setTimeout(res, time);
|
||||
});
|
||||
}
|
||||
|
||||
async function sum(ns: Array<number>): Promise<number> {
|
||||
return ns.reduce((prev, cur) => prev + cur, 0)
|
||||
return ns.reduce((prev, cur) => prev + cur, 0);
|
||||
}
|
||||
|
||||
const backendHandlers: BackendHandlerType = {
|
||||
|
Loading…
Reference in New Issue
Block a user