Try ordinary AJAX request for fetching files if GM.xmlHttpRequest not available.
This commit is contained in:
parent
c3054640a8
commit
a2ed86e4f0
@ -19,6 +19,19 @@ CrossOrigin =
|
|||||||
cb response, responseHeaderString
|
cb response, responseHeaderString
|
||||||
<% } %>
|
<% } %>
|
||||||
<% if (type === 'userscript') { %>
|
<% if (type === 'userscript') { %>
|
||||||
|
fallback = ->
|
||||||
|
$.ajax url, {
|
||||||
|
headers
|
||||||
|
responseType: 'arraybuffer'
|
||||||
|
onloadend: ->
|
||||||
|
if @status and @response
|
||||||
|
cb new Uint8Array(@response), @getAllResponseHeaders()
|
||||||
|
else
|
||||||
|
cb null
|
||||||
|
}
|
||||||
|
unless GM?.xmlHttpRequest? or GM_xmlhttpRequest?
|
||||||
|
fallback()
|
||||||
|
return
|
||||||
gmOptions =
|
gmOptions =
|
||||||
method: "GET"
|
method: "GET"
|
||||||
url: url
|
url: url
|
||||||
@ -43,7 +56,7 @@ CrossOrigin =
|
|||||||
try
|
try
|
||||||
(GM?.xmlHttpRequest or GM_xmlhttpRequest) gmOptions
|
(GM?.xmlHttpRequest or GM_xmlhttpRequest) gmOptions
|
||||||
catch
|
catch
|
||||||
$.queueTask cb, null
|
fallback()
|
||||||
<% } %>
|
<% } %>
|
||||||
|
|
||||||
file: (url, cb) ->
|
file: (url, cb) ->
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user