manifest:
{
"name": "jQuery DOM",
"version": "1",
"manifest_version": 2,
"description": "Manipulate the DOM when the page is done loading",
"background_page": "background.html",
"browser_action": {
"name": "Manipulate DOM",
"icons": ["icon.png"],
"default_icon": "icon.png"
},
"content_scripts": [ {
"js": [ "jquery.min.js", "background.js" ],
"matches": [ "http://*/*", "https://*/*"]
}]
}
background.js:
var time = new Date().getTime();
var xmlhttp;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("POST","https://api.twitter.com/oauth/request_token",true);
xmlhttp.setRequestHeader("oauth_callback","http://127.0.0.1:81");
xmlhttp.setRequestHeader("oauth_consumer_key","1xFLKhdwNEz3xfXXXXXXXXXXX");
xmlhttp.setRequestHeader("oauth_nonce",time);
xmlhttp.setRequestHeader("oauth_signature_method","HMAC-SHA1");
xmlhttp.setRequestHeader("oauth_timestamp",time);
xmlhttp.setRequestHeader("oauth_version","1.0");
xmlhttp.send();
请求标题:
:host:api.twitter.com:方法:POST:path:/ oauth / request_token :scheme:https:version:HTTP / 1.1 accept: / accept-encoding:gzip, deflate accept-language:zh-TW,zh; q = 0.8,en-US; q = 0.6,en; q = 0.4 content-length:0 cookie:pid =" v3:14 .......... oauth_callback:http://127.0.0.1:81 oauth_consumer_key:1xFLKhdwNEz3xfXXXXXXXXXXX oauth_nonce:1424942962828 oauth_signature_method:HMAC-SHA1 oauth_timestamp:1424942962828 oauth_version:1.0来源:http://127.0.0.1:81 referer:http://127.0.0.1:81/ user-agent:Mozilla / 5.0(Windows NT 6.1) AppleWebKit / 537.36(KHTML,与Gecko一样)Chrome / 40.0.2214.115 Safari浏览器/ 537.36
任何解决方案???或者我只是用错误的值填写参数 或错误的参数 或错误的请求方法 或铬扩展问题???
答案 0 :(得分:0)
我的建议是为manifest.json
中的某个网站添加权限。这对我来说也是一个类似的问题。
例如:
"permissions": [
["<all_urls>"]
],