From 56ae941c4e16f801a88f0a1f961421548c91370d Mon Sep 17 00:00:00 2001 From: ccd0 Date: Wed, 15 Nov 2017 00:39:22 -0800 Subject: [PATCH] Use page version of XHR when in GM4 so withCredentials works. #1597 --- src/platform/$.coffee | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/platform/$.coffee b/src/platform/$.coffee index c730acd4d..c8dfb35a5 100644 --- a/src/platform/$.coffee +++ b/src/platform/$.coffee @@ -45,10 +45,10 @@ $.ajax = do -> # With the `If-Modified-Since` header we only receive the HTTP headers and no body for 304 responses. # This saves a lot of bandwidth and CPU time for both the users and the servers. lastModified = {} - <% if (type === 'crx') { %> - if XPCNativeWrapper? + if window.wrappedJSObject and not XMLHttpRequest.wrappedJSObject pageXHR = XPCNativeWrapper window.wrappedJSObject.XMLHttpRequest - <% } %> + else + pageXHR = XMLHttpRequest (url, options={}, extra={}) -> {type, whenModified, upCallbacks, form} = extra @@ -57,11 +57,7 @@ $.ajax = do -> url = url.replace /^((?:https?:)?\/\/(?:\w+\.)?4c(?:ha|d)n\.org)\/adv\//, '$1//adv/' # XXX https://bugs.chromium.org/p/chromium/issues/detail?id=643659 url += "?s=#{whenModified}" if $.engine is 'blink' and whenModified - xhr = XMLHttpRequest - <% if (type === 'crx') { %> - xhr = pageXHR or xhr - <% } %> - r = new xhr() + r = new pageXHR() type or= form and 'post' or 'get' try r.open type, url, true