mirror of
https://github.com/mdn/webextensions-examples.git
synced 2026-04-16 06:18:35 +02:00
19 lines
643 B
JavaScript
19 lines
643 B
JavaScript
var html = document.querySelector('html');
|
|
var body = document.querySelector('body');
|
|
|
|
chrome.runtime.onMessage.addListener(updateBg);
|
|
|
|
function updateBg(request, sender, sendResponse) {
|
|
if(request.image) {
|
|
html.style.backgroundImage = 'url(' + request.image + ')';
|
|
body.style.backgroundImage = 'url(' + request.image + ')';
|
|
} else if(request.color) {
|
|
html.style.backgroundColor = request.color;
|
|
body.style.backgroundColor = request.color;
|
|
} else if (request.reset) {
|
|
html.style.backgroundImage = '';
|
|
html.style.backgroundColor = '';
|
|
body.style.backgroundImage = '';
|
|
body.style.backgroundColor = '';
|
|
}
|
|
} |