diff --git a/background.js b/background.js index 4fa775e..aefdbb8 100644 --- a/background.js +++ b/background.js @@ -9,6 +9,7 @@ const hotStrapRegExp = new RegExp('^https\:\/\/www\.hotstar\.com.*'); // Payload to clear the localStorage and fire a reload event after X minutes +//till the screen goes back to full screen,try to make it full for every 3 seconds (this happens for a minute) const CODE = ` setInterval(function() { localStorage.clear(); @@ -16,8 +17,31 @@ const CODE = ` setInterval(function() { window.location.reload(); - }, 300000); -`; + }, 240000); + + var counter = 0; + + var refresh = setInterval(function() { + counter++; + var element = document.getElementsByClassName("vjs-fullscreen-control"); + console.log("enter"); + console.log(element.length); + console.log(element); + if(counter > 20){ + console.log("exited,not in full") + clearInterval(refresh); + } + else if(!window.screenTop && !window.screenY){ + console.log("in full"); + clearInterval(refresh); + } + else{ + console.log("not in full"); + element[0].click(); + } + }, 3000); +` +; // Function to query all tabs and get the current active tab function getCurrentTab(cb) { @@ -50,11 +74,17 @@ function injectCode(tab) { } // When the tab reloads inject the script again -chrome.tabs.onUpdated.addListener(function (tabId, changeInfo, tab) { - injectCode(tab); +chrome.webNavigation.onHistoryStateUpdated.addListener(function(details) { + if(details.frameId === 0) { + // Fires only when details.url === currentTab.url + chrome.tabs.get(details.tabId, function(tab) { + if(tab.url === details.url) { + console.log("onHistoryStateUpdated"); + injectCode(tab); + } + }); + } }); - - // Listen for activation event(click on the extension icon) chrome.browserAction.onClicked.addListener(function () { getCurrentTab(function (tab) { diff --git a/manifest.json b/manifest.json index 796789b..c91f5ba 100644 --- a/manifest.json +++ b/manifest.json @@ -11,7 +11,8 @@ }, "permissions": [ "tabs", - "activeTab" + "activeTab", + "webNavigation" ], "browser_action": {} } \ No newline at end of file