Chrome扩展自动运行js脚本

Apr 13 2020

新建一个文件夹

1
mkdir chrome_extension

下载jquery-2.0.2.min.js,导入jQuery

新建文件manifest.json

1
touch manifest.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
{
"name": "multitran_find_error",
"manifest_version": 2,
"version": "0.2",
"description": "For multitran to find the red error item",
"browser_action": {
"default_icon": "icon.png"
},
"content_scripts": [
{
"matches": ["http://*.multitran.com/*", "https://*.multitran.com/*"],
"js": ["jquery-2.0.2.min.js", "script.js"]
}
],
"background":{
"scripts" : ["jquery-2.0.2.min.js"]
}
}

新建script.js

1
此处编写js脚本

打开chrome://extensions/,勾选开发者模式,选择加载已解压的扩展程序

JavaScript