File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed
Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ function backgroundCheck() {
3737 if ( tab !== undefined ) {
3838 activity . setCurrentActiveTab ( tab . url ) ;
3939 chrome . idle . queryState ( parseInt ( setting_interval_inactivity ) , function ( state ) {
40- if ( state === 'active' ) {
40+ if ( state === 'active' || ( state === 'idle' && checkDOM ( ) ) ) {
4141 if ( activity . isLimitExceeded ( activeUrl , tab ) ) {
4242 setBlockPageToCurrent ( activeUrl ) ;
4343 }
@@ -89,6 +89,21 @@ function setBlockPageToCurrent(activeUrl) {
8989 } ) ;
9090}
9191
92+ function isVideoPlayedOnPage ( ) {
93+ var videoElement = document . getElementsByTagName ( 'video' ) [ 0 ] ;
94+ if ( videoElement !== undefined && videoElement . currentTime > 0 && ! videoElement . paused && ! videoElement . ended && videoElement . readyState > 2 )
95+ return true ;
96+ }
97+
98+ function checkDOM ( ) {
99+ chrome . tabs . executeScript ( {
100+ code : '(' + isVideoPlayedOnPage + ')();'
101+ } , ( results ) => {
102+ if ( results !== undefined && results !== null && results [ 0 ] !== undefined )
103+ return results [ 0 ] ;
104+ } ) ;
105+ }
106+
92107function backgroundUpdateStorage ( ) {
93108 if ( tabs != undefined && tabs . length > 0 )
94109 storage . saveTabs ( tabs ) ;
You can’t perform that action at this time.
0 commit comments