Make nativeMessaging an optional permission

This commit is contained in:
bytedream 2024-07-28 23:31:25 +02:00
parent 67c492db47
commit 84605ceb30
2 changed files with 9 additions and 4 deletions

View File

@ -17,8 +17,6 @@
let isMobile: boolean;
(async () => {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
isMobile = (await browser.runtime.getPlatformInfo()).os === 'android';
})();
@ -75,7 +73,13 @@
<Toggle
bind:checked={ff2mpvEnabled}
id="ff2mpv"
on:change={async () => Other.setFf2mpv(ff2mpvEnabled)}
on:change={async () => {
ff2mpvEnabled = !ff2mpvEnabled;
if (await browser.permissions.request({ permissions: ['nativeMessaging'] })) {
await Other.setFf2mpv(ff2mpvEnabled);
ff2mpvEnabled = !ff2mpvEnabled;
}
}}
></Toggle>
<a
class="info-questionmark"

View File

@ -22,7 +22,8 @@ const sharedManifest: Partial<chrome.runtime.ManifestBase> = {
96: 'icons/stream-bypass@96px.png',
128: 'icons/stream-bypass@128px.png'
},
permissions: ['storage', 'nativeMessaging']
permissions: ['storage'],
optional_permissions: ['nativeMessaging']
};
const browserAction = {