代码拉取完成,页面将自动刷新
对manifest.json
文件各个参数的说明
{
// 必须的字段
"name": "My Extension",
"version": "versionString",
"manifest_version": 2,
// 建议提供的字段
"description": "A plain text description",
"icons": { ... },
"default_locale": "en",
// 多选一,或者都不提供
"browser_action": {...},
"page_action": {...},
"theme": {...},
"app": {...},
// 根据需要提供
"background": {...},
"chrome_url_overrides": {...},
"content_scripts": [...],
"content_security_policy": "policyString",
"file_browser_handlers": [...],
"homepage_url": "http://path/to/homepage",
"incognito": "spanning" or "split",
"intents": {...}
"key": "publicKey",
"minimum_chrome_version": "versionString",
"nacl_modules": [...],
"offline_enabled": true,
"omnibox": { "keyword": "aString" },
"options_page": "aFile.html",
"permissions": [...],
"plugins": [...],
"requirements": {...},
"update_url": "http://path/to/updateInfo.xml",
"web_accessible_resources": [...]
}
{
"manifest_version": 2,
"name": "陆",
"version": "1.0",
"description": "test-description",
"permissions": [
"https://secure.flickr.com/"
],
// chrome://extensions/ 扩展应用中显示的图标
"icons":
{
"48": "common/img/icon.png",
"128": "common/img/icon.png"
},
// background。会一直常驻后台
"background": {
"scripts": ["js/background.js"],
"persistent": true
},
// 浏览器顶部栏交互用
"browser_action": {
// 图标
"default_icon": "common/img/icon.png",
// 图标点开后,显示交互的html
"default_popup": "common/html/popup.html"
},
//
"page_action": {
"default_icon": "common/img/icon.png",
"default_title": "Do action",
"default_popup": "common/html/popup.html"
},
// 需要直接注入页面的JS,和web页面交互
"content_scripts":
[
{
// 定义哪些页面需要注入。这里是所有页面都注入
"matches": ["<all_urls>"],
"js": ["common/js/init.js", "modules/spiderTool/js/spiderTool.listener.js"],
"css": [],
// 代码注入的时间,可选值: "document_start", "document_end", or "document_idle",最后一个表示页面空闲时,默认document_idle
"run_at": "document_start"
}
],
// 权限申请
"permissions":
[
"contextMenus", // 右键菜单
"activeTab",
"tabs", // 标签.chrome.tabs和chrome.windows模块需要这个权限
"notifications", // 通知
"webRequest", // web请求
"webRequestBlocking", // 阻塞式web请求
"storage", // 插件本地存储
"cookies",
"downloads",
"http://*/*", // 可以通过executeScript或者insertCSS访问的网站
"https://*/*" // 可以通过executeScript或者insertCSS访问的网站
],
// 指定本扩展在注入的目标页面上所需使用的资源的路径
"web_accessible_resources": [
"common/**.*",
"modules/**.*"
]
}
content script
:在Web页面的内部执行javascript脚本
。Content scripts与它所在的应用(扩展)并不是完全没有联系,脚本可以与所在的应用(扩展)交换消息。script可以发送消息,或者背景页面发送消息script接收page_action
:在地址栏内增加临时的图标browser_action
:在工具栏上增加图标背景页
”来查看里面的打印信息注:弹窗popup.html可以直接调用背景页面中的函数
在Web页面的内部执行javascript脚本
页面里的javascript不能访问content script中的变量和函数
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。