@@ -54,6 +54,7 @@ const canceledRequests = {};
54
54
const tabsWaitingToLoad = { } ;
55
55
const googleHostREs = [ ] ;
56
56
const youtubeHostREs = [ ] ;
57
+ const searchpagePathREs = [ ] ;
57
58
58
59
async function isMACAddonEnabled ( ) {
59
60
try {
@@ -156,6 +157,9 @@ function generateGoogleHostREs () {
156
157
for ( let youtubeDomain of YOUTUBE_DOMAINS ) {
157
158
youtubeHostREs . push ( new RegExp ( `^(.*\\.)?${ youtubeDomain } $` ) ) ;
158
159
}
160
+ for ( let searchpagePath of SEARCHPAGE_PATHS ) {
161
+ searchpagePathREs . push ( new RegExp ( `^${ searchpagePath } (.*)` ) ) ;
162
+ }
159
163
}
160
164
161
165
async function loadExtensionSettings ( ) {
@@ -241,25 +245,27 @@ function isGoogleURL (url) {
241
245
const parsedUrl = new URL ( url ) ;
242
246
for ( let googleHostRE of googleHostREs ) {
243
247
if ( googleHostRE . test ( parsedUrl . host ) ) {
248
+ return true ;
249
+ }
250
+ }
251
+ return false ;
252
+ }
253
+
254
+ function isYouTubeURL ( url ) {
255
+ const parsedUrl = new URL ( url ) ;
256
+ for ( let youtubeHostRE of youtubeHostREs ) {
257
+ if ( youtubeHostRE . test ( parsedUrl . host ) ) {
258
+ return true ;
259
+ }
260
+ }
261
+ return false ;
262
+ }
244
263
245
- // Ignore nothing when all ignore-settings are disabled
246
- if ( ! extensionSettings . ignore_searchpages && ! extensionSettings . ignore_youtube ) {
247
- return true ;
248
- }
249
-
250
- // Ignore YouTube host when setting is enabled and host matches
251
- if ( extensionSettings . ignore_youtube ) {
252
- for ( let youtubeHostRE of youtubeHostREs ) {
253
- if ( youtubeHostRE . test ( parsedUrl . host ) ) {
254
- return false ;
255
- }
256
- }
257
- }
258
-
259
- // Ignore search page when setting is enabled and path matches
260
- if ( extensionSettings . ignore_searchpages && ! SEARCHPAGE_PATHS . includes ( parsedUrl . pathname ) ) {
261
- return true ;
262
- }
264
+ function isSearchPageURL ( url ) {
265
+ const parsedUrl = new URL ( url ) ;
266
+ for ( let searchpagePathRE of searchpagePathREs ) {
267
+ if ( searchpagePathRE . test ( parsedUrl . pathname ) ) {
268
+ return true ;
263
269
}
264
270
}
265
271
return false ;
@@ -271,7 +277,17 @@ function shouldContainInto (url, tab) {
271
277
return false ;
272
278
}
273
279
274
- if ( isGoogleURL ( url ) ) {
280
+ let handleUrl = isGoogleURL ( url ) ;
281
+
282
+ if ( extensionSettings . ignore_youtube && isYouTubeURL ( url ) ) {
283
+ handleUrl = false ;
284
+ }
285
+
286
+ if ( extensionSettings . ignore_searchpages && isSearchPageURL ( url ) ) {
287
+ handleUrl = false ;
288
+ }
289
+
290
+ if ( handleUrl ) {
275
291
if ( tab . cookieStoreId !== googleCookieStoreId ) {
276
292
// Google-URL outside of Google Container Tab
277
293
// Should contain into Google Container
0 commit comments