aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-webextension
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2022-04-28 15:55:20 -0300
committerSebastian <sebasjm@gmail.com>2022-04-28 15:55:20 -0300
commit508f5d2ea7a0c83eeb35bfae08a514c7e23fd884 (patch)
tree02b43d1769c93e35f601a0d97be69d4f8e304f77 /packages/taler-wallet-webextension
parentb239ae1029eef5a68bf98d21e81acd317abb0673 (diff)
simplify alarm and check webRequest without using 'in'
Diffstat (limited to 'packages/taler-wallet-webextension')
-rw-r--r--packages/taler-wallet-webextension/src/platform/chrome.ts24
1 files changed, 10 insertions, 14 deletions
diff --git a/packages/taler-wallet-webextension/src/platform/chrome.ts b/packages/taler-wallet-webextension/src/platform/chrome.ts
index 900470dff..e4ebfbae5 100644
--- a/packages/taler-wallet-webextension/src/platform/chrome.ts
+++ b/packages/taler-wallet-webextension/src/platform/chrome.ts
@@ -51,11 +51,11 @@ function keepAlive(callback: any): void {
chrome.alarms.onAlarm.addListener((a) => {
logger.trace(`kee p alive alarm: ${a.name}`)
- callback()
+ // callback()
})
- } else {
- callback();
+ // } else {
}
+ callback();
}
@@ -331,29 +331,25 @@ function registerTalerHeaderListener(callback: (tabId: number, url: string) => v
getPermissionsApi().containsHostPermissions().then(result => {
//if there is a handler already, remove it
if (
- "webRequest" in chrome &&
- "onHeadersReceived" in chrome.webRequest &&
prevHeaderListener &&
- chrome.webRequest.onHeadersReceived.hasListener(prevHeaderListener)
+ chrome?.webRequest?.onHeadersReceived?.hasListener(prevHeaderListener)
) {
chrome.webRequest.onHeadersReceived.removeListener(prevHeaderListener);
}
//if the result was positive, add the headerListener
if (result) {
- chrome.webRequest.onHeadersReceived.addListener(
+ chrome?.webRequest?.onHeadersReceived?.addListener(
headerListener,
{ urls: ["<all_urls>"] },
["responseHeaders"],
);
}
//notify the browser about this change, this operation is expensive
- if ("webRequest" in chrome) {
- chrome.webRequest.handlerBehaviorChanged(() => {
- if (chrome.runtime.lastError) {
- console.error(JSON.stringify(chrome.runtime.lastError));
- }
- });
- }
+ chrome?.webRequest?.handlerBehaviorChanged(() => {
+ if (chrome.runtime.lastError) {
+ console.error(JSON.stringify(chrome.runtime.lastError));
+ }
+ });
});
}