R
R
Ruslan2011-03-07 11:43:45
Google Chrome
Ruslan, 2011-03-07 11:43:45

JSONP in UserJS for Chrome

Tell me how to implement JSONP in UserJS for Chrome? I understand that extensions do not have access to the global object?

1) That is, it is impossible to declare myCallback so that the script returns myCallback(JSON)

Get access to what is returned by the script:

2) callbackVar = JSON, so that it is possible to delete globalObj[callbackVar], as well as the ability to issue an error message by timeout
3) well, or var callbackVar = JSON

also fails.

You need to transfer UserJS from Opera.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin Kitmanov, 2011-03-07
@ruzzz

Content scripts from extensions are executed in their own sandbox. So it will not work to intercept the request (as I understand it, this is what you want) sent by the page itself. The only communication option in this case is through the DOM tree, it is shared.
If you need to send a cross-domain AJAX request from the content script, then this is done by exchanging messages with the Background Page , which sends the request, receives the result and sends it to the content script through, again, messages.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question