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