"description": "Change background color of all websites",
"permissions": ["activeTab", "storage"],
"browser_action": {
"default_icon": "icon.png",
"default_popup": "popup.html"
},
"content_scripts": [
{
"matches": [""],
"js": ["content.js"]
}
]
}
popup.html
popup.js
document.getElementById("applyButton").addEventListener("click", function () {
var color = document.getElementById("colorPicker").value;
chrome.storage.sync.set({ backgroundColor: color }, function () {
console.log("Color is set to " + color);
});
});
On the left are the file names, and the right are the content of each file.
Create a folder with any name you like, save all four files into that folder, and then create an icon.png file for the extension, save in the same folder.
In the google chrome, go to “Chrome://extension” --> on the top right corner, click “Developer mode” to enable it. --> click “load unpacked” -->從新啟動chrome, 可以用了。