mirror of
https://github.com/mdn/webextensions-examples.git
synced 2026-04-26 19:14:30 +02:00
adding cookie example — cookie-bg-picker
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
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 = '';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user