Merge branch 'webext'

This commit is contained in:
ccd0 2017-10-08 16:58:52 -07:00
commit 79672540e6
6 changed files with 45 additions and 8 deletions

View File

@ -87,7 +87,7 @@ crx_contents := script.js eventPage.js icon16.png icon48.png icon128.png manifes
release := \
$(foreach f, \
$(foreach c,. -beta.,$(name)$(c)crx updates$(c)xml $(name)$(c)user.js $(name)$(c)meta.js) \
$(foreach c,. -beta.,$(name)$(c)crx updates$(c)xml updates$(c)json $(name)$(c)user.js $(name)$(c)meta.js) \
$(name)-noupdate.crx \
$(name)-noupdate.user.js \
$(name).zip \
@ -184,6 +184,9 @@ testbuilds/crx$1/manifest.json : src/meta/manifest.json version.json $(template_
testbuilds/updates$1.xml : src/meta/updates.xml version.json $(template_deps) | testbuilds/crx$1
$(template) $$< $$@ type=crx channel=$1
testbuilds/updates$1.json : src/meta/updates.json version.json $(template_deps) | testbuilds/crx$1
$(template) $$< $$@ type=crx channel=$1
testbuilds/$(name)$1.crx.zip : \
$(foreach f,$(crx_contents),testbuilds/crx$1/$(f)) \
package.json version.json tools/zip-crx.js node_modules/jszip/package.json
@ -342,7 +345,7 @@ stable : distready
git push . HEAD:bstable
git tag -af stable -m "$(meta_name) v$(version)."
cd dist && git merge --no-commit -s ours stable
cd dist && git checkout stable "builds/$(name).*" builds/updates.xml
cd dist && git checkout stable "builds/$(name).*" builds/updates.xml builds/updates.json
cd dist && git commit -am "Move $(meta_name) v$(version) to stable channel."
web : index.html distready

View File

@ -16,6 +16,7 @@
"newIssue": "https://gitreports.com/issue/ccd0/4chan-x?issue_title=%title&details=%details",
"newIssueMaxLength": 8181,
"appid": "lacclbnghgdicfifcamcmcnilckjamag",
"appidGecko": "4chan-x@4chan-x.net",
"chromeStoreID": "ohnjgmpcibpbafdlkimncjhflgedgpam",
"recaptchaKey": "6Ldp2bsSAAAAAAJ5uyx_lx34lJeEpTLVkP5k04qc",
"youtubeAPIKey": "AIzaSyB5_zaen_-46Uhz1xGR-lz1YoUMHqCD6CE",

View File

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

View File

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

12
src/meta/updates.json Normal file
View File

@ -0,0 +1,12 @@
{
"addons": {
"<%= meta.appidGecko %>": {
"updates": [
{
"version": "<%= readJSON('/version.json').version %>",
"update_link": "<%= meta.downloads %><%= name %><%= channel %>.crx"
}
]
}
}
}

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.
# This saves a lot of bandwidth and CPU time for both the users and the servers.
lastModified = {}
<% if (type === 'crx') { %>
if XPCNativeWrapper?
pageXHR = XPCNativeWrapper window.wrappedJSObject.XMLHttpRequest
<% } %>
(url, options={}, 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/'
# XXX https://bugs.chromium.org/p/chromium/issues/detail?id=643659
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'
try
r.open type, url, true
@ -415,9 +423,17 @@ $.get = $.oneItemSugar (data, cb) ->
return unless $.crxWorking()
results = {}
get = (area) ->
chrome.storage[area].get Object.keys(data), (result) ->
keys = Object.keys data
# XXX slow performance in Firefox
if $.engine is 'gecko' and area is 'sync' and keys.length > 3
keys = null
chrome.storage[area].get keys, (result) ->
if chrome.runtime.lastError
c.error chrome.runtime.lastError.message
if keys is null
result2 = {}
result2[key] = val for key, val of result when key of data
result = result2
for key of data
$.oldValue[area][key] = result[key]
results[area] = result