Google plugin (set page background)

Time:2022-6-18

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

Recommended Today

Server enables elegant Internet access

Internet access in schools requires identity authentication. This identity authentication mechanism is troublesome for people who often use the Internet. In order to solve this problem, several feasible methods without manual authentication are proposed here to solve the pain point of identity authentication. Personal use host For personal computers, the simplest is to use Google […]