From 78dd2a96392b35373564623b61b137407eece60d Mon Sep 17 00:00:00 2001 From: ccd0 Date: Mon, 17 Sep 2018 20:47:21 -0700 Subject: [PATCH] Use CrossOrigin.json to fetch posts from archives due to blocking of ordinary third-party AJAX requests. --- Makefile | 2 +- src/classes/Fetcher.coffee | 12 +++--------- src/meta/metadata.js | 5 +++++ 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index a8268f3fb..f88841cff 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/src/classes/Fetcher.coffee b/src/classes/Fetcher.coffee index d268c73d1..30f21e2db 100644 --- a/src/classes/Fetcher.coffee +++ b/src/classes/Fetcher.coffee @@ -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:\/\// diff --git a/src/meta/metadata.js b/src/meta/metadata.js index d2905e3b3..81f9e8481 100644 --- a/src/meta/metadata.js +++ b/src/meta/metadata.js @@ -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) {