Main steps
1.manifest. Declaring web in JSON_ accessible_ resources
"web_accessible_resources":[
"img/*"
]
2. create contextmenus in the background and listen for click events
var menuItem = {
"id" : "resource",
"Title": "setting the background image",
"contexts": ["all"]
};
chrome.contextMenus.create(menuItem);
3. call chrome extension. Geturl get image URL
var imgurl = chrome.extension.getURL("img/beauty.jpg");
4. call executescript
chrome.tabs.executeScript(null,{code:"document.body.style.backgroundImage = 'url(\""+imgurl+"\")';\
document.body.style.backgroundRepeat='repeat';"});
Source code
Link:https://pan.baidu.com/s/1p3wk…
Extraction code: ond1