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,33 @@ 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" ,
22
+ ] ;
23
+
24
+ const BLOGSPOT_DOMAINS = [
25
+ "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" , "stackdriver.com" ,
20
26
] ;
21
- 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" , "stackdriver.com" ] ;
27
+
22
28
const ALPHABET_DOMAINS = [
23
- "abc.xyz" , "waze.com" , "capitalg.com" , "gv.com" , "calicolabs.com" , "x.company" , "nest.com" , "sidewalklabs.com" , "verily.com"
29
+ "abc.xyz" , "waze.com" , "capitalg.com" , "gv.com" , "calicolabs.com" , "x.company" , "nest.com" , "sidewalklabs.com" , "verily.com" ,
24
30
] ;
25
31
26
32
const AD_DOMAINS = [
27
33
"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" ,
34
+ "googlesyndication.com" , "googlecommerce.com" , "googlebot.com" , "googleapps.com" , "googleadservices.com" , "gmodules.com" , "googl.com" ,
29
35
"1e100.net" , "domains.google" , "gv.com" ,
30
36
] ;
31
37
32
38
const DEVELOPER_DOMAINS = [
33
39
"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
40
] ;
35
41
36
- const SEARCHPAGE_PATHS = [
37
- "/search" , "/maps" , "/flights"
38
- ]
39
-
40
-
41
42
GOOGLE_DOMAINS = GOOGLE_DOMAINS . concat ( GOOGLE_INTL_DOMAINS )
42
43
. concat ( GOOGLE_SERVICES ) . concat ( YOUTUBE_DOMAINS ) . concat ( BLOGSPOT_DOMAINS ) . concat ( ALPHABET_DOMAINS )
43
44
. concat ( DEVELOPER_DOMAINS ) . concat ( AD_DOMAINS ) ;
44
45
45
-
46
-
47
46
const MAC_ADDON_ID = "@testpilot-containers" ;
48
47
49
48
let macAddonEnabled = false ;
@@ -54,7 +53,6 @@ const canceledRequests = {};
54
53
const tabsWaitingToLoad = { } ;
55
54
const googleHostREs = [ ] ;
56
55
const youtubeHostREs = [ ] ;
57
- const searchpagePathREs = [ ] ;
58
56
59
57
async function isMACAddonEnabled ( ) {
60
58
try {
@@ -151,14 +149,15 @@ function shouldCancelEarly (tab, options) {
151
149
}
152
150
153
151
function generateGoogleHostREs ( ) {
152
+ const matchOperatorsRegex = / [ | \\ { } ( ) [ \] ^ $ + * ? . - ] / g;
153
+
154
154
for ( let googleDomain of GOOGLE_DOMAINS ) {
155
- googleHostREs . push ( new RegExp ( `^(.*\\.)?${ googleDomain } $` ) ) ;
155
+ googleDomain = googleDomain . replace ( matchOperatorsRegex , '\\$&' ) ;
156
+ googleHostREs . push ( new RegExp ( `(^|\.)${ googleDomain } $` ) ) ;
156
157
}
157
158
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 } (.*)` ) ) ;
159
+ youtubeDomain = youtubeDomain . replace ( matchOperatorsRegex , '\\$&' ) ;
160
+ youtubeHostREs . push ( new RegExp ( `(^|\.)${ youtubeDomain } $` ) ) ;
162
161
}
163
162
}
164
163
@@ -263,12 +262,17 @@ function isYouTubeURL (url) {
263
262
264
263
function isSearchPageURL ( url ) {
265
264
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 ;
265
+ return parsedUrl . pathname . startsWith ( '/search' ) ;
266
+ }
267
+
268
+ function isMapsURL ( url ) {
269
+ const parsedUrl = new URL ( url ) ;
270
+ return parsedUrl . pathname . startsWith ( '/maps' ) ;
271
+ }
272
+
273
+ function isFlightsURL ( url ) {
274
+ const parsedUrl = new URL ( url ) ;
275
+ return parsedUrl . pathname . startsWith ( '/flights' ) ;
272
276
}
273
277
274
278
function shouldContainInto ( url , tab ) {
@@ -279,11 +283,19 @@ function shouldContainInto (url, tab) {
279
283
280
284
let handleUrl = isGoogleURL ( url ) ;
281
285
282
- if ( extensionSettings . ignore_youtube && isYouTubeURL ( url ) ) {
286
+ if ( handleUrl && extensionSettings . ignore_youtube && isYouTubeURL ( url ) ) {
287
+ handleUrl = false ;
288
+ }
289
+
290
+ if ( handleUrl && extensionSettings . ignore_searchpages && isSearchPageURL ( url ) ) {
291
+ handleUrl = false ;
292
+ }
293
+
294
+ if ( handleUrl && extensionSettings . ignore_maps && isMapsURL ( url ) ) {
283
295
handleUrl = false ;
284
296
}
285
297
286
- if ( extensionSettings . ignore_searchpages && isSearchPageURL ( url ) ) {
298
+ if ( handleUrl && extensionSettings . ignore_flights && isFlightsURL ( url ) ) {
287
299
handleUrl = false ;
288
300
}
289
301
0 commit comments