Use CrossOrigin.json to fetch posts from archives due to blocking of ordinary third-party AJAX requests.

This commit is contained in:
ccd0 2018-09-17 20:47:21 -07:00
parent ed01e4ca5f
commit 78dd2a9639
3 changed files with 9 additions and 10 deletions

View File

@ -195,7 +195,7 @@ testbuilds/$(name)$1.crx.zip : \
testbuilds/$(name)$1.crx : testbuilds/$(name)$1.crx.zip package.json tools/sign.js node_modules/node-rsa/package.json
node tools/sign.js $1
testbuilds/$(name)$1.meta.js : src/meta/metadata.js src/meta/icon48.png version.json $(template_deps) | testbuilds
testbuilds/$(name)$1.meta.js : src/meta/metadata.js src/meta/icon48.png version.json src/Archive/archives.json $(template_deps) | testbuilds
$(template) $$< $$@ type=userscript channel=$1
testbuilds/$(name)$1.user.js : testbuilds/$(name)$1.meta.js tmp/meta-newline.js $$(call pieces,userscript) | .events/compile

View File

@ -104,17 +104,11 @@ class Fetcher
return false unless Conf['Resurrect Quotes']
return false if not (url = Redirect.to 'post', {@boardID, @postID})
archive = Redirect.data.post[@boardID]
if /^https:\/\//.test(url) or location.protocol is 'http:'
$.cache url, (e) =>
@parseArchivedPost e.target.response, url, archive
,
responseType: 'json'
withCredentials: archive.withCredentials
return true
else if Conf['Exempt Archives from Encryption']
encryptionOK = /^https:\/\//.test(url) or location.protocol is 'http:'
if encryptionOK or Conf['Exempt Archives from Encryption']
CrossOrigin.json url, (response) =>
{media} = response
if media then for key of media when /_link$/.test key
if !encryptionOK and media then for key of media when /_link$/.test key
# Image/thumbnail URLs loaded over HTTP can be modified in transit.
# Require them to be from an HTTP host so that no referrer is sent to them from an HTTPS page.
delete media[key] unless media[key]?.match /^http:\/\//

View File

@ -36,6 +36,11 @@
%>
// @connect 4chan.org
// @connect 4cdn.org
<%=
readJSON('/src/Archive/archives.json').map(function(archive) {
return '// @connect ' + archive.domain;
}).join('\n')
%>
// @connect *
<%=
meta.grants.map(function(grant) {