Chrome插件开发 - pod4g/tool GitHub Wiki
分别创建几个文件:
- index.html
- index.css
- manifest.json
- test.js
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>测试chrome插件</title>
</head>
<body>
你好阿斯顿阿达阿斯顿啊
</body>
</html>
index.css
html,body{
height: 100%;
background: red;
}
manifest.json(此文件很重要,必须要有)
{
"name": "image counter",
"version": "1.0.0",
"manifest_version":2,
"description": "by 李彦峰",
"permissions": ["http://*/*"],
"content_scripts":[
{
"matches":["http://www.diaox2.com/article/1170.html"],
"css":["index.css"],
"js":["test.js"]
}
]
}
test.js
;(function(){
var img = document.getElementsByTagName('img');
console.log(img.length);
alert('此页面共有 ' + img.length +" 张图片");
})(this)