mirror of
https://github.com/mdn/webextensions-examples.git
synced 2026-04-17 14:59:12 +02:00
adding cookie example — cookie-bg-picker
This commit is contained in:
19
cookie-bg-picker/content_scripts/updatebg.js
Normal file
19
cookie-bg-picker/content_scripts/updatebg.js
Normal file
@@ -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