谷歌插件编写

来源:互联网 发布:java中的io和nio 编辑:程序博客网 时间:2024/05/22 04:47

闲的无聊研究了下谷歌插件编写,谷歌插件资料国内:点击打开链接

目录如下:我这里用的是jQuery

manifest.json最重要配置文件,其他的跟网页开发没什么区别

{  "manifest_version": 2,  "name": "one-click hello_world",  "description": "my first chrome extension-background",  "version": "1.0",  "permissions": [    "tabs",    "https://*/*",    "http://*/*"  ],  "content_scripts": [    {      "matches": ["http://*/*","https://*/*"],      "js": ["jquery-2.0.3.min.js","content.js"]    }  ],  "background": {    "scripts": [      "bg.js"    ],    "persistent": false  },  "page_action": {    "default_name": "Hello world",    "default_icon": "marker.png",    "default_popup": "popup.html"  }}
marker.png是在浏览器上显示的小图片


popup.html文件:

<!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8">    <title>Title</title>    <script src="jquery-2.0.3.min.js"></script>    <script src="content.js"></script></head><body >    <div>以太币:<span id="eth"></span></div></body></html>
content.js 主要是jQuery代码

$(function () {    window.setInterval(function () {        $.ajax({            type: "GET", url: "", success: function (res) {            }        });    }, 1000)})


效果如下:



在谷歌浏览器扩展程序:直接加载已解压的扩展程序即可,打开项目的文件夹