mirror of
https://github.com/mdn/webextensions-examples.git
synced 2026-04-16 06:18:35 +02:00
Get document.html and document.body only when we need them
This commit is contained in:
@@ -1,13 +1,12 @@
|
||||
var html = document.querySelector('html');
|
||||
var body = document.querySelector('body');
|
||||
|
||||
browser.runtime.onMessage.addListener(updateBg);
|
||||
|
||||
function updateBg(request, sender, sendResponse) {
|
||||
if(request.image) {
|
||||
var html = document.querySelector('html');
|
||||
var body = document.querySelector('body');
|
||||
if (request.image) {
|
||||
html.style.backgroundImage = 'url(' + request.image + ')';
|
||||
body.style.backgroundImage = 'url(' + request.image + ')';
|
||||
} else if(request.color) {
|
||||
} else if (request.color) {
|
||||
html.style.backgroundColor = request.color;
|
||||
body.style.backgroundColor = request.color;
|
||||
} else if (request.reset) {
|
||||
|
||||
Reference in New Issue
Block a user