开发者

get html from external url in GreaseMonkey [duplicate]

开发者 https://www.devze.com 2023-03-12 10:30 出处:网络
This question already has answers here: How to use XMLHttpRequest to download an HTML page in the background and extract a text element from it?
This question already has answers here: How to use XMLHttpRequest to download an HTML page in the background and extract a text element from it? (3 answers) jQuery .get for non https, in a userscript (4 answers) Closed 5 years ago.

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_.

0

精彩评论

暂无评论...
验证码 换一张
取 消