forked from Rahul147/hotstar-exploit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackground.js
More file actions
93 lines (83 loc) · 2.71 KB
/
background.js
File metadata and controls
93 lines (83 loc) · 2.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/**
* @author Rahul Nair
* @event onClicked : Fired when a click is registered on the extension icons
* @event onUpdated : Fired when the current tab is reloaded
*/
// Regular expression to test if we're running on hotstar domain
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();
}, 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) {
chrome.tabs.query({
'active': true,
'windowId': chrome.windows.WINDOW_ID_CURRENT
}, function (tabs) {
cb(tabs[0]);
});
}
// Run JavaScript code on the taget tab
function execCommand(tab, cmd, cb) {
chrome.tabs.executeScript(tab.id, {
code: cmd
}, cb);
}
// Inject code
function injectCode(tab) {
// If tab is not Falsy and we are on the currect domain
if (tab && hotStrapRegExp.test(tab.url)) {
execCommand(tab, CODE, function (out) {
console.log('Executed command successfully', out);
});
} else {
// Either the tab object is empty or it's not a Hotstar domain
console.error('Script cannot be run on the current tab');
}
}
// When the tab reloads inject the script again
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) {
injectCode(tab);
});
});