diff --git a/CHANGELOG.md b/CHANGELOG.md index d8f934e64..4782a080b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ -Sometimes the changelog has notes (not comprehensive) acknowledging people's work. This does not mean the changes are their fault, only that their code was used. All changes to the script are chosen by and the fault of the maintainer (ccd0). +### v1.14.3 + +**v1.14.3.0** *(2018-09-18)* - [[Userscript](https://raw.githubusercontent.com/ccd0/4chan-x/1.14.3.0/builds/4chan-X-noupdate.user.js)] [[Chrome extension](https://raw.githubusercontent.com/ccd0/4chan-x/1.14.3.0/builds/4chan-X-noupdate.crx)] +- Based on v1.14.2.1. +- Fix issues with archives, Link Title, and Github Gist embedding caused by ad blocking changes. + ### v1.14.2 **v1.14.2.1** *(2018-06-22)* - [[Userscript](https://raw.githubusercontent.com/ccd0/4chan-x/1.14.2.1/builds/4chan-X-noupdate.user.js)] [[Chrome extension](https://raw.githubusercontent.com/ccd0/4chan-x/1.14.2.1/builds/4chan-X-noupdate.crx)] diff --git a/builds/4chan-X-beta.crx b/builds/4chan-X-beta.crx index 3124e883d..7a4013159 100644 Binary files a/builds/4chan-X-beta.crx and b/builds/4chan-X-beta.crx differ diff --git a/builds/4chan-X-beta.meta.js b/builds/4chan-X-beta.meta.js index 7707a664f..11a8f38d6 100644 --- a/builds/4chan-X-beta.meta.js +++ b/builds/4chan-X-beta.meta.js @@ -1,6 +1,6 @@ // ==UserScript== // @name 4chan X beta -// @version 1.14.2.1 +// @version 1.14.3.0 // @minGMVer 1.14 // @minFFVer 26 // @namespace 4chan-X @@ -38,6 +38,24 @@ // @exclude https://www.4chan.org/donate?* // @connect 4chan.org // @connect 4cdn.org +// @connect mayhemydg.github.io +// @connect archive.4plebs.org +// @connect archive.nyafuu.org +// @connect archive.rebeccablacktech.com +// @connect warosu.org +// @connect desuarchive.org +// @connect boards.fireden.net +// @connect arch.b4k.co +// @connect archive.b-stats.org +// @connect archived.moe +// @connect thebarchive.com +// @connect archiveofsins.com +// @connect api.clyp.it +// @connect api.dailymotion.com +// @connect api.github.com +// @connect soundcloud.com +// @connect vimeo.com +// @connect www.googleapis.com // @connect * // @grant GM_getValue // @grant GM_setValue diff --git a/builds/4chan-X-beta.user.js b/builds/4chan-X-beta.user.js index ac119b68e..86e9d8c33 100644 --- a/builds/4chan-X-beta.user.js +++ b/builds/4chan-X-beta.user.js @@ -1,6 +1,6 @@ // ==UserScript== // @name 4chan X beta -// @version 1.14.2.1 +// @version 1.14.3.0 // @minGMVer 1.14 // @minFFVer 26 // @namespace 4chan-X @@ -38,6 +38,24 @@ // @exclude https://www.4chan.org/donate?* // @connect 4chan.org // @connect 4cdn.org +// @connect mayhemydg.github.io +// @connect archive.4plebs.org +// @connect archive.nyafuu.org +// @connect archive.rebeccablacktech.com +// @connect warosu.org +// @connect desuarchive.org +// @connect boards.fireden.net +// @connect arch.b4k.co +// @connect archive.b-stats.org +// @connect archived.moe +// @connect thebarchive.com +// @connect archiveofsins.com +// @connect api.clyp.it +// @connect api.dailymotion.com +// @connect api.github.com +// @connect soundcloud.com +// @connect vimeo.com +// @connect www.googleapis.com // @connect * // @grant GM_getValue // @grant GM_setValue @@ -157,7 +175,7 @@ docSet = function() { }; g = { - VERSION: '1.14.2.1', + VERSION: '1.14.3.0', NAMESPACE: '4chan X.', boards: {} }; @@ -5361,12 +5379,56 @@ CrossOrigin = (function() { }); }, json: (function() { - var callbacks, responses; + var callbacks, failure, results, success; callbacks = {}; - responses = {}; - return function(url, cb) { - if (responses[url]) { - cb(responses[url]); + results = {}; + success = function(url, result) { + var cb, j, len, ref; + ref = callbacks[url]; + for (j = 0, len = ref.length; j < len; j++) { + cb = ref[j]; + $.queueTask(function() { + return cb.call(result); + }); + } + delete callbacks[url]; + return results[url] = result; + }; + failure = function(url) { + var cb, j, len, ref; + ref = callbacks[url]; + for (j = 0, len = ref.length; j < len; j++) { + cb = ref[j]; + $.queueTask(function() { + return cb.call({}); + }); + } + return delete callbacks[url]; + }; + return function(url, cb, bypassCache) { + var req; + if (!(((typeof GM !== "undefined" && GM !== null ? GM.xmlHttpRequest : void 0) != null) || (typeof GM_xmlhttpRequest !== "undefined" && GM_xmlhttpRequest !== null))) { + if (bypassCache) { + $.cleanCache(function(url2) { + return url2 === url; + }); + } + if ((req = $.cache(url, cb, { + responseType: 'json' + }))) { + $.on(req, 'abort error', function() { + return cb.call({}); + }); + } else { + cb.call({}); + } + return; + } + if (bypassCache) { + delete results[url]; + } + if (results[url]) { + cb.call(results[url]); return; } if (callbacks[url]) { @@ -5378,21 +5440,24 @@ CrossOrigin = (function() { method: "GET", url: url + '', onload: function(xhr) { - var j, len, ref, response; - response = JSON.parse(xhr.responseText); - ref = callbacks[url]; - for (j = 0, len = ref.length; j < len; j++) { - cb = ref[j]; - cb(response); + var response, status, statusText; + status = xhr.status, statusText = xhr.statusText; + try { + response = JSON.parse(xhr.responseText); + return success(url, { + status: status, + statusText: statusText, + response: response + }); + } catch (_error) { + return failure(url); } - delete callbacks[url]; - return responses[url] = response; }, onerror: function() { - return delete callbacks[url]; + return failure(url); }, onabort: function() { - return delete callbacks[url]; + return failure(url); } }); }; @@ -6024,7 +6089,7 @@ Fetcher = (function() { }; Fetcher.prototype.archivedPost = function() { - var archive, url; + var archive, encryptionOK, that, url; if (!Conf['Resurrect Quotes']) { return false; } @@ -6035,33 +6100,23 @@ Fetcher = (function() { return false; } archive = Redirect.data.post[this.boardID]; - if (/^https:\/\//.test(url) || location.protocol === 'http:') { - $.cache(url, (function(_this) { - return function(e) { - return _this.parseArchivedPost(e.target.response, url, archive); - }; - })(this), { - responseType: 'json', - withCredentials: archive.withCredentials - }); - return true; - } else if (Conf['Exempt Archives from Encryption']) { - CrossOrigin.json(url, (function(_this) { - return function(response) { - var key, media, ref; - media = response.media; - if (media) { - for (key in media) { - if (/_link$/.test(key)) { - if (!((ref = media[key]) != null ? ref.match(/^http:\/\//) : void 0)) { - delete media[key]; - } + encryptionOK = /^https:\/\//.test(url) || location.protocol === 'http:'; + if (encryptionOK || Conf['Exempt Archives from Encryption']) { + that = this; + CrossOrigin.json(url, function() { + var key, media, ref, ref1; + if (!encryptionOK && ((ref = this.response) != null ? ref.media : void 0)) { + media = this.response.media; + for (key in media) { + if (/_link$/.test(key)) { + if (!((ref1 = media[key]) != null ? ref1.match(/^http:\/\//) : void 0)) { + delete media[key]; } } } - return _this.parseArchivedPost(response, url, archive); - }; - })(this)); + } + return that.parseArchivedPost(this.response, url, archive); + }); return true; } return false; @@ -7568,7 +7623,7 @@ Redirect = (function() { return Redirect.data = o; }, update: function(cb) { - var i, j, k, len, len1, load, nloaded, ref, ref1, responses, url, urls; + var err, fail, i, j, k, len, len1, load, nloaded, ref, ref1, response, responses, url, urls; urls = []; responses = []; nloaded = 0; @@ -7583,21 +7638,16 @@ Redirect = (function() { urls.push(url); } } + fail = function(url, action, msg) { + return new Notice('warning', "Error " + action + " archive data from\n" + url + "\n" + msg, 20); + }; load = function(i) { return function() { - var err, fail, response; - fail = function(action, msg) { - return new Notice('warning', "Error " + action + " archive data from\n" + urls[i] + "\n" + msg, 20); - }; + var response; if (this.status !== 200) { - return fail('fetching', (this.status ? "Error " + this.statusText + " (" + this.status + ")" : 'Connection Error')); - } - try { - response = JSON.parse(this.response); - } catch (_error) { - err = _error; - return fail('parsing', err.message); + return fail(urls[i], 'fetching', (this.status ? "Error " + this.statusText + " (" + this.status + ")" : 'Connection Error')); } + response = this.response; if (!(response instanceof Array)) { response = [response]; } @@ -7612,15 +7662,19 @@ Redirect = (function() { for (i = k = 0, len1 = urls.length; k < len1; i = ++k) { url = urls[i]; if ((ref1 = url[0]) === '[' || ref1 === '{') { + try { + response = JSON.parse(url); + } catch (_error) { + err = _error; + fail(url, 'parsing', err.message); + continue; + } load(i).call({ status: 200, - response: url + response: response }); } else { - $.ajax(url, { - responseType: 'text', - onloadend: load(i) - }); + CrossOrigin.json(url, load(i), true); } } } else { @@ -15022,19 +15076,13 @@ Embedding = (function() { return Embedding.flushTitles(service); } } else { - if (!$.cache(service.api(uid), (function() { + return CrossOrigin.json(service.api(uid), (function() { return Embedding.cb.title(this, data); - }), { - responseType: 'json' - })) { - return $.extend(link, { - innerHTML: "[" + E(key) + "] Title Link Blocked (are you using NoScript?)" - }); - } + })); } }, flushTitles: function(service) { - var cb, data, j, len, queue; + var cb, data, queue; queue = service.queue; if (!(queue != null ? queue.length : void 0)) { return; @@ -15047,7 +15095,7 @@ Embedding = (function() { Embedding.cb.title(this, data); } }; - if (!$.cache(service.api((function() { + return CrossOrigin.json(service.api((function() { var j, len, results; results = []; for (j = 0, len = queue.length; j < len; j++) { @@ -15055,16 +15103,7 @@ Embedding = (function() { results.push(data.uid); } return results; - })()), cb, { - responseType: 'json' - })) { - for (j = 0, len = queue.length; j < len; j++) { - data = queue[j]; - $.extend(data.link, { - innerHTML: "[" + E(data.key) + "] Title Link Blocked (are you using NoScript?)" - }); - } - } + })()), cb); }, preview: function(data) { var key, link, service, uid; @@ -15132,6 +15171,9 @@ Embedding = (function() { }, title: function(req, data) { var base1, j, k, key, len, len1, link, link2, options, post, post2, ref, ref1, service, status, text, uid; + if (!req.status) { + return; + } key = data.key, uid = data.uid, options = data.options, link = data.link, post = data.post; status = req.status; service = Embedding.types[key].title; @@ -15275,18 +15317,15 @@ Embedding = (function() { hidden: true, id: "gist-embed-" + (counter++) }); - $.ajax("https://api.github.com/gists/" + a.dataset.uid, { - responseType: 'json', - onload: function() { - el.textContent = Object.values(this.response.files)[0].content; - el.className = 'prettyprint'; - $.global(function() { - return typeof window.prettyPrint === "function" ? window.prettyPrint((function() {}), document.getElementById(document.currentScript.dataset.id).parentNode) : void 0; - }, { - id: el.id - }); - return el.hidden = false; - } + CrossOrigin.json("https://api.github.com/gists/" + a.dataset.uid, function() { + el.textContent = Object.values(this.response.files)[0].content; + el.className = 'prettyprint'; + $.global(function() { + return typeof window.prettyPrint === "function" ? window.prettyPrint((function() {}), document.getElementById(document.currentScript.dataset.id).parentNode) : void 0; + }, { + id: el.id + }); + return el.hidden = false; }); return el; }; diff --git a/builds/4chan-X-noupdate.crx b/builds/4chan-X-noupdate.crx index e2eda2ea9..537b51b2f 100644 Binary files a/builds/4chan-X-noupdate.crx and b/builds/4chan-X-noupdate.crx differ diff --git a/builds/4chan-X-noupdate.user.js b/builds/4chan-X-noupdate.user.js index bb02c1909..8c4618260 100644 --- a/builds/4chan-X-noupdate.user.js +++ b/builds/4chan-X-noupdate.user.js @@ -1,6 +1,6 @@ // ==UserScript== // @name 4chan X -// @version 1.14.2.1 +// @version 1.14.3.0 // @minGMVer 1.14 // @minFFVer 26 // @namespace 4chan-X @@ -38,6 +38,24 @@ // @exclude https://www.4chan.org/donate?* // @connect 4chan.org // @connect 4cdn.org +// @connect mayhemydg.github.io +// @connect archive.4plebs.org +// @connect archive.nyafuu.org +// @connect archive.rebeccablacktech.com +// @connect warosu.org +// @connect desuarchive.org +// @connect boards.fireden.net +// @connect arch.b4k.co +// @connect archive.b-stats.org +// @connect archived.moe +// @connect thebarchive.com +// @connect archiveofsins.com +// @connect api.clyp.it +// @connect api.dailymotion.com +// @connect api.github.com +// @connect soundcloud.com +// @connect vimeo.com +// @connect www.googleapis.com // @connect * // @grant GM_getValue // @grant GM_setValue @@ -157,7 +175,7 @@ docSet = function() { }; g = { - VERSION: '1.14.2.1', + VERSION: '1.14.3.0', NAMESPACE: '4chan X.', boards: {} }; @@ -5361,12 +5379,56 @@ CrossOrigin = (function() { }); }, json: (function() { - var callbacks, responses; + var callbacks, failure, results, success; callbacks = {}; - responses = {}; - return function(url, cb) { - if (responses[url]) { - cb(responses[url]); + results = {}; + success = function(url, result) { + var cb, j, len, ref; + ref = callbacks[url]; + for (j = 0, len = ref.length; j < len; j++) { + cb = ref[j]; + $.queueTask(function() { + return cb.call(result); + }); + } + delete callbacks[url]; + return results[url] = result; + }; + failure = function(url) { + var cb, j, len, ref; + ref = callbacks[url]; + for (j = 0, len = ref.length; j < len; j++) { + cb = ref[j]; + $.queueTask(function() { + return cb.call({}); + }); + } + return delete callbacks[url]; + }; + return function(url, cb, bypassCache) { + var req; + if (!(((typeof GM !== "undefined" && GM !== null ? GM.xmlHttpRequest : void 0) != null) || (typeof GM_xmlhttpRequest !== "undefined" && GM_xmlhttpRequest !== null))) { + if (bypassCache) { + $.cleanCache(function(url2) { + return url2 === url; + }); + } + if ((req = $.cache(url, cb, { + responseType: 'json' + }))) { + $.on(req, 'abort error', function() { + return cb.call({}); + }); + } else { + cb.call({}); + } + return; + } + if (bypassCache) { + delete results[url]; + } + if (results[url]) { + cb.call(results[url]); return; } if (callbacks[url]) { @@ -5378,21 +5440,24 @@ CrossOrigin = (function() { method: "GET", url: url + '', onload: function(xhr) { - var j, len, ref, response; - response = JSON.parse(xhr.responseText); - ref = callbacks[url]; - for (j = 0, len = ref.length; j < len; j++) { - cb = ref[j]; - cb(response); + var response, status, statusText; + status = xhr.status, statusText = xhr.statusText; + try { + response = JSON.parse(xhr.responseText); + return success(url, { + status: status, + statusText: statusText, + response: response + }); + } catch (_error) { + return failure(url); } - delete callbacks[url]; - return responses[url] = response; }, onerror: function() { - return delete callbacks[url]; + return failure(url); }, onabort: function() { - return delete callbacks[url]; + return failure(url); } }); }; @@ -6024,7 +6089,7 @@ Fetcher = (function() { }; Fetcher.prototype.archivedPost = function() { - var archive, url; + var archive, encryptionOK, that, url; if (!Conf['Resurrect Quotes']) { return false; } @@ -6035,33 +6100,23 @@ Fetcher = (function() { return false; } archive = Redirect.data.post[this.boardID]; - if (/^https:\/\//.test(url) || location.protocol === 'http:') { - $.cache(url, (function(_this) { - return function(e) { - return _this.parseArchivedPost(e.target.response, url, archive); - }; - })(this), { - responseType: 'json', - withCredentials: archive.withCredentials - }); - return true; - } else if (Conf['Exempt Archives from Encryption']) { - CrossOrigin.json(url, (function(_this) { - return function(response) { - var key, media, ref; - media = response.media; - if (media) { - for (key in media) { - if (/_link$/.test(key)) { - if (!((ref = media[key]) != null ? ref.match(/^http:\/\//) : void 0)) { - delete media[key]; - } + encryptionOK = /^https:\/\//.test(url) || location.protocol === 'http:'; + if (encryptionOK || Conf['Exempt Archives from Encryption']) { + that = this; + CrossOrigin.json(url, function() { + var key, media, ref, ref1; + if (!encryptionOK && ((ref = this.response) != null ? ref.media : void 0)) { + media = this.response.media; + for (key in media) { + if (/_link$/.test(key)) { + if (!((ref1 = media[key]) != null ? ref1.match(/^http:\/\//) : void 0)) { + delete media[key]; } } } - return _this.parseArchivedPost(response, url, archive); - }; - })(this)); + } + return that.parseArchivedPost(this.response, url, archive); + }); return true; } return false; @@ -7568,7 +7623,7 @@ Redirect = (function() { return Redirect.data = o; }, update: function(cb) { - var i, j, k, len, len1, load, nloaded, ref, ref1, responses, url, urls; + var err, fail, i, j, k, len, len1, load, nloaded, ref, ref1, response, responses, url, urls; urls = []; responses = []; nloaded = 0; @@ -7583,21 +7638,16 @@ Redirect = (function() { urls.push(url); } } + fail = function(url, action, msg) { + return new Notice('warning', "Error " + action + " archive data from\n" + url + "\n" + msg, 20); + }; load = function(i) { return function() { - var err, fail, response; - fail = function(action, msg) { - return new Notice('warning', "Error " + action + " archive data from\n" + urls[i] + "\n" + msg, 20); - }; + var response; if (this.status !== 200) { - return fail('fetching', (this.status ? "Error " + this.statusText + " (" + this.status + ")" : 'Connection Error')); - } - try { - response = JSON.parse(this.response); - } catch (_error) { - err = _error; - return fail('parsing', err.message); + return fail(urls[i], 'fetching', (this.status ? "Error " + this.statusText + " (" + this.status + ")" : 'Connection Error')); } + response = this.response; if (!(response instanceof Array)) { response = [response]; } @@ -7612,15 +7662,19 @@ Redirect = (function() { for (i = k = 0, len1 = urls.length; k < len1; i = ++k) { url = urls[i]; if ((ref1 = url[0]) === '[' || ref1 === '{') { + try { + response = JSON.parse(url); + } catch (_error) { + err = _error; + fail(url, 'parsing', err.message); + continue; + } load(i).call({ status: 200, - response: url + response: response }); } else { - $.ajax(url, { - responseType: 'text', - onloadend: load(i) - }); + CrossOrigin.json(url, load(i), true); } } } else { @@ -15022,19 +15076,13 @@ Embedding = (function() { return Embedding.flushTitles(service); } } else { - if (!$.cache(service.api(uid), (function() { + return CrossOrigin.json(service.api(uid), (function() { return Embedding.cb.title(this, data); - }), { - responseType: 'json' - })) { - return $.extend(link, { - innerHTML: "[" + E(key) + "] Title Link Blocked (are you using NoScript?)" - }); - } + })); } }, flushTitles: function(service) { - var cb, data, j, len, queue; + var cb, data, queue; queue = service.queue; if (!(queue != null ? queue.length : void 0)) { return; @@ -15047,7 +15095,7 @@ Embedding = (function() { Embedding.cb.title(this, data); } }; - if (!$.cache(service.api((function() { + return CrossOrigin.json(service.api((function() { var j, len, results; results = []; for (j = 0, len = queue.length; j < len; j++) { @@ -15055,16 +15103,7 @@ Embedding = (function() { results.push(data.uid); } return results; - })()), cb, { - responseType: 'json' - })) { - for (j = 0, len = queue.length; j < len; j++) { - data = queue[j]; - $.extend(data.link, { - innerHTML: "[" + E(data.key) + "] Title Link Blocked (are you using NoScript?)" - }); - } - } + })()), cb); }, preview: function(data) { var key, link, service, uid; @@ -15132,6 +15171,9 @@ Embedding = (function() { }, title: function(req, data) { var base1, j, k, key, len, len1, link, link2, options, post, post2, ref, ref1, service, status, text, uid; + if (!req.status) { + return; + } key = data.key, uid = data.uid, options = data.options, link = data.link, post = data.post; status = req.status; service = Embedding.types[key].title; @@ -15275,18 +15317,15 @@ Embedding = (function() { hidden: true, id: "gist-embed-" + (counter++) }); - $.ajax("https://api.github.com/gists/" + a.dataset.uid, { - responseType: 'json', - onload: function() { - el.textContent = Object.values(this.response.files)[0].content; - el.className = 'prettyprint'; - $.global(function() { - return typeof window.prettyPrint === "function" ? window.prettyPrint((function() {}), document.getElementById(document.currentScript.dataset.id).parentNode) : void 0; - }, { - id: el.id - }); - return el.hidden = false; - } + CrossOrigin.json("https://api.github.com/gists/" + a.dataset.uid, function() { + el.textContent = Object.values(this.response.files)[0].content; + el.className = 'prettyprint'; + $.global(function() { + return typeof window.prettyPrint === "function" ? window.prettyPrint((function() {}), document.getElementById(document.currentScript.dataset.id).parentNode) : void 0; + }, { + id: el.id + }); + return el.hidden = false; }); return el; }; diff --git a/builds/4chan-X.crx b/builds/4chan-X.crx index 5d2abb73d..3cf8f7f0b 100644 Binary files a/builds/4chan-X.crx and b/builds/4chan-X.crx differ diff --git a/builds/4chan-X.meta.js b/builds/4chan-X.meta.js index bfc181a2f..0a556a782 100644 --- a/builds/4chan-X.meta.js +++ b/builds/4chan-X.meta.js @@ -1,6 +1,6 @@ // ==UserScript== // @name 4chan X -// @version 1.14.2.1 +// @version 1.14.3.0 // @minGMVer 1.14 // @minFFVer 26 // @namespace 4chan-X @@ -38,6 +38,24 @@ // @exclude https://www.4chan.org/donate?* // @connect 4chan.org // @connect 4cdn.org +// @connect mayhemydg.github.io +// @connect archive.4plebs.org +// @connect archive.nyafuu.org +// @connect archive.rebeccablacktech.com +// @connect warosu.org +// @connect desuarchive.org +// @connect boards.fireden.net +// @connect arch.b4k.co +// @connect archive.b-stats.org +// @connect archived.moe +// @connect thebarchive.com +// @connect archiveofsins.com +// @connect api.clyp.it +// @connect api.dailymotion.com +// @connect api.github.com +// @connect soundcloud.com +// @connect vimeo.com +// @connect www.googleapis.com // @connect * // @grant GM_getValue // @grant GM_setValue diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index a7d2472ea..ae648e8e2 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -1,6 +1,6 @@ // ==UserScript== // @name 4chan X -// @version 1.14.2.1 +// @version 1.14.3.0 // @minGMVer 1.14 // @minFFVer 26 // @namespace 4chan-X @@ -38,6 +38,24 @@ // @exclude https://www.4chan.org/donate?* // @connect 4chan.org // @connect 4cdn.org +// @connect mayhemydg.github.io +// @connect archive.4plebs.org +// @connect archive.nyafuu.org +// @connect archive.rebeccablacktech.com +// @connect warosu.org +// @connect desuarchive.org +// @connect boards.fireden.net +// @connect arch.b4k.co +// @connect archive.b-stats.org +// @connect archived.moe +// @connect thebarchive.com +// @connect archiveofsins.com +// @connect api.clyp.it +// @connect api.dailymotion.com +// @connect api.github.com +// @connect soundcloud.com +// @connect vimeo.com +// @connect www.googleapis.com // @connect * // @grant GM_getValue // @grant GM_setValue @@ -157,7 +175,7 @@ docSet = function() { }; g = { - VERSION: '1.14.2.1', + VERSION: '1.14.3.0', NAMESPACE: '4chan X.', boards: {} }; @@ -5361,12 +5379,56 @@ CrossOrigin = (function() { }); }, json: (function() { - var callbacks, responses; + var callbacks, failure, results, success; callbacks = {}; - responses = {}; - return function(url, cb) { - if (responses[url]) { - cb(responses[url]); + results = {}; + success = function(url, result) { + var cb, j, len, ref; + ref = callbacks[url]; + for (j = 0, len = ref.length; j < len; j++) { + cb = ref[j]; + $.queueTask(function() { + return cb.call(result); + }); + } + delete callbacks[url]; + return results[url] = result; + }; + failure = function(url) { + var cb, j, len, ref; + ref = callbacks[url]; + for (j = 0, len = ref.length; j < len; j++) { + cb = ref[j]; + $.queueTask(function() { + return cb.call({}); + }); + } + return delete callbacks[url]; + }; + return function(url, cb, bypassCache) { + var req; + if (!(((typeof GM !== "undefined" && GM !== null ? GM.xmlHttpRequest : void 0) != null) || (typeof GM_xmlhttpRequest !== "undefined" && GM_xmlhttpRequest !== null))) { + if (bypassCache) { + $.cleanCache(function(url2) { + return url2 === url; + }); + } + if ((req = $.cache(url, cb, { + responseType: 'json' + }))) { + $.on(req, 'abort error', function() { + return cb.call({}); + }); + } else { + cb.call({}); + } + return; + } + if (bypassCache) { + delete results[url]; + } + if (results[url]) { + cb.call(results[url]); return; } if (callbacks[url]) { @@ -5378,21 +5440,24 @@ CrossOrigin = (function() { method: "GET", url: url + '', onload: function(xhr) { - var j, len, ref, response; - response = JSON.parse(xhr.responseText); - ref = callbacks[url]; - for (j = 0, len = ref.length; j < len; j++) { - cb = ref[j]; - cb(response); + var response, status, statusText; + status = xhr.status, statusText = xhr.statusText; + try { + response = JSON.parse(xhr.responseText); + return success(url, { + status: status, + statusText: statusText, + response: response + }); + } catch (_error) { + return failure(url); } - delete callbacks[url]; - return responses[url] = response; }, onerror: function() { - return delete callbacks[url]; + return failure(url); }, onabort: function() { - return delete callbacks[url]; + return failure(url); } }); }; @@ -6024,7 +6089,7 @@ Fetcher = (function() { }; Fetcher.prototype.archivedPost = function() { - var archive, url; + var archive, encryptionOK, that, url; if (!Conf['Resurrect Quotes']) { return false; } @@ -6035,33 +6100,23 @@ Fetcher = (function() { return false; } archive = Redirect.data.post[this.boardID]; - if (/^https:\/\//.test(url) || location.protocol === 'http:') { - $.cache(url, (function(_this) { - return function(e) { - return _this.parseArchivedPost(e.target.response, url, archive); - }; - })(this), { - responseType: 'json', - withCredentials: archive.withCredentials - }); - return true; - } else if (Conf['Exempt Archives from Encryption']) { - CrossOrigin.json(url, (function(_this) { - return function(response) { - var key, media, ref; - media = response.media; - if (media) { - for (key in media) { - if (/_link$/.test(key)) { - if (!((ref = media[key]) != null ? ref.match(/^http:\/\//) : void 0)) { - delete media[key]; - } + encryptionOK = /^https:\/\//.test(url) || location.protocol === 'http:'; + if (encryptionOK || Conf['Exempt Archives from Encryption']) { + that = this; + CrossOrigin.json(url, function() { + var key, media, ref, ref1; + if (!encryptionOK && ((ref = this.response) != null ? ref.media : void 0)) { + media = this.response.media; + for (key in media) { + if (/_link$/.test(key)) { + if (!((ref1 = media[key]) != null ? ref1.match(/^http:\/\//) : void 0)) { + delete media[key]; } } } - return _this.parseArchivedPost(response, url, archive); - }; - })(this)); + } + return that.parseArchivedPost(this.response, url, archive); + }); return true; } return false; @@ -7568,7 +7623,7 @@ Redirect = (function() { return Redirect.data = o; }, update: function(cb) { - var i, j, k, len, len1, load, nloaded, ref, ref1, responses, url, urls; + var err, fail, i, j, k, len, len1, load, nloaded, ref, ref1, response, responses, url, urls; urls = []; responses = []; nloaded = 0; @@ -7583,21 +7638,16 @@ Redirect = (function() { urls.push(url); } } + fail = function(url, action, msg) { + return new Notice('warning', "Error " + action + " archive data from\n" + url + "\n" + msg, 20); + }; load = function(i) { return function() { - var err, fail, response; - fail = function(action, msg) { - return new Notice('warning', "Error " + action + " archive data from\n" + urls[i] + "\n" + msg, 20); - }; + var response; if (this.status !== 200) { - return fail('fetching', (this.status ? "Error " + this.statusText + " (" + this.status + ")" : 'Connection Error')); - } - try { - response = JSON.parse(this.response); - } catch (_error) { - err = _error; - return fail('parsing', err.message); + return fail(urls[i], 'fetching', (this.status ? "Error " + this.statusText + " (" + this.status + ")" : 'Connection Error')); } + response = this.response; if (!(response instanceof Array)) { response = [response]; } @@ -7612,15 +7662,19 @@ Redirect = (function() { for (i = k = 0, len1 = urls.length; k < len1; i = ++k) { url = urls[i]; if ((ref1 = url[0]) === '[' || ref1 === '{') { + try { + response = JSON.parse(url); + } catch (_error) { + err = _error; + fail(url, 'parsing', err.message); + continue; + } load(i).call({ status: 200, - response: url + response: response }); } else { - $.ajax(url, { - responseType: 'text', - onloadend: load(i) - }); + CrossOrigin.json(url, load(i), true); } } } else { @@ -15022,19 +15076,13 @@ Embedding = (function() { return Embedding.flushTitles(service); } } else { - if (!$.cache(service.api(uid), (function() { + return CrossOrigin.json(service.api(uid), (function() { return Embedding.cb.title(this, data); - }), { - responseType: 'json' - })) { - return $.extend(link, { - innerHTML: "[" + E(key) + "] Title Link Blocked (are you using NoScript?)" - }); - } + })); } }, flushTitles: function(service) { - var cb, data, j, len, queue; + var cb, data, queue; queue = service.queue; if (!(queue != null ? queue.length : void 0)) { return; @@ -15047,7 +15095,7 @@ Embedding = (function() { Embedding.cb.title(this, data); } }; - if (!$.cache(service.api((function() { + return CrossOrigin.json(service.api((function() { var j, len, results; results = []; for (j = 0, len = queue.length; j < len; j++) { @@ -15055,16 +15103,7 @@ Embedding = (function() { results.push(data.uid); } return results; - })()), cb, { - responseType: 'json' - })) { - for (j = 0, len = queue.length; j < len; j++) { - data = queue[j]; - $.extend(data.link, { - innerHTML: "[" + E(data.key) + "] Title Link Blocked (are you using NoScript?)" - }); - } - } + })()), cb); }, preview: function(data) { var key, link, service, uid; @@ -15132,6 +15171,9 @@ Embedding = (function() { }, title: function(req, data) { var base1, j, k, key, len, len1, link, link2, options, post, post2, ref, ref1, service, status, text, uid; + if (!req.status) { + return; + } key = data.key, uid = data.uid, options = data.options, link = data.link, post = data.post; status = req.status; service = Embedding.types[key].title; @@ -15275,18 +15317,15 @@ Embedding = (function() { hidden: true, id: "gist-embed-" + (counter++) }); - $.ajax("https://api.github.com/gists/" + a.dataset.uid, { - responseType: 'json', - onload: function() { - el.textContent = Object.values(this.response.files)[0].content; - el.className = 'prettyprint'; - $.global(function() { - return typeof window.prettyPrint === "function" ? window.prettyPrint((function() {}), document.getElementById(document.currentScript.dataset.id).parentNode) : void 0; - }, { - id: el.id - }); - return el.hidden = false; - } + CrossOrigin.json("https://api.github.com/gists/" + a.dataset.uid, function() { + el.textContent = Object.values(this.response.files)[0].content; + el.className = 'prettyprint'; + $.global(function() { + return typeof window.prettyPrint === "function" ? window.prettyPrint((function() {}), document.getElementById(document.currentScript.dataset.id).parentNode) : void 0; + }, { + id: el.id + }); + return el.hidden = false; }); return el; }; diff --git a/builds/4chan-X.zip b/builds/4chan-X.zip index fa3cd5359..f6bd3b538 100644 Binary files a/builds/4chan-X.zip and b/builds/4chan-X.zip differ diff --git a/builds/updates-beta.json b/builds/updates-beta.json index 006643482..4950787b0 100644 --- a/builds/updates-beta.json +++ b/builds/updates-beta.json @@ -3,7 +3,7 @@ "4chan-x@4chan-x.net": { "updates": [ { - "version": "1.14.2.1", + "version": "1.14.3.0", "update_link": "https://www.4chan-x.net/builds/4chan-X-beta.crx" } ] diff --git a/builds/updates-beta.xml b/builds/updates-beta.xml index cc44abfb7..0f5bc33e4 100644 --- a/builds/updates-beta.xml +++ b/builds/updates-beta.xml @@ -1,7 +1,7 @@ - + diff --git a/builds/updates.json b/builds/updates.json index ae553c143..34ba27686 100644 --- a/builds/updates.json +++ b/builds/updates.json @@ -3,7 +3,7 @@ "4chan-x@4chan-x.net": { "updates": [ { - "version": "1.14.2.1", + "version": "1.14.3.0", "update_link": "https://www.4chan-x.net/builds/4chan-X.crx" } ] diff --git a/builds/updates.xml b/builds/updates.xml index 4f9f2fe64..4ad29f976 100644 --- a/builds/updates.xml +++ b/builds/updates.xml @@ -1,7 +1,7 @@ - + diff --git a/version.json b/version.json index 39fc6231c..267bdda04 100644 --- a/version.json +++ b/version.json @@ -1,4 +1,4 @@ { - "version": "1.14.2.1", - "date": "2018-06-22T06:12:54.498Z" + "version": "1.14.3.0", + "date": "2018-09-18T11:28:33.974Z" } \ No newline at end of file