Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
282 views
in Technique[技术] by (71.8m points)

Chrome extension, chrome extension communication

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...