-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpopup.js
More file actions
20 lines (18 loc) · 802 Bytes
/
popup.js
File metadata and controls
20 lines (18 loc) · 802 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
let changeColor = document.getElementById('changeColor');
// grabs color set by background.js and sets the button color in the popup
chrome.storage.sync.get('color', function(data) {
changeColor.style.backgroundColor = data.color;
changeColor.setAttribute('value', data.color);
});
// on click of button on toolbar button, changes background color of
// website to designated 'color' value
// does so by way of programmatic injection, not code injection
// tabs.executeScript injects js/css code into a page
changeColor.onclick = function(element) {
let color = element.target.value;
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
chrome.tabs.executeScript(
tabs[0].id,
{code: 'document.body.style.backgroundColor = "' + color + '";'});
});
};