Chrome 插件学习笔记(1)
1.新建个文件夹 C:\Users\admin\Desktop\chrame
2.目录结构:
3.manifest.json内容:
{ "name": "hello extension", "version": "1.0", "manifest_version": 2, "content_scripts": [ { "js": [ "begin.js" ], "matches": [ "http://tieba.baidu.com/cuseraudit/browser"], "run_at": "document_end" } ] }
4.begin.js内容:
window.setTimeout(hello, 1000); function hello() { window.scrollTo(0, 1000) var rdos = document.getElementsByTagName("input"); //获取所有radio for (var i = 0; i < rdos.length; i++) { if (rdos[i].value == "0") { rdos[i].checked = true } } //点击事件 var obj = document.getElementsByTagName("button"); //获取所有button for (var i = 0; i < obj.length; i++) { if (obj[i].className == 'btn j_btn_submit btn_submit')//找到要点击的button { obj[i].click() } } }
5.打开chrome 工具==>拓展程序==>
6.浏览之前新建的文件夹,点击确定
7. 出现自己编写的的应用
8.打开http://tieba.baidu.com/cuseraudit/browser 就可以了