We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8a4c236 commit 3030313Copy full SHA for 3030313
src/background/dynamic_content_scripts.ts
@@ -41,8 +41,18 @@ export async function unregisterContentScriptIfExists(
41
registrations = await browser.scripting.getRegisteredContentScripts({
42
ids: [dynamicContentScriptRegistrationId],
43
});
44
- } catch (error) {
45
- return true;
+ } catch (error: any) {
+ // Safari throws if the script id doesn't exist, so handle that gracefully
46
+ if (
47
+ error instanceof Error &&
48
+ error.message.match(
49
+ /Invalid call to scripting.getRegisteredContentScripts\(\)\. No script with ID '.*'/
50
+ )
51
+ ) {
52
+ return true;
53
+ } else {
54
+ throw error;
55
+ }
56
}
57
58
if (registrations.length === 0) {
0 commit comments