使用Chrome插件赋能测试——manifest.json举例

{
	// 清单文件的版本,这个必须写,而且必须是2
	"manifest_version": 2,
	// 插件的名称
	"name": "demo",
	// 插件的版本
	"version": "1.0.0",
	// 插件描述
	"description": "简单的Chrome扩展demo",
	// 图标,一般偷懒全部用一个尺寸的也没问题
	"icons":
	{
		"16": "img/icon.png",
		"48": "img/icon.png",
		"128": "img/icon.png"
	},
	// 会一直常驻的后台JS或后台页面
	"background":
	{
		// 2种指定方式,如果指定JS,那么会自动生成一个背景页
		"page": "background.html"
		//"scripts": ["js/background.js"]
	},
	// 浏览器右上角图标设置,browser_action、page_action、app必须三选一
	"browser_action": 
	{
		"default_icon": "img/icon.png",
		// 图标悬停时的标题,可选
		"default_title": "这是一个示例Chrome插件",
		"default_popup": "popup.html"
	},
	// 当某些特定页面打开才显示的图标
	/*"page_action":
	{
		"default_icon": "img/icon.png",
		"default_title": "我是pageAction",
		"default_popup": "popup.html"
	},*/
	// 需要直接注入页面的JS
	"content_scripts": 
	[
		{
			//"matches": ["http://*/*", "https://*/*"],
			// "<all_urls>" 表示匹配所有地址
			"matches": ["<all_urls>"],
			// 多个JS按顺序注入
			"js": ["js/jquery-1.8.3.js", "js/content-script.js"],
			// JS的注入可以随便一点,但是CSS的注意就要千万小心了,因为一不小心就可能影响全局样式
			"css": ["css/custom.css"],
			// 代码注入的时间,可选值: "document_start", "document_end", or "document_idle",最后一个表示页面空闲时,默认document_idle
			"run_at": "document_start"
		},
		// 这里仅仅是为了演示content-script可以配置多个规则
		{
			"matches": ["*://*/*.png", "*://*/*.jpg", "*://*/*.gif", "*://*/*.bmp"],
			"js": ["js/show-image-content-size.js"]
		}
	],
	// 权限申请
	"permissions":
	[
		"contextMenus", // 右键菜单
		"tabs", // 标签
		"notifications", // 通知
		"webRequest", // web请求
		"webRequestBlocking",
		"storage", // 插件本地存储
		"http://*/*", // 可以通过executeScript或者insertCSS访问的网站
		"https://*/*" // 可以通过executeScript或者insertCSS访问的网站
	],
	// 普通页面能够直接访问的插件资源列表,如果不设置是无法直接访问的
	"web_accessible_resources": ["js/inject.js"],
	"homepage_url": "https://www.baidu.com",
	// 覆盖浏览器默认页面
	"chrome_url_overrides":
	{
		// 覆盖浏览器默认的新标签页
		"newtab": "newtab.html"
	},
	// Chrome40以前的插件配置页写法
	"options_page": "options.html",
	// Chrome40以后的插件配置页写法,如果2个都写,新版Chrome只认后面这一个
	"options_ui":
	{
		"page": "options.html",
		// 添加一些默认的样式,推荐使用
		"chrome_style": true
	},
	// 向地址栏注册一个关键字以提供搜索建议,只能设置一个关键字
	"omnibox": { "keyword" : "go" },
	// 默认语言
	"default_locale": "zh_CN",
	// devtools页面入口,注意只能指向一个HTML文件,不能是JS文件
	"devtools_page": "devtools.html"
}

{
	"background": {
		/* 只执行一次,用来写入到鼠标右键 */
		"scripts": ["js/background.js"]
	},
	"author": "TEEMO",
	"description": "基于Vue,Axios的简易Postman插件,UI基于Eleme 2.1.2.0",
	"icons": {
      "128": "img/icon-128.png",
      "16": "img/icon-16.png",
      "32": "img/icon-32.png",
      "48": "img/icon-48.png",
      "96": "img/icon-96.png"
   },
	"manifest_version": 2,
	"name": "Magic Postman",
	"offline_enabled": true,
	"browser_action": {
		"default_icon": "img/icon-96.png",
		/* "default_popup": "postman.html", */
		"default_title": "Magic Postman"
	},
	/* ***重要*** 配置安全选项,配置后才可以使用Vue*/
	"content_security_policy": "style-src 'self' 'unsafe-inline';script-src 'self' 'unsafe-eval'; object-src 'self' ; media-src 'self' filesystem:",
	/* 插件要获取的浏览器用户权限 */
	"permissions": [
		"background", 
		"contextMenus", 
		"geolocation", 
		"management", 
		"topSites", 
		"bookmarks", 
		"unlimitedStorage", 
		"topSites", 
		"identity",
		/* ***重要*** 允许所有http,https请求可以跨域 */
		"http://*/", "https://*/", 
		"chrome://favicon/", 
		"history", 
		"alarms", 
		"notifications", 
		"tabs", 
		"storage", 
		"activeTab", 
		"declarativeContent", 
		"webNavigation", 
		"webRequest", 
		"webRequestBlocking", 
		"cookies"
	],
	"version": "1.0.0"
}

{
  "name": "ChromeSsp",
  "version": "1.0.0",
  "minimum_chrome_version": "10.0",
  "description": "chrome devtools extension example",
  "devtools_page": "devtools.html",
  "manifest_version": 2,
  "content_scripts": [
         {
             "matches": ["*://*/*"],
             "css": [],
             "js": ["ContentScripts.js"]
         }
       ],
  "background": {
    "scripts": [
      "scripts/background.js"
    ],
    "persistent": true
  },
  "permissions": [
    "webRequest",
    "webRequestBlocking",
    "storage",
    "tabs",
    "http://*/*",
    "https://*/*"
  ],
  "content_security_policy": "style-src 'self' 'unsafe-inline' https://unpkg.com;script-src 'self' 'unsafe-eval' https://cdn.bootcss.com;object-src 'self' ;"
}

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

多则惑少则明

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值