-
Notifications
You must be signed in to change notification settings - Fork 0
/
background.js
70 lines (53 loc) · 2.32 KB
/
background.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
// chrome.runtime.onInstalled.addListener(() => {
// chrome.storage.local.set({
// "isExtensionEnabled": true
// })
// chrome.storage.local.set({
// "legend_inset": '15px auto auto 15px'
// })
// chrome.storage.local.set({
// "legend_inset__price": '15px auto auto 200px'
// })
// });
// chrome.action.onClicked.addListener((tab) => {
// chrome.storage.local.get(["isExtensionEnabled"], (data) => {
// let isExtensionEnabled = data.isExtensionEnabled
// var newStatus = isExtensionEnabled ? false : true // If on, turn off. If off, turn on.
// chrome.storage.local.set({
// "isExtensionEnabled": true
// })cd ide
// // var imageData = newStatus ? chrome.runtime.getURL('/images/templogo.png') : chrome.runtime.getURL('/images/templogo_grey.png')
// // chrome.action.setIcon({path: imageData}, () => { /* Don't need the callback */ });
// chrome.tabs.query({}, tabs => {
// tabs.forEach(tab => {
// // tab.url only shows up if its ticket master or livenation, since we defined the ext only to work for those two.
// tab.url ? chrome.tabs.sendMessage(tab.id, newStatus) : null
// });
// });
// });
// });
// intercept and capture authorization headers
chrome.webRequest.onBeforeSendHeaders.addListener(async function(details) {
if (details.url.includes('messages?')) {
console.log(details.tabId)
let myHeaders = {}
let headers = details.requestHeaders
console.log(headers)
for (var i=0; i < headers.length; i++) {
let header = headers[i]['name'].toLowerCase()
let value = headers[i]['value']
if (header == 'authorization' || header == 'x-super-properties') {
myHeaders[header] = value
}
}
await chrome.storage.local.set({
'authorization': myHeaders['authorization'],
'x-super-properties': myHeaders['x-super-properties']
})
chrome.tabs.sendMessage(details.tabId, {
'initiator': 'authorization',
'authorization': myHeaders['authorization'],
'x-super-properties': myHeaders['x-super-properties']
})
}
}, {urls: ['<all_urls>']}, ['requestHeaders'])