Chrome extension, chrome extension communication

梦想与她 提交于 2019-12-13 11:12:09

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!