@@ -17,6 +17,10 @@ function makePathRelative(file: string): string {
17
17
async function registerOnOrigins ( {
18
18
origins : newOrigins ,
19
19
} : chrome . permissions . Permissions ) : Promise < void > {
20
+ if ( ! newOrigins ?. length ) {
21
+ return ;
22
+ }
23
+
20
24
const { content_scripts : rawManifest , manifest_version : manifestVersion } = chrome . runtime . getManifest ( ) ;
21
25
22
26
if ( ! rawManifest ) {
@@ -26,7 +30,7 @@ async function registerOnOrigins({
26
30
const cleanManifest = excludeDuplicateFiles ( rawManifest , { warn : manifestVersion === 2 } ) ;
27
31
28
32
// Register one at a time to allow removing one at a time as well
29
- for ( const origin of newOrigins || [ ] ) {
33
+ for ( const origin of newOrigins ) {
30
34
for ( const config of cleanManifest ) {
31
35
const registeredScript = registerContentScript ( {
32
36
// Always convert paths here because we don't know whether Firefox MV3 will accept full URLs
@@ -43,17 +47,15 @@ async function registerOnOrigins({
43
47
44
48
// May not be needed in the future in Firefox
45
49
// https://bugzilla.mozilla.org/show_bug.cgi?id=1458947
46
- void injectToExistingTabs ( newOrigins || [ ] , cleanManifest ) ;
50
+ void injectToExistingTabs ( newOrigins , cleanManifest ) ;
47
51
}
48
52
49
53
function handleNewPermissions ( permissions : chrome . permissions . Permissions ) {
50
- if ( permissions . origins && permissions . origins . length > 0 ) {
51
- void registerOnOrigins ( permissions ) ;
52
- }
54
+ void registerOnOrigins ( permissions ) ;
53
55
}
54
56
55
57
async function handledDroppedPermissions ( { origins} : chrome . permissions . Permissions ) {
56
- if ( ! origins || origins . length === 0 ) {
58
+ if ( ! origins ? .length ) {
57
59
return ;
58
60
}
59
61
0 commit comments