Handle errors thrown by GM.xmlHttpRequest.
This commit is contained in:
parent
69a56f9e05
commit
c3054640a8
@ -19,7 +19,7 @@ CrossOrigin =
|
|||||||
cb response, responseHeaderString
|
cb response, responseHeaderString
|
||||||
<% } %>
|
<% } %>
|
||||||
<% if (type === 'userscript') { %>
|
<% if (type === 'userscript') { %>
|
||||||
(GM?.xmlHttpRequest or GM_xmlhttpRequest)
|
gmOptions =
|
||||||
method: "GET"
|
method: "GET"
|
||||||
url: url
|
url: url
|
||||||
headers: headers
|
headers: headers
|
||||||
@ -40,6 +40,10 @@ CrossOrigin =
|
|||||||
cb null
|
cb null
|
||||||
onabort: ->
|
onabort: ->
|
||||||
cb null
|
cb null
|
||||||
|
try
|
||||||
|
(GM?.xmlHttpRequest or GM_xmlhttpRequest) gmOptions
|
||||||
|
catch
|
||||||
|
$.queueTask cb, null
|
||||||
<% } %>
|
<% } %>
|
||||||
|
|
||||||
file: (url, cb) ->
|
file: (url, cb) ->
|
||||||
@ -102,7 +106,7 @@ CrossOrigin =
|
|||||||
req.onloadend = onloadend
|
req.onloadend = onloadend
|
||||||
|
|
||||||
<% if (type === 'userscript') { %>
|
<% if (type === 'userscript') { %>
|
||||||
gmReq = (GM?.xmlHttpRequest or GM_xmlhttpRequest) {
|
gmOptions = {
|
||||||
method: 'GET'
|
method: 'GET'
|
||||||
url
|
url
|
||||||
headers
|
headers
|
||||||
@ -121,6 +125,11 @@ CrossOrigin =
|
|||||||
onabort: -> req.onloadend()
|
onabort: -> req.onloadend()
|
||||||
ontimeout: -> req.onloadend()
|
ontimeout: -> req.onloadend()
|
||||||
}
|
}
|
||||||
|
try
|
||||||
|
gmReq = (GM?.xmlHttpRequest or GM_xmlhttpRequest) gmOptions
|
||||||
|
catch
|
||||||
|
return $.ajax url, options
|
||||||
|
|
||||||
if gmReq and typeof gmReq.abort is 'function'
|
if gmReq and typeof gmReq.abort is 'function'
|
||||||
req.abort = ->
|
req.abort = ->
|
||||||
try
|
try
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user