diff options
author | Ajay <[email protected]> | 2022-08-16 16:00:34 -0400 |
---|---|---|
committer | Ajay <[email protected]> | 2022-08-16 16:00:34 -0400 |
commit | faeb5dede016f25710bc79b6b3fcdcd82f37e45b (patch) | |
tree | fce4d08609ce002636104ad9f96be878c2ef2423 /src/utils.ts | |
parent | eae8485713f54d09a77004c1362cbafc69d9b7e9 (diff) | |
download | SponsorBlock-faeb5dede016f25710bc79b6b3fcdcd82f37e45b.tar.gz SponsorBlock-faeb5dede016f25710bc79b6b3fcdcd82f37e45b.zip |
Add page for refreshing invidious permissions if it was revoked
Fixes #1354
Diffstat (limited to 'src/utils.ts')
-rw-r--r-- | src/utils.ts | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/utils.ts b/src/utils.ts index fbfbbda7..ae390d78 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -210,6 +210,37 @@ export default class Utils { }); } + applyInvidiousPermissions(enable: boolean, option = "supportInvidious"): Promise<boolean> { + return new Promise((resolve) => { + if (enable) { + this.setupExtraSitePermissions((granted) => { + if (!granted) { + Config.config[option] = false; + } + + resolve(granted); + }); + } else { + this.removeExtraSiteRegistration(); + resolve(false); + } + }); + } + + containsInvidiousPermission(): Promise<boolean> { + return new Promise((resolve) => { + let permissions = ["declarativeContent"]; + if (this.isFirefox()) permissions = []; + + chrome.permissions.contains({ + origins: this.getPermissionRegex(), + permissions: permissions + }, function (result) { + resolve(result); + }); + }) + } + /** * Merges any overlapping timestamp ranges into single segments and returns them as a new array. */ |