mirror of
https://github.com/mdn/webextensions-examples.git
synced 2026-04-18 07:18:34 +02:00
Get document.html and document.body only when we need them
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
var html = document.querySelector('html');
|
||||
var body = document.querySelector('body');
|
||||
|
||||
browser.runtime.onMessage.addListener(updateBg);
|
||||
|
||||
function updateBg(request, sender, sendResponse) {
|
||||
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 + ')';
|
||||
|
||||
Reference in New Issue
Block a user