-
StackOverflow 文档
-
google-chrome 教程
-
Chrome 扩展程序
-
浏览器在页面上运行 executeScript 的操作
manifest.json
{
"name": "Hello Page",
"description": "Add 'Hello' to the current page.",
"version": "1.0",
"permissions": [
"activeTab"
],
"background": {
"scripts": ["background.js"],
"persistent": false
},
"browser_action": {
"default_title": "Say Hello on this page"
},
"manifest_version": 2
}
background.js
chrome.browserAction.onClicked.addListener(function(tab) {
chrome.tabs.executeScript({
code: 'document.body.insertAdjacentText("beforeBegin", "Hello!")'
});
});