@@ -5,7 +5,7 @@ class Activity {
55 if ( this . isValidPage ( tab ) === true ) {
66 if ( tab . id && ( tab . id != 0 ) ) {
77 tabs = tabs || [ ] ;
8- var domain = this . extractHostname ( tab . url ) ;
8+ var domain = extractHostname ( tab . url ) ;
99 var isDifferentUrl = false ;
1010 if ( currentTab !== tab . url ) {
1111 isDifferentUrl = true ;
@@ -41,13 +41,13 @@ class Activity {
4141
4242 isInBlackList ( domain ) {
4343 if ( setting_black_list !== undefined && setting_black_list . length > 0 )
44- return setting_black_list . find ( o => isDomainEquals ( this . extractHostname ( o ) , this . extractHostname ( domain ) ) ) !== undefined ;
44+ return setting_black_list . find ( o => isDomainEquals ( extractHostname ( o ) , extractHostname ( domain ) ) ) !== undefined ;
4545 else return false ;
4646 }
4747
4848 isLimitExceeded ( domain , tab ) {
4949 if ( setting_restriction_list !== undefined && setting_restriction_list . length > 0 ) {
50- var item = setting_restriction_list . find ( o => isDomainEquals ( this . extractHostname ( o . domain ) , this . extractHostname ( domain ) ) ) ;
50+ var item = setting_restriction_list . find ( o => isDomainEquals ( extractHostname ( o . domain ) , extractHostname ( domain ) ) ) ;
5151 if ( item !== undefined ) {
5252 var today = new Date ( ) . toLocaleDateString ( "en-US" ) ;
5353 var data = tab . days . find ( x => x . date == today ) ;
@@ -62,6 +62,27 @@ class Activity {
6262 return false ;
6363 }
6464
65+ wasDeferred ( domain ) {
66+ if ( deferredRestrictionsList != undefined ) {
67+ let defItem = deferredRestrictionsList . find ( x => extractHostname ( x . site ) == extractHostname ( domain ) ) ;
68+ if ( defItem != null ) {
69+ let time = defItem . dateOfDeferred ;
70+ if ( time + DEFERRED_TIMEOUT > new Date ( ) . getTime ( ) ) {
71+ return true ;
72+ }
73+ else {
74+ let index = deferredRestrictionsList . indexOf ( defItem ) ;
75+ if ( index > - 1 )
76+ deferredRestrictionsList . splice ( index , 1 ) ;
77+
78+ return false ;
79+ }
80+ }
81+ }
82+
83+ return false ;
84+ }
85+
6586 isNewUrl ( domain ) {
6687 if ( tabs . length > 0 )
6788 return tabs . find ( o => o . url === domain ) === undefined ;
@@ -73,24 +94,9 @@ class Activity {
7394 return tabs . find ( o => o . url === domain ) ;
7495 }
7596
76- extractHostname ( url ) {
77- var hostname ;
78-
79- if ( url . indexOf ( "//" ) > - 1 ) {
80- hostname = url . split ( '/' ) [ 2 ] ;
81- }
82- else {
83- hostname = url . split ( '/' ) [ 0 ] ;
84- }
85-
86- hostname = hostname . split ( ':' ) [ 0 ] ;
87- hostname = hostname . split ( '?' ) [ 0 ] ;
88-
89- return hostname ;
90- }
91-
97+
9298 updateFavicon ( tab ) {
93- var domain = this . extractHostname ( tab . url ) ;
99+ var domain = extractHostname ( tab . url ) ;
94100 var currentTab = this . getTab ( domain ) ;
95101 if ( currentTab !== null && currentTab !== undefined ) {
96102 if ( tab . favIconUrl !== undefined && tab . favIconUrl !== currentTab . favicon ) {
@@ -138,7 +144,7 @@ class Activity {
138144
139145 isNeedNotifyView ( domain , tab ) {
140146 if ( setting_notification_list !== undefined && setting_notification_list . length > 0 ) {
141- var item = setting_notification_list . find ( o => isDomainEquals ( this . extractHostname ( o . domain ) , this . extractHostname ( domain ) ) ) ;
147+ var item = setting_notification_list . find ( o => isDomainEquals ( extractHostname ( o . domain ) , extractHostname ( domain ) ) ) ;
142148 if ( item !== undefined ) {
143149 var today = new Date ( ) . toLocaleDateString ( "en-US" ) ;
144150 var data = tab . days . find ( x => x . date == today ) ;
0 commit comments