mirror of
https://github.com/mdn/webextensions-examples.git
synced 2026-04-16 06:18:35 +02:00
* Replace var with let in examples store-collected-images/webextension-plain/deps/uuidv4.js * Reverted third–party code
19 lines
650 B
JavaScript
19 lines
650 B
JavaScript
browser.runtime.onMessage.addListener(updateBg);
|
|
|
|
function updateBg(request, sender, sendResponse) {
|
|
let html = document.querySelector('html');
|
|
let body = document.querySelector('body');
|
|
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 = '';
|
|
}
|
|
}
|