-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdebug.js
141 lines (110 loc) · 3.67 KB
/
debug.js
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
// Developer mode functionality
function help() {
var helpMessages = [
'Welcome to the secret help menu',
'Here are the commands available to you in this console window',
'help() : see this menu again',
'debug.dev() : enable dev mode',
'debug.spoof() : set a dummy device ID locally. You can pass an ID as a parameter, or leave empty for default dummy ID',
'debug.devstop() : disable dev mode',
'debug.alarms() : print all alarms',
'vars : print all local variables',
'debug.setLocalVars(object) : save any key-value pairs as local variables and in local storage',
'debug.clearSync() : clear the sync storage',
'debug.printSessions() : show session information',
'debug.showNotification() : show the old notification popup',
'--------------------------------------------------------------',
'With developer mode enabled, you will see more options in the popup',
'You can manage local variables, or set alarms',
'Have fun!'
];
for (i in helpMessages) {
console.log(helpMessages[i]);
}
}
var debug = {
spoof: function(dummyId) {
if (!dummyId) {
var dummyId = '7538e784-763d-4b7c-bb85-cbc2b890e533';
}
setLocalVars({
dummyId: dummyId,
deviceId: dummyId,
managedDevice: true
});
onStartup();
},
setDeviceVersion: function(version) {
setLocalVars({
deviceVersionSpoof: true,
fakeDeviceVersion: version || '84.0.132.2837'
});
onStartup();
},
setAvailableVersion: function(version) {
setLocalVars({
availableVersionSpoof: true,
fakeAvailableVersion: version || '84.2.231.8956'
});
onStartup();
},
showVersions: function() {
console.log(vars.deviceVersionSpoof ? 'device version spoofed ' + vars.fakeDeviceVersion : 'device version retrieved: ' + vars.verboseDeviceVersion);
console.log(vars.availableVersionSpoof ? 'available version spoofed ' + vars.fakeAvailableVersion : 'available version not spoofed: ' + vars.verboseAvailableVersion);
},
endSpoof: function() {
setLocalVars({
dummyId: null,
deviceId: null,
managedDevice: null,
deviceVersionSpoof: null,
availableVersionSpoof: null,
fakeAvailableVersion: null
});
},
clearStorage: function() {
chrome.storage.sync.clear();
chrome.storage.local.clear();
},
reset: function() {
debug.clearStorage();
debug.killAlarms();
onStartup();
},
goOnline: PubSubApp.goOnline,
goOffline: PubSubApp.goOffline,
dev: function() {
vars.developer = true;
Analytics.sendEvent({
category: 'Developer',
action: 'Enabled',
domain: vars.domain,
licenseTier: vars.licenseTier
});
setLocalVars(vars, init);
},
devstop: function() {
delete vars.developer;
delete vars.dummyId;
chrome.storage.local.clear(function() {
setLocalVars(vars);
});
},
alarms: function() {
chrome.alarms.getAll(function(alarms) {
var now = new Date().getTime();
for (var i in alarms) {
var alarmDelay = ((alarms[i].scheduledTime - now) / 1000);
var min = Math.floor(alarmDelay / 60);
var sec = Math.floor(alarmDelay % 60);
console.log(alarms[i].name.split('|')[1] + ' will fire in ' + min + ' minutes and ' + sec + ' seconds');
}
});
},
killAlarms: function() {
chrome.alarms.clearAll();
},
showNotification: function() {
showOldVersionPopup();
}
};