@@ -55,6 +55,7 @@ const googleHostREs = [];
5555const youtubeHostREs = [ ] ;
5656const whitelistedHostREs = [ ] ;
5757const allowlistedHostREs = [ ] ;
58+ const softAllowlistedHostREs = [ ] ;
5859
5960async function isMACAddonEnabled ( ) {
6061 try {
@@ -181,6 +182,15 @@ function generateAllowlistedHostREs () {
181182 }
182183}
183184
185+ function generateSoftAllowlistedHostREs ( ) {
186+ if ( softAllowlistedHostREs . length != 0 ) { return ; }
187+ const matchOperatorsRegex = / [ | \\ { } ( ) [ \] ^ $ + * ? . - ] / g;
188+ for ( let allowlistedDomain of extensionSettings . soft_allowlist ) {
189+ allowlistedDomain = allowlistedDomain . replace ( matchOperatorsRegex , '\\$&' ) ;
190+ softAllowlistedHostREs . push ( new RegExp ( `(^|\\.)${ allowlistedDomain } $` ) ) ;
191+ }
192+ }
193+
184194async function loadExtensionSettings ( ) {
185195 extensionSettings = await browser . storage . sync . get ( ) ;
186196 if ( extensionSettings . whitelist === undefined ) {
@@ -189,6 +199,9 @@ async function loadExtensionSettings () {
189199 if ( extensionSettings . allowlist === undefined ) {
190200 extensionSettings . allowlist = "" ;
191201 }
202+ if ( extensionSettings . soft_allowlist === undefined ) {
203+ ▸ extensionSettings . soft_allowlist = "" ;
204+ }
192205}
193206
194207async function clearGoogleCookies ( ) {
@@ -312,6 +325,18 @@ function isAllowlistedURL (url) {
312325 return false ;
313326}
314327
328+ function isSoftAllowlistedURL ( url ) {
329+ generateSoftAllowlistedHostREs ( ) ;
330+ const parsedUrl = new URL ( url ) ;
331+ for ( let allowlistedHostRE of softAllowlistedHostREs ) {
332+ if ( allowlistedHostRE . test ( parsedUrl . hostname ) ) {
333+ return true ;
334+ }
335+ }
336+ return false ;
337+ }
338+
339+
315340function isSearchPageURL ( url ) {
316341 const parsedUrl = new URL ( url ) ;
317342 return parsedUrl . pathname . startsWith ( '/search' ) ;
@@ -344,7 +369,8 @@ function shouldContainInto (url, tab) {
344369 }
345370
346371 let allowlistUrl = ( extensionSettings . allowlist . length != 0 && isAllowlistedURL ( url ) ) ;
347- let handleUrl = isGoogleURL ( url ) || allowlistUrl ;
372+ let softAllowlistUrl = ( extensionSettings . soft_allowlist . length != 0 && isSoftAllowlistedURL ( url ) ) ;
373+ let handleUrl = isGoogleURL ( url ) || allowlistUrl || softAllowlistUrl ;
348374
349375 if ( handleUrl && extensionSettings . whitelist . length != 0 && isWhitelistedURL ( url ) ) {
350376 handleUrl = false ;
@@ -381,8 +407,8 @@ function shouldContainInto (url, tab) {
381407 return false ;
382408 }
383409
384- if ( allowlistUrl ) {
385- // Don't force an allowlisted URL to be in the Google Container
410+ if ( softAllowlistUrl ) {
411+ // Don't force an soft- allowlisted URL to be in the Google Container
386412 return false ;
387413 }
388414
0 commit comments