manifest
{ "name":"Catch your Data", "description":"Catch every data what you need", "version":"1.0", "permissions": [ "tabs", "http://*/*", "https://*/*","http://service.miniice.cn/","storage"//storage必须有,储存权限 ], "browser_action": { "default_title": "Get this page's Data.", "default_icon": "icon.png", "default_popup": "popup.html" }, "manifest_version":2, "content_scripts": [ { "js":["jquery-2.2.0.min.js","getnumber.js"], "matches":["https://sycm.taobao.com/portal/*"]//权限设置,可不设 } ], "background": { "scripts": ["jquery-2.2.0.min.js","ajax.js"] }, "options_page":"options.html" }
background - ajax.js
$.post("data.php","",function(ret){ console.log(ret); chrome.storage.sync.set(ret, function(){ //do something console.log("缓存成功") }); })
content_scripts ?getnumber.js
chrome.storage.sync.get(null,function(result){ console.log(result); })