-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackground.js
31 lines (27 loc) · 1.03 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
chrome.runtime.onMessage.addListener(async (recdMessage) => {
if (recdMessage.messageType === 'GET_CREDENTIALS_FROM_BG') {
console.log(recdMessage.messageType)
const accessCodeText = recdMessage.accessCodeText
// TODO: call timeboxed API to populate credentials
const credentials = {
username: "test@gmail.com",
passwd: "1234password"
}
let [tab] = await chrome.tabs.query({
active: true, currentWindow: true
});
let message = {
messageType: "WITH_CREDENTIALS_FROM_BG",
credentials: credentials
}
chrome.tabs.sendMessage(tab.id, message, (response) => {
if (chrome.runtime.lastError) {
// TODO: error handling
// console.error("Error communicating from background to content_script!")
} else {
console.log("Sent message from background to content_script!")
console.log(response)
}
});
}
});