Use page XHR for Firefox WE, and list host permissions explicitly.

This commit is contained in:
ccd0 2017-09-29 03:16:10 -07:00
parent 3e019cc116
commit e6bd2d9cb2
3 changed files with 11 additions and 4 deletions

View File

@ -20,6 +20,7 @@
"BroadcastChannel": false, "BroadcastChannel": false,
"GM_info": false, "GM_info": false,
"cloneInto": false, "cloneInto": false,
"XPCNativeWrapper": false,
"unsafeWindow": false, "unsafeWindow": false,
"chrome": false, "chrome": false,
"GM": false<%= "GM": false<%=

View File

@ -23,9 +23,7 @@
<% if (channel !== '-noupdate') { %> "update_url": "<%= meta.downloads %>updates<%= channel %>.xml", <% if (channel !== '-noupdate') { %> "update_url": "<%= meta.downloads %>updates<%= channel %>.xml",
"key": "<%= meta.appid %>", "key": "<%= meta.appid %>",
<% } %> "minimum_chrome_version": "<%= meta.min.chrome %>", <% } %> "minimum_chrome_version": "<%= meta.min.chrome %>",
"permissions": [ "permissions": <%= JSON.stringify(meta.matches_only.concat(["storage"])) %>,
"storage"
],
"optional_permissions": [ "optional_permissions": [
"*://*/" "*://*/"
], ],

View File

@ -45,6 +45,10 @@ $.ajax = do ->
# With the `If-Modified-Since` header we only receive the HTTP headers and no body for 304 responses. # 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. # This saves a lot of bandwidth and CPU time for both the users and the servers.
lastModified = {} lastModified = {}
<% if (type === 'crx') { %>
if XPCNativeWrapper?
pageXHR = XPCNativeWrapper window.wrappedJSObject.XMLHttpRequest
<% } %>
(url, options={}, extra={}) -> (url, options={}, extra={}) ->
{type, whenModified, upCallbacks, form} = extra {type, whenModified, upCallbacks, form} = extra
@ -53,7 +57,11 @@ $.ajax = do ->
url = url.replace /^((?:https?:)?\/\/(?:\w+\.)?4c(?:ha|d)n\.org)\/adv\//, '$1//adv/' url = url.replace /^((?:https?:)?\/\/(?:\w+\.)?4c(?:ha|d)n\.org)\/adv\//, '$1//adv/'
# XXX https://bugs.chromium.org/p/chromium/issues/detail?id=643659 # XXX https://bugs.chromium.org/p/chromium/issues/detail?id=643659
url += "?s=#{whenModified}" if $.engine is 'blink' and whenModified url += "?s=#{whenModified}" if $.engine is 'blink' and whenModified
r = new XMLHttpRequest() xhr = XMLHttpRequest
<% if (type === 'crx') { %>
xhr = pageXHR or xhr
<% } %>
r = new xhr()
type or= form and 'post' or 'get' type or= form and 'post' or 'get'
try try
r.open type, url, true r.open type, url, true