-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontent-script.js
50 lines (44 loc) · 1.27 KB
/
content-script.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
chrome.runtime.onMessage.addListener(
function (request, sender, sendResponse) {
console.log(sender.tab ?
"from a content script:" + sender.tab.url :
"from the extension");
changeMail(request);
sendResponse({
farewell: "goodbye"
});
return true;
}
);
//select radio button based on email used
function changeMail(mail) {
if (mail == "[email protected]") {
document.getElementById("radio2").checked = true;
} else {
document.getElementById("radio1").checked = true;
}
}
//get saved email setting and apply it
chrome.storage.sync.get("mail", function (result) {
console.log('Value currently is ' + result);
console.log(result.mail);
var mail = result.mail;
changeMail(mail);
});
/*
//automatically update page if settings are changed
chrome.storage.onChanged.addListener((changes, area) => {
if (area === 'sync' && changes.mail?.newValue) {
console.log(changes.mail.newValue);
var mail=changes.mail.newValue
changeMail(mail);
}
});
*/
/*
console.log(mail);
if (mail == "[email protected]") {
document.getElementById("radio2").checked = true;
} else {
document.getElementById("radio1").checked = true;
}*/