Offer cross-origin abort in userscripts if available.
This commit is contained in:
parent
e98fed9e5f
commit
6ea1d4ca13
@ -177,6 +177,7 @@ ThreadWatcher =
|
||||
ajax = if (siteID is Site.hostname) then $.ajax else CrossOrigin.ajax
|
||||
req = ajax url,
|
||||
onloadend: ->
|
||||
@finished = true
|
||||
ThreadWatcher.fetched++
|
||||
if ThreadWatcher.fetched is ThreadWatcher.requests.length
|
||||
ThreadWatcher.requests = []
|
||||
@ -192,7 +193,7 @@ ThreadWatcher =
|
||||
ThreadWatcher.requests.push req
|
||||
|
||||
abort: ->
|
||||
for req in ThreadWatcher.requests when req.readyState isnt 4 # DONE
|
||||
for req in ThreadWatcher.requests when !req.finished
|
||||
req.abort?()
|
||||
return
|
||||
|
||||
|
||||
@ -87,7 +87,7 @@ CrossOrigin =
|
||||
response: null
|
||||
|
||||
<% if (type === 'userscript') { %>
|
||||
(GM?.xmlHttpRequest or GM_xmlhttpRequest)
|
||||
gmReq = (GM?.xmlHttpRequest or GM_xmlhttpRequest)
|
||||
method: "GET"
|
||||
url: url+''
|
||||
timeout: timeout
|
||||
@ -99,6 +99,7 @@ CrossOrigin =
|
||||
onerror: -> onloadend.call(req)
|
||||
onabort: -> onloadend.call(req)
|
||||
ontimeout: -> onloadend.call(req)
|
||||
req.abort = gmReq.abort
|
||||
<% } %>
|
||||
|
||||
<% if (type === 'crx') { %>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user