get html from external url in GreaseMonkey [duplicate]
I'm looking to write some greaseMonkey script that combines html from external url's into the curren开发者_如何学Pythont page.
I heard that it might be a problem doing so in JavaScript, because of the Same Origin Policy, but does GreaseMonkey support server side scripting which are requied for that (jQuery), or is the get-method via some external js library/api I can use for that?[Edit] Is it possible to "get" the html by adding iframe with reference to external url in it?
GM_xmlhttpRequest is not affected by Same Origin Policy
As Dr.Molle said, Greasemonkey has an API that allows you to bypass the same origin policy: GM_xmlhttpRequest.
Unfortunately the jQuery AJAX methods don't use the Greasemonkey API to issue their requests, so you will need to manually use the Greasemonkey API rather than relying on the jQuery AJAX methods. If you absolutely must use jQuery, it should be possible to edit the createStandardXHR()
method; just add GM_
.
精彩评论