问题
Below is my manifest.json:
{
"name": "My Extension Name",
"version": "1.9.1",
"manifest_version": 2,
"icons": { "16": "icon16.png",
"48": "icon48.png",
"128": "icon128.png" },
"homepage_url": "https://www.mysite.com",
"description": "My Extension Description",
"permissions": ["http://www.example.com/*"],
"content_scripts" : [{
"matches" : [ "http://www.example.com/*"],
"js" : ["contentscript.js"],
"run_at" : "document_end"
}],
"web_accessible_resources": ["script.js"]
}
My contentscript.js is:
var s = document.createElement('script');
s.src = chrome.extension.getURL("script.js");
(document.head||document.documentElement).appendChild(s);
script.js:
$.post("https://www.mysite.com/app/myfolder/", function(html){
$("body").prepend(html);
});
I would like to access the DOM in http://www.example.com/. There is a form in http://www.example.com/. when the submit button of the form is clicked, iw ould like to get the post values in www.mysite.com. How to achieve this?
回答1:
Yes, you can intercept, process, and tamper with a site's POST
data using the chrome.webRequest
interface. Just implement webRequest
in your manifest.json
and add an onBeforeSendHeaders
function in your content-script. More documentation can be found on the Google Chrome Extension Developers Documentation.
来源:https://stackoverflow.com/questions/27792627/chrome-extension-chrome-extension-communication