Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added functionality to full screen to hotstar screen automatically. Corrected code to inject only once per reload. #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 36 additions & 6 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,39 @@
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();
}, 0);

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) {
Expand Down Expand Up @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
},
"permissions": [
"tabs",
"activeTab"
"activeTab",
"webNavigation"
],
"browser_action": {}
}