2
2
const GOOGLE_CONTAINER_NAME = "Google" ;
3
3
const GOOGLE_CONTAINER_COLOR = "red" ;
4
4
const GOOGLE_CONTAINER_ICON = "briefcase" ;
5
+
5
6
let GOOGLE_DOMAINS = [
6
7
"google.com" , "google.org" , "googleapis.com" , "g.co" , "ggpht.com" ,
7
8
"blogger.com" , "googleblog.com" , "blog.google" , "googleusercontent.com" , "googlesource.com" ,
8
- "google.org" , "google.net" , "466453.com" , "gooogle.com" , "gogle.com" , "ggoogle.com" , "gogole.com" , "goolge.com" , "googel.com" , "googlee.com" , "googil.com" , "googlr.com" , "elgoog.im" , "ai.google" , "com.google" ,
9
+ "google.org" , "google.net" , "466453.com" , "gooogle.com" , "gogle.com" , "ggoogle.com" , "gogole.com" , "goolge.com" , "googel.com" , "googlee.com" , "googil.com" , "googlr.com" , "elgoog.im" , "ai.google" , "com.google" ,
9
10
] ;
10
11
11
12
const GOOGLE_INTL_DOMAINS = [
@@ -15,35 +16,31 @@ const GOOGLE_INTL_DOMAINS = [
15
16
const GOOGLE_SERVICES = [
16
17
"like.com" , "keyhole.com" , "panoramio.com" , "picasa.com" , "urchin.com" , "igoogle.com" , "foofle.com" , "froogle.com" , "localguidesconnect.com" , "googlemail.com" , "googleanalytics.com" , "google-analytics.com" , "googletagmanager.com" , "googlecode.com" , "googlesource.com" , "googledrive.com" , "googlearth.com" , "googleearth.com" , "googlemaps.com" , "googlepagecreator.com" , "googlescholar.com" , "advertisercommunity.com" , "thinkwithgoogle.com" ,
17
18
] ;
19
+
18
20
const YOUTUBE_DOMAINS = [
19
- "youtube.com" , "youtu.be" , "yt.be" , "ytimg.com" , " youtube-nocookie.com" , "youtubegaming.com" , "youtubeeducation.com" , "youtube-nocookie .com",
21
+ "youtube.com" , "youtu.be" , "yt.be" , "ytimg.com" , "youtube-nocookie.com" , "youtubegaming.com" , "youtubeeducation.com" ,
20
22
] ;
23
+
21
24
const BLOGSPOT_DOMAINS = [ "blogspot.com" , "blogspot.ae" , "blogspot.al" , "blogspot.am" , "blogspot.com.ar" , "blogspot.co.at" , "blogspot.com.au" , "blogspot.ba" , "blogspot.be" , "blogspot.bg" , "blogspot.bj" , "blogspot.com.br" , "blogspot.com.by" , "blogspot.ca" , "blogspot.cf" , "blogspot.ch" , "blogspot.cl" , "blogspot.com.co" , "blogspot.cv" , "blogspot.com.cy" , "blogspot.cz" , "blogspot.de" , "blogspot.dj" , "blogspot.dk" , "blogspot.dm" , "blogspot.com.do" , "blogspot.dz" , "blogspot.com.eg" , "blogspot.es" , "blogspot.fi" , "blogspot.fr" , "blogspot.gr" , "blogspot.hr" , "blogspot.hu" , "blogspot.co.id" , "blogspot.ie" , "blogspot.co.il" , "blogspot.in" , "blogspot.is" , "blogspot.it" , "blogspot.jp" , "blogspot.co.ke" , "blogspot.kr" , "blogspot.li" , "blogspot.lt" , "blogspot.lu" , "blogspot.md" , "blogspot.mk" , "blogspot.com.mt" , "blogspot.mx" , "blogspot.my" , "blogspot.com.ng" , "blogspot.nl" , "blogspot.no" , "blogspot.co.nz" , "blogspot.pt" , "blogspot.qa" , "blogspot.ro" , "blogspot.rs" , "blogspot.ru" , "blogspot.se" , "blogspot.sg" , "blogspot.si" , "blogspot.sk" , "blogspot.sn" , "blogspot.com.sr" , "blogspot.td" , "blogspot.co.tl" , "blogspot.co.to" , "blogspot.com.tr" , "blogspot.tw" , "blogspot.co.uk" , "blogspot.com.uy" , "blogspot.co.za" ] ;
25
+
22
26
const ALPHABET_DOMAINS = [
23
- "abc.xyz" , "waze.com" , "capitalg.com" , "gv.com" , "calicolabs.com" , "x.company" , "nest.com" , "sidewalklabs.com" , "verily.com"
27
+ "abc.xyz" , "waze.com" , "capitalg.com" , "gv.com" , "calicolabs.com" , "x.company" , "nest.com" , "sidewalklabs.com" , "verily.com" ,
24
28
] ;
25
29
26
30
const AD_DOMAINS = [
27
31
"doubleclickbygoogle.com" , "feedburner.com" , "doubleclick.com" , "doubleclick.net" , "adwords.com" , "adsense.com" , "admob.com" , "advertisercommunity.com" ,
28
- "googlesyndication.com" , "googlecommerce.com" , "googlebot.com" , "googleapps.com" , "googleadservices.com" , "gmodules.com" , "googl.com" ,
32
+ "googlesyndication.com" , "googlecommerce.com" , "googlebot.com" , "googleapps.com" , "googleadservices.com" , "gmodules.com" , "googl.com" ,
29
33
"1e100.net" , "domains.google" , "gv.com" ,
30
34
] ;
31
35
32
36
const DEVELOPER_DOMAINS = [
33
37
"madewithcode.com" , "design.google" , "gallery.io" , "domains.google" , "material.io" , "android.com" , "chromium.org" , "cobrasearch.com" , "chromecast.com" , "chrome.com" , "chromebook.com" , "madewithcode.com" , "whatbrowser.org" , "withgoogle.com" , "web.dev" ,
34
38
] ;
35
39
36
- const SEARCHPAGE_PATHS = [
37
- "/search" , "/maps" , "/flights"
38
- ]
39
-
40
-
41
40
GOOGLE_DOMAINS = GOOGLE_DOMAINS . concat ( GOOGLE_INTL_DOMAINS )
42
41
. concat ( GOOGLE_SERVICES ) . concat ( YOUTUBE_DOMAINS ) . concat ( BLOGSPOT_DOMAINS ) . concat ( ALPHABET_DOMAINS )
43
42
. concat ( DEVELOPER_DOMAINS ) . concat ( AD_DOMAINS ) ;
44
43
45
-
46
-
47
44
const MAC_ADDON_ID = "@testpilot-containers" ;
48
45
49
46
let macAddonEnabled = false ;
@@ -54,7 +51,6 @@ const canceledRequests = {};
54
51
const tabsWaitingToLoad = { } ;
55
52
const googleHostREs = [ ] ;
56
53
const youtubeHostREs = [ ] ;
57
- const searchpagePathREs = [ ] ;
58
54
59
55
async function isMACAddonEnabled ( ) {
60
56
try {
@@ -151,14 +147,15 @@ function shouldCancelEarly (tab, options) {
151
147
}
152
148
153
149
function generateGoogleHostREs ( ) {
150
+ const matchOperatorsRegex = / [ | \\ { } ( ) [ \] ^ $ + * ? . - ] / g;
151
+
154
152
for ( let googleDomain of GOOGLE_DOMAINS ) {
155
- googleHostREs . push ( new RegExp ( `^(.*\\.)?${ googleDomain } $` ) ) ;
153
+ googleDomain = googleDomain . replace ( matchOperatorsRegex , '\\$&' ) ;
154
+ googleHostREs . push ( new RegExp ( `(^|\.)${ googleDomain } $` ) ) ;
156
155
}
157
156
for ( let youtubeDomain of YOUTUBE_DOMAINS ) {
158
- youtubeHostREs . push ( new RegExp ( `^(.*\\.)?${ youtubeDomain } $` ) ) ;
159
- }
160
- for ( let searchpagePath of SEARCHPAGE_PATHS ) {
161
- searchpagePathREs . push ( new RegExp ( `^${ searchpagePath } (.*)` ) ) ;
157
+ youtubeDomain = youtubeDomain . replace ( matchOperatorsRegex , '\\$&' ) ;
158
+ youtubeHostREs . push ( new RegExp ( `(^|\.)${ youtubeDomain } $` ) ) ;
162
159
}
163
160
}
164
161
@@ -263,12 +260,17 @@ function isYouTubeURL (url) {
263
260
264
261
function isSearchPageURL ( url ) {
265
262
const parsedUrl = new URL ( url ) ;
266
- for ( let searchpagePathRE of searchpagePathREs ) {
267
- if ( searchpagePathRE . test ( parsedUrl . pathname ) ) {
268
- return true ;
269
- }
270
- }
271
- return false ;
263
+ return parsedUrl . pathname . startsWith ( '/search' ) ;
264
+ }
265
+
266
+ function isMapsURL ( url ) {
267
+ const parsedUrl = new URL ( url ) ;
268
+ return parsedUrl . pathname . startsWith ( '/maps' ) ;
269
+ }
270
+
271
+ function isFlightsURL ( url ) {
272
+ const parsedUrl = new URL ( url ) ;
273
+ return parsedUrl . pathname . startsWith ( '/flights' ) ;
272
274
}
273
275
274
276
function shouldContainInto ( url , tab ) {
@@ -279,11 +281,19 @@ function shouldContainInto (url, tab) {
279
281
280
282
let handleUrl = isGoogleURL ( url ) ;
281
283
282
- if ( extensionSettings . ignore_youtube && isYouTubeURL ( url ) ) {
284
+ if ( handleUrl && extensionSettings . ignore_youtube && isYouTubeURL ( url ) ) {
285
+ handleUrl = false ;
286
+ }
287
+
288
+ if ( handleUrl && extensionSettings . ignore_searchpages && isSearchPageURL ( url ) ) {
289
+ handleUrl = false ;
290
+ }
291
+
292
+ if ( handleUrl && extensionSettings . ignore_maps && isMapsURL ( url ) ) {
283
293
handleUrl = false ;
284
294
}
285
295
286
- if ( extensionSettings . ignore_searchpages && isSearchPageURL ( url ) ) {
296
+ if ( handleUrl && extensionSettings . ignore_flights && isFlightsURL ( url ) ) {
287
297
handleUrl = false ;
288
298
}
289
299
0 commit comments