diff --git a/CHANGELOG.md b/CHANGELOG.md index 147d979b4..8e4fceccd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +### v2.9.38 +*2014-10-27* + +- Security fixes. +- Update archives. + ### v2.9.37 *2014-10-01* diff --git a/LICENSE b/LICENSE index c131bb8c5..eeb4cc20d 100644 --- a/LICENSE +++ b/LICENSE @@ -1,5 +1,5 @@ /* -* appchan x - Version 2.9.37 - 2014-12-08 +* appchan x - Version 2.9.38 - 2014-12-08 * * Licensed under the MIT license. * https://github.com/zixaphir/appchan-x/blob/master/LICENSE diff --git a/builds/appchan-x.meta.js b/builds/appchan-x.meta.js index dab25ea59..fdbccdf5e 100644 --- a/builds/appchan-x.meta.js +++ b/builds/appchan-x.meta.js @@ -1,6 +1,6 @@ // ==UserScript== // @name appchan x -// @version 2.9.37 +// @version 2.9.38 // @minGMVer 1.14 // @minFFVer 26 // @namespace zixaphir diff --git a/builds/appchan-x.user.js b/builds/appchan-x.user.js index 5d979ee17..8eccab752 100644 --- a/builds/appchan-x.user.js +++ b/builds/appchan-x.user.js @@ -1,7 +1,7 @@ // Generated by CoffeeScript // ==UserScript== // @name appchan x -// @version 2.9.37 +// @version 2.9.38 // @minGMVer 1.14 // @minFFVer 26 // @namespace zixaphir @@ -28,7 +28,7 @@ // ==/UserScript== /* -* appchan x - Version 2.9.37 - 2014-12-08 +* appchan x - Version 2.9.38 - 2014-12-08 * * Licensed under the MIT license. * https://github.com/zixaphir/appchan-x/blob/master/LICENSE @@ -483,7 +483,7 @@ doc = d.documentElement; g = { - VERSION: '2.9.37', + VERSION: '2.9.38', NAMESPACE: 'appchan_x.', boards: {} }; @@ -7408,12 +7408,9 @@ QuoteBacklink = { init: function() { - var format; if (!Conf['Quote Backlinks']) { return; } - format = Conf['backlink'].replace(/%id/g, "' + id + '"); - this.funk = Function('id', "return '" + format + "'"); this.frag = $.nodes([ $.tn(' '), $.el('a', { className: 'backlink' @@ -7462,7 +7459,7 @@ _ref = this.nodes.backlinks; for (_i = 0, _len = _ref.length; _i < _len; _i++) { backlink = _ref[_i]; - QuoteMarkers.parseQuotelink(this, backlink, true, QuoteBacklink.funk(Get.postDataFromLink(backlink).postID)); + QuoteMarkers.parseQuotelink(this, backlink, true, Conf['backlink'].replace(/%id/g, Get.postDataFromLink(backlink).postID)); } return; } @@ -7485,7 +7482,7 @@ frag = QuoteBacklink.frag.cloneNode(true); a = frag.lastElementChild; a.href = Build.path(quoter.board.ID, quoter.thread.ID, quoter.ID); - a.textContent = text = QuoteBacklink.funk(quoter.ID); + a.textContent = text = Conf['backlink'].replace(/%id/g, quoter.ID); if (quoter.isDead) { $.addClass(a, 'deadlink'); } @@ -11397,7 +11394,7 @@ link = _ref[_i]; try { if (link[0] !== '#') { - links.push(this.createSauceLink(link.trim())); + links.push(link.trim()); } } catch (_error) { err = _error; @@ -11415,21 +11412,27 @@ cb: this.node }); }, - createSauceLink: function(link) { + createSauceLink: function(link, post, a) { var m, text; link = link.replace(/%(T?URL|MD5|board|name)/g, function(parameter) { var type; - return ((type = { - '%TURL': 'post.file.thumbURL', - '%URL': 'post.file.URL', - '%MD5': 'post.file.MD5', - '%board': 'post.board', - '%name': 'post.file.name' - }[parameter]) ? "' + encodeURIComponent(" + type + ") + '" : parameter); + if (type = { + '%TURL': post.file.thumbURL, + '%URL': post.file.URL, + '%MD5': post.file.MD5, + '%board': post.board, + '%name': post.file.name + }[parameter]) { + return encodeURIComponent(type); + } else { + return parameter; + } }); text = (m = link.match(/;text:(.+)$/)) ? m[1] : link.match(/(\w+)\.\w+\//)[1]; link = link.replace(/;text:.+$/, ''); - return Function('post', 'a', "a.href = '" + link + "';\na.textContent = '" + text + "';\nreturn a;"); + a.href = link; + a.textContent = text; + return a; }, node: function() { var link, nodes, _i, _len, _ref; @@ -11440,7 +11443,7 @@ _ref = Sauce.links; for (_i = 0, _len = _ref.length; _i < _len; _i++) { link = _ref[_i]; - nodes.push($.tn('\u00A0'), link(this, Sauce.link.cloneNode(true))); + nodes.push($.tn('\u00A0'), Sauce.createSauceLink(link, this, Sauce.link.cloneNode(true))); } return $.add(this.file.text, nodes); } @@ -13230,7 +13233,7 @@ } return Redirect.data = o; }, - archives: [{"uid":0,"name":"Moe","domain":"archive.moe","http":true,"https":true,"software":"foolfuuka","boards":["a","biz","c","co","diy","gd","int","jp","m","out","po","sci","sp","tg","tv","v","vg","vp","vr","wsg"],"files":["a","biz","c","co","diy","gd","jp","m","po","sci","tg","v","vg","vp","vr","wsg"]},{"uid":1,"name":"NSFW Moe","domain":"nsfw.archive.moe","http":true,"https":true,"software":"foolfuuka","boards":["h","u"],"files":["h","u"]},{"uid":3,"name":"4plebs Archive","domain":"archive.4plebs.org","http":true,"https":true,"software":"foolfuuka","boards":["adv","f","hr","o","pol","s4s","tg","trv","tv","x"],"files":["adv","f","hr","o","pol","s4s","tg","trv","tv","x"]},{"uid":5,"name":"Love is Over","domain":"archive.loveisover.me","http":true,"https":true,"software":"foolfuuka","boards":["c","d","e","i","lgbt","t","u","w","wg"],"files":["c","d","e","i","lgbt","t","u","w","wg"]},{"uid":8,"name":"Rebecca Black Tech","domain":"archive.rebeccablacktech.com","http":false,"https":true,"software":"fuuka","boards":["cgl","g","mu","w"],"files":["cgl","g","mu","w"]},{"uid":9,"name":"Heinessen","domain":"archive.heinessen.com","http":true,"https":false,"software":"fuuka","boards":["an","fit","k","mlp","r9k","toy"],"files":["an","fit","k","mlp","r9k","toy"]},{"uid":10,"name":"warosu","domain":"warosu.org","http":false,"https":true,"software":"fuuka","boards":["3","biz","cgl","ck","diy","fa","g","ic","jp","lit","sci","tg","vr"],"files":["3","biz","cgl","ck","diy","fa","ic","jp","lit","sci","tg","vr"]},{"uid":15,"name":"fgts","domain":"fgts.jp","http":true,"https":true,"software":"foolfuuka","boards":["asp","cm","h","hc","hm","n","p","r","s","soc","y"],"files":["asp","cm","h","hc","hm","n","p","r","s","soc","y"]},{"uid":16,"name":"maware","domain":"archive.mawa.re","http":true,"https":false,"software":"foolfuuka","boards":["t"],"files":["t"]}], + archives: [{"uid":0,"name":"Moe","domain":"archive.moe","http":true,"https":true,"software":"foolfuuka","boards":["a","biz","c","co","diy","gd","int","jp","m","out","po","sci","sp","tg","tv","v","vg","vp","vr","wsg"],"files":["a","biz","c","co","diy","gd","jp","m","po","sci","tg","v","vg","vp","vr","wsg"]},{"uid":1,"name":"NSFW Moe","domain":"nsfw.archive.moe","http":true,"https":true,"software":"foolfuuka","boards":["h","u"],"files":["h","u"]},{"uid":3,"name":"4plebs Archive","domain":"archive.4plebs.org","http":true,"https":true,"software":"foolfuuka","boards":["adv","f","hr","o","pol","s4s","tg","trv","tv","x"],"files":["adv","f","hr","o","pol","s4s","tg","trv","tv","x"]},{"uid":5,"name":"Love is Over","domain":"archive.loveisover.me","http":true,"https":true,"software":"foolfuuka","boards":["c","d","e","i","lgbt","t","u","w","wg"],"files":["c","d","e","i","lgbt","t","u","w","wg"]},{"uid":8,"name":"Rebecca Black Tech","domain":"archive.rebeccablacktech.com","http":false,"https":true,"software":"fuuka","boards":["cgl","g","mu","w"],"files":["cgl","g","mu","w"]},{"uid":9,"name":"Heinessen","domain":"archive.heinessen.com","http":true,"https":false,"software":"fuuka","boards":["an","fit","k","mlp","r9k","toy"],"files":["an","fit","k","mlp","r9k","toy"]},{"uid":10,"name":"warosu","domain":"warosu.org","http":false,"https":true,"software":"fuuka","boards":["3","biz","cgl","ck","diy","fa","g","ic","jp","lit","sci","tg","vr"],"files":["3","biz","cgl","ck","diy","fa","ic","jp","lit","sci","tg","vr"]},{"uid":15,"name":"fgts","domain":"fgts.jp","http":true,"https":true,"software":"foolfuuka","boards":["asp","cm","h","hc","hm","n","p","r","s","soc","y"],"files":["asp","cm","h","hc","hm","n","p","r","s","soc","y"]},{"uid":16,"name":"maware","domain":"archive.mawa.re","http":true,"https":false,"software":"foolfuuka","boards":["t"],"files":["t"]},{"uid":17,"name":"imcute","domain":"imcute.yt","http":true,"https":false,"software":"foolfuuka","boards":["gif","jp","vg"],"files":["gif","jp","vg"]}], to: function(dest, data) { var archive; archive = (dest === 'search' || dest === 'board' ? Redirect.data.thread : Redirect.data[dest])[data.boardID]; @@ -13368,6 +13371,15 @@ "software": "foolfuuka", "boards": ["t"], "files": ["t"] + }, { + "uid": 17, + "name": "imcute", + "domain": "imcute.yt", + "http": true, + "https": false, + "software": "foolfuuka", + "boards": ["gif", "jp", "vg"], + "files": ["gif", "jp", "vg"] } ]; @@ -15311,7 +15323,6 @@ if (!Conf['File Info Formatting']) { return; } - this.funk = this.createFunc(Conf['fileInfo']); return Post.callbacks.push({ name: 'File Info Formatting', cb: this.node @@ -15321,18 +15332,16 @@ if (!this.file || this.isClone) { return; } - return this.file.text.innerHTML = "" + (FileInfo.funk(FileInfo, this)) + ""; + return this.file.text.innerHTML = "" + (FileInfo.format(Conf['fileInfo'], this)) + ""; }, - createFunc: function(format) { - var code; - code = format.replace(/%(.)/g, function(s, c) { + format: function(formatString, post) { + return formatString.replace(/%([A-Za-z])/g, function(s, c) { if (c in FileInfo.formatters) { - return "' + FileInfo.formatters." + c + ".call(post) + '"; + return FileInfo.formatters[c].call(post); } else { return s; } }); - return Function('FileInfo', 'post', "return '" + code + "'"); }, convertUnit: function(size, unit) { var i; @@ -16167,7 +16176,6 @@ if (!Conf['Time Formatting']) { return; } - this.funk = this.createFunc(Conf['time']); return Post.callbacks.push({ name: 'Time Formatting', cb: this.node @@ -16177,18 +16185,16 @@ if (this.isClone) { return; } - return this.nodes.date.textContent = Time.funk(Time, this.info.date); + return this.nodes.date.textContent = Time.format(Conf['time'], this.info.date); }, - createFunc: function(format) { - var code; - code = format.replace(/%([A-Za-z])/g, function(s, c) { + format: function(formatString, date) { + return formatString.replace(/%([A-Za-z])/g, function(s, c) { if (c in Time.formatters) { - return "' + Time.formatters." + c + ".call(date) + '"; + return Time.formatters[c].call(date); } else { return s; } }); - return Function('Time', 'date', "return '" + code + "'"); }, day: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], month: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'], @@ -17147,15 +17153,13 @@ return Header.generateBoardList(this.value); }, time: function() { - var funk; - funk = Time.createFunc(this.value); - return this.nextElementSibling.textContent = funk(Time, new Date()); + return this.nextElementSibling.textContent = Time.format(this.value, new Date()); }, backlink: function() { - return this.nextElementSibling.textContent = this.value.replace(/%id/, '123456789'); + return this.nextElementSibling.textContent = this.value.replace(/%id/g, '123456789'); }, fileInfo: function() { - var data, funk; + var data; data = { isReply: true, file: { @@ -17169,8 +17173,7 @@ isSpoiler: true } }; - funk = FileInfo.createFunc(this.value); - return this.nextElementSibling.innerHTML = funk(FileInfo, data); + return this.nextElementSibling.innerHTML = FileInfo.format(this.value, data); }, favicon: function() { Favicon.init(); diff --git a/builds/appchan-x.zip b/builds/appchan-x.zip index f15a8b4d6..a495f37ee 100644 Binary files a/builds/appchan-x.zip and b/builds/appchan-x.zip differ diff --git a/builds/crx/manifest.json b/builds/crx/manifest.json index ddf69000e..00d289754 100644 --- a/builds/crx/manifest.json +++ b/builds/crx/manifest.json @@ -1,6 +1,6 @@ { "name": "appchan x", - "version": "2.9.37", + "version": "2.9.38", "manifest_version": 2, "description": "The most comprehensive 4chan userscript.", "icons": { diff --git a/builds/crx/script.js b/builds/crx/script.js index 4ca1c0f22..415ef2761 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -1,6 +1,6 @@ // Generated by CoffeeScript /* -* appchan x - Version 2.9.37 - 2014-12-08 +* appchan x - Version 2.9.38 - 2014-12-08 * * Licensed under the MIT license. * https://github.com/zixaphir/appchan-x/blob/master/LICENSE @@ -454,7 +454,7 @@ doc = d.documentElement; g = { - VERSION: '2.9.37', + VERSION: '2.9.38', NAMESPACE: 'appchan_x.', boards: {} }; @@ -7429,12 +7429,9 @@ QuoteBacklink = { init: function() { - var format; if (!Conf['Quote Backlinks']) { return; } - format = Conf['backlink'].replace(/%id/g, "' + id + '"); - this.funk = Function('id', "return '" + format + "'"); this.frag = $.nodes([ $.tn(' '), $.el('a', { className: 'backlink' @@ -7483,7 +7480,7 @@ _ref = this.nodes.backlinks; for (_i = 0, _len = _ref.length; _i < _len; _i++) { backlink = _ref[_i]; - QuoteMarkers.parseQuotelink(this, backlink, true, QuoteBacklink.funk(Get.postDataFromLink(backlink).postID)); + QuoteMarkers.parseQuotelink(this, backlink, true, Conf['backlink'].replace(/%id/g, Get.postDataFromLink(backlink).postID)); } return; } @@ -7506,7 +7503,7 @@ frag = QuoteBacklink.frag.cloneNode(true); a = frag.lastElementChild; a.href = Build.path(quoter.board.ID, quoter.thread.ID, quoter.ID); - a.textContent = text = QuoteBacklink.funk(quoter.ID); + a.textContent = text = Conf['backlink'].replace(/%id/g, quoter.ID); if (quoter.isDead) { $.addClass(a, 'deadlink'); } @@ -11380,7 +11377,7 @@ link = _ref[_i]; try { if (link[0] !== '#') { - links.push(this.createSauceLink(link.trim())); + links.push(link.trim()); } } catch (_error) { err = _error; @@ -11398,21 +11395,27 @@ cb: this.node }); }, - createSauceLink: function(link) { + createSauceLink: function(link, post, a) { var m, text; link = link.replace(/%(T?URL|MD5|board|name)/g, function(parameter) { var type; - return ((type = { - '%TURL': 'post.file.thumbURL', - '%URL': 'post.file.URL', - '%MD5': 'post.file.MD5', - '%board': 'post.board', - '%name': 'post.file.name' - }[parameter]) ? "' + encodeURIComponent(" + type + ") + '" : parameter); + if (type = { + '%TURL': post.file.thumbURL, + '%URL': post.file.URL, + '%MD5': post.file.MD5, + '%board': post.board, + '%name': post.file.name + }[parameter]) { + return encodeURIComponent(type); + } else { + return parameter; + } }); text = (m = link.match(/;text:(.+)$/)) ? m[1] : link.match(/(\w+)\.\w+\//)[1]; link = link.replace(/;text:.+$/, ''); - return Function('post', 'a', "a.href = '" + link + "';\na.textContent = '" + text + "';\nreturn a;"); + a.href = link; + a.textContent = text; + return a; }, node: function() { var link, nodes, _i, _len, _ref; @@ -11423,7 +11426,7 @@ _ref = Sauce.links; for (_i = 0, _len = _ref.length; _i < _len; _i++) { link = _ref[_i]; - nodes.push($.tn('\u00A0'), link(this, Sauce.link.cloneNode(true))); + nodes.push($.tn('\u00A0'), Sauce.createSauceLink(link, this, Sauce.link.cloneNode(true))); } return $.add(this.file.text, nodes); } @@ -13212,7 +13215,7 @@ } return Redirect.data = o; }, - archives: [{"uid":0,"name":"Moe","domain":"archive.moe","http":true,"https":true,"software":"foolfuuka","boards":["a","biz","c","co","diy","gd","int","jp","m","out","po","sci","sp","tg","tv","v","vg","vp","vr","wsg"],"files":["a","biz","c","co","diy","gd","jp","m","po","sci","tg","v","vg","vp","vr","wsg"]},{"uid":1,"name":"NSFW Moe","domain":"nsfw.archive.moe","http":true,"https":true,"software":"foolfuuka","boards":["h","u"],"files":["h","u"]},{"uid":3,"name":"4plebs Archive","domain":"archive.4plebs.org","http":true,"https":true,"software":"foolfuuka","boards":["adv","f","hr","o","pol","s4s","tg","trv","tv","x"],"files":["adv","f","hr","o","pol","s4s","tg","trv","tv","x"]},{"uid":5,"name":"Love is Over","domain":"archive.loveisover.me","http":true,"https":true,"software":"foolfuuka","boards":["c","d","e","i","lgbt","t","u","w","wg"],"files":["c","d","e","i","lgbt","t","u","w","wg"]},{"uid":8,"name":"Rebecca Black Tech","domain":"archive.rebeccablacktech.com","http":false,"https":true,"software":"fuuka","boards":["cgl","g","mu","w"],"files":["cgl","g","mu","w"]},{"uid":9,"name":"Heinessen","domain":"archive.heinessen.com","http":true,"https":false,"software":"fuuka","boards":["an","fit","k","mlp","r9k","toy"],"files":["an","fit","k","mlp","r9k","toy"]},{"uid":10,"name":"warosu","domain":"warosu.org","http":false,"https":true,"software":"fuuka","boards":["3","biz","cgl","ck","diy","fa","g","ic","jp","lit","sci","tg","vr"],"files":["3","biz","cgl","ck","diy","fa","ic","jp","lit","sci","tg","vr"]},{"uid":15,"name":"fgts","domain":"fgts.jp","http":true,"https":true,"software":"foolfuuka","boards":["asp","cm","h","hc","hm","n","p","r","s","soc","y"],"files":["asp","cm","h","hc","hm","n","p","r","s","soc","y"]},{"uid":16,"name":"maware","domain":"archive.mawa.re","http":true,"https":false,"software":"foolfuuka","boards":["t"],"files":["t"]}], + archives: [{"uid":0,"name":"Moe","domain":"archive.moe","http":true,"https":true,"software":"foolfuuka","boards":["a","biz","c","co","diy","gd","int","jp","m","out","po","sci","sp","tg","tv","v","vg","vp","vr","wsg"],"files":["a","biz","c","co","diy","gd","jp","m","po","sci","tg","v","vg","vp","vr","wsg"]},{"uid":1,"name":"NSFW Moe","domain":"nsfw.archive.moe","http":true,"https":true,"software":"foolfuuka","boards":["h","u"],"files":["h","u"]},{"uid":3,"name":"4plebs Archive","domain":"archive.4plebs.org","http":true,"https":true,"software":"foolfuuka","boards":["adv","f","hr","o","pol","s4s","tg","trv","tv","x"],"files":["adv","f","hr","o","pol","s4s","tg","trv","tv","x"]},{"uid":5,"name":"Love is Over","domain":"archive.loveisover.me","http":true,"https":true,"software":"foolfuuka","boards":["c","d","e","i","lgbt","t","u","w","wg"],"files":["c","d","e","i","lgbt","t","u","w","wg"]},{"uid":8,"name":"Rebecca Black Tech","domain":"archive.rebeccablacktech.com","http":false,"https":true,"software":"fuuka","boards":["cgl","g","mu","w"],"files":["cgl","g","mu","w"]},{"uid":9,"name":"Heinessen","domain":"archive.heinessen.com","http":true,"https":false,"software":"fuuka","boards":["an","fit","k","mlp","r9k","toy"],"files":["an","fit","k","mlp","r9k","toy"]},{"uid":10,"name":"warosu","domain":"warosu.org","http":false,"https":true,"software":"fuuka","boards":["3","biz","cgl","ck","diy","fa","g","ic","jp","lit","sci","tg","vr"],"files":["3","biz","cgl","ck","diy","fa","ic","jp","lit","sci","tg","vr"]},{"uid":15,"name":"fgts","domain":"fgts.jp","http":true,"https":true,"software":"foolfuuka","boards":["asp","cm","h","hc","hm","n","p","r","s","soc","y"],"files":["asp","cm","h","hc","hm","n","p","r","s","soc","y"]},{"uid":16,"name":"maware","domain":"archive.mawa.re","http":true,"https":false,"software":"foolfuuka","boards":["t"],"files":["t"]},{"uid":17,"name":"imcute","domain":"imcute.yt","http":true,"https":false,"software":"foolfuuka","boards":["gif","jp","vg"],"files":["gif","jp","vg"]}], to: function(dest, data) { var archive; archive = (dest === 'search' || dest === 'board' ? Redirect.data.thread : Redirect.data[dest])[data.boardID]; @@ -13350,6 +13353,15 @@ "software": "foolfuuka", "boards": ["t"], "files": ["t"] + }, { + "uid": 17, + "name": "imcute", + "domain": "imcute.yt", + "http": true, + "https": false, + "software": "foolfuuka", + "boards": ["gif", "jp", "vg"], + "files": ["gif", "jp", "vg"] } ]; @@ -15299,7 +15311,6 @@ if (!Conf['File Info Formatting']) { return; } - this.funk = this.createFunc(Conf['fileInfo']); return Post.callbacks.push({ name: 'File Info Formatting', cb: this.node @@ -15309,18 +15320,16 @@ if (!this.file || this.isClone) { return; } - return this.file.text.innerHTML = "" + (FileInfo.funk(FileInfo, this)) + ""; + return this.file.text.innerHTML = "" + (FileInfo.format(Conf['fileInfo'], this)) + ""; }, - createFunc: function(format) { - var code; - code = format.replace(/%(.)/g, function(s, c) { + format: function(formatString, post) { + return formatString.replace(/%([A-Za-z])/g, function(s, c) { if (c in FileInfo.formatters) { - return "' + FileInfo.formatters." + c + ".call(post) + '"; + return FileInfo.formatters[c].call(post); } else { return s; } }); - return Function('FileInfo', 'post', "return '" + code + "'"); }, convertUnit: function(size, unit) { var i; @@ -16155,7 +16164,6 @@ if (!Conf['Time Formatting']) { return; } - this.funk = this.createFunc(Conf['time']); return Post.callbacks.push({ name: 'Time Formatting', cb: this.node @@ -16165,18 +16173,16 @@ if (this.isClone) { return; } - return this.nodes.date.textContent = Time.funk(Time, this.info.date); + return this.nodes.date.textContent = Time.format(Conf['time'], this.info.date); }, - createFunc: function(format) { - var code; - code = format.replace(/%([A-Za-z])/g, function(s, c) { + format: function(formatString, date) { + return formatString.replace(/%([A-Za-z])/g, function(s, c) { if (c in Time.formatters) { - return "' + Time.formatters." + c + ".call(date) + '"; + return Time.formatters[c].call(date); } else { return s; } }); - return Function('Time', 'date', "return '" + code + "'"); }, day: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], month: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'], @@ -17138,15 +17144,13 @@ return Header.generateBoardList(this.value); }, time: function() { - var funk; - funk = Time.createFunc(this.value); - return this.nextElementSibling.textContent = funk(Time, new Date()); + return this.nextElementSibling.textContent = Time.format(this.value, new Date()); }, backlink: function() { - return this.nextElementSibling.textContent = this.value.replace(/%id/, '123456789'); + return this.nextElementSibling.textContent = this.value.replace(/%id/g, '123456789'); }, fileInfo: function() { - var data, funk; + var data; data = { isReply: true, file: { @@ -17160,8 +17164,7 @@ isSpoiler: true } }; - funk = FileInfo.createFunc(this.value); - return this.nextElementSibling.innerHTML = funk(FileInfo, data); + return this.nextElementSibling.innerHTML = FileInfo.format(this.value, data); }, favicon: function() { Favicon.init(); diff --git a/package.json b/package.json index 2c61c1a83..b01692d7a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "appchan-x", - "version": "2.9.37", + "version": "2.9.38", "description": "The most comprehensive 4chan userscript.", "meta": { "name": "appchan x", diff --git a/src/Archive/archives.json b/src/Archive/archives.json index bfcd71396..243cace86 100644 --- a/src/Archive/archives.json +++ b/src/Archive/archives.json @@ -79,4 +79,13 @@ "software": "foolfuuka", "boards": ["t"], "files": ["t"] +}, { + "uid": 17, + "name": "imcute", + "domain": "imcute.yt", + "http": true, + "https": false, + "software": "foolfuuka", + "boards": ["gif", "jp", "vg"], + "files": ["gif", "jp", "vg"] }] diff --git a/src/General/Settings.coffee b/src/General/Settings.coffee index eb7f9346d..308174ed7 100755 --- a/src/General/Settings.coffee +++ b/src/General/Settings.coffee @@ -348,11 +348,10 @@ Settings = Header.generateBoardList @value time: -> - funk = Time.createFunc @value - @nextElementSibling.textContent = funk Time, new Date() + @nextElementSibling.textContent = Time.format @value, new Date() backlink: -> - @nextElementSibling.textContent = @value.replace /%id/, '123456789' + @nextElementSibling.textContent = @value.replace /%id/g, '123456789' fileInfo: -> data = @@ -366,8 +365,7 @@ Settings = isImage: true isVideo: false isSpoiler: true - funk = FileInfo.createFunc @value - @nextElementSibling.innerHTML = funk FileInfo, data + @nextElementSibling.innerHTML = FileInfo.format @value, data favicon: -> Favicon.init() diff --git a/src/Images/Sauce.coffee b/src/Images/Sauce.coffee index 291aa72a7..256b75f84 100755 --- a/src/Images/Sauce.coffee +++ b/src/Images/Sauce.coffee @@ -5,7 +5,7 @@ Sauce = links = [] for link in Conf['sauces'].split '\n' try - links.push @createSauceLink link.trim() if link[0] isnt '#' + links.push link.trim() if link[0] isnt '#' catch err # Don't add random text plz. return unless links.length @@ -14,29 +14,27 @@ Sauce = Post.callbacks.push name: 'Sauce' cb: @node - createSauceLink: (link) -> + createSauceLink: (link, post, a) -> link = link.replace /%(T?URL|MD5|board|name)/g, (parameter) -> - return (if type = { - '%TURL': 'post.file.thumbURL' - '%URL': 'post.file.URL' - '%MD5': 'post.file.MD5' - '%board': 'post.board' - '%name': 'post.file.name' + if type = { + '%TURL': post.file.thumbURL + '%URL': post.file.URL + '%MD5': post.file.MD5 + '%board': post.board + '%name': post.file.name }[parameter] - "' + encodeURIComponent(#{type}) + '" + encodeURIComponent(type) else - parameter) + parameter text = if m = link.match(/;text:(.+)$/) then m[1] else link.match(/(\w+)\.\w+\//)[1] link = link.replace /;text:.+$/, '' - Function 'post', 'a', """ - a.href = '#{link}'; - a.textContent = '#{text}'; - return a; - """ + a.href = link + a.textContent = text + a node: -> return if @isClone or !@file nodes = [] for link in Sauce.links # \u00A0 is nbsp - nodes.push $.tn('\u00A0'), link @, Sauce.link.cloneNode true + nodes.push $.tn('\u00A0'), (Sauce.createSauceLink link, @, Sauce.link.cloneNode true) $.add @file.text, nodes diff --git a/src/Miscellaneous/FileInfo.coffee b/src/Miscellaneous/FileInfo.coffee index c94bb41bd..7a15a76ce 100755 --- a/src/Miscellaneous/FileInfo.coffee +++ b/src/Miscellaneous/FileInfo.coffee @@ -2,20 +2,18 @@ FileInfo = init: -> return if !Conf['File Info Formatting'] - @funk = @createFunc Conf['fileInfo'] Post.callbacks.push name: 'File Info Formatting' cb: @node node: -> return if !@file or @isClone - @file.text.innerHTML = "#{FileInfo.funk FileInfo, @}" - createFunc: (format) -> - code = format.replace /%(.)/g, (s, c) -> + @file.text.innerHTML = "#{FileInfo.format Conf['fileInfo'], @}" + format: (formatString, post) -> + formatString.replace /%([A-Za-z])/g, (s, c) -> if c of FileInfo.formatters - "' + FileInfo.formatters.#{c}.call(post) + '" + FileInfo.formatters[c].call(post) else s - Function 'FileInfo', 'post', "return '#{code}'" convertUnit: (size, unit) -> if unit is 'B' return "#{size.toFixed()} Bytes" diff --git a/src/Miscellaneous/Time.coffee b/src/Miscellaneous/Time.coffee index 0d290cc63..3d2d3f2f6 100755 --- a/src/Miscellaneous/Time.coffee +++ b/src/Miscellaneous/Time.coffee @@ -2,20 +2,18 @@ Time = init: -> return if !Conf['Time Formatting'] - @funk = @createFunc Conf['time'] Post.callbacks.push name: 'Time Formatting' cb: @node node: -> return if @isClone - @nodes.date.textContent = Time.funk Time, @info.date - createFunc: (format) -> - code = format.replace /%([A-Za-z])/g, (s, c) -> + @nodes.date.textContent = Time.format Conf['time'], @info.date + format: (formatString, date) -> + formatString.replace /%([A-Za-z])/g, (s, c) -> if c of Time.formatters - "' + Time.formatters.#{c}.call(date) + '" + Time.formatters[c].call(date) else s - Function 'Time', 'date', "return '#{code}'" day: [ 'Sunday' 'Monday' diff --git a/src/Quotelinks/QuoteBacklink.coffee b/src/Quotelinks/QuoteBacklink.coffee index def790c58..dfb1e3156 100755 --- a/src/Quotelinks/QuoteBacklink.coffee +++ b/src/Quotelinks/QuoteBacklink.coffee @@ -12,8 +12,6 @@ QuoteBacklink = init: -> return if !Conf['Quote Backlinks'] - format = Conf['backlink'].replace /%id/g, "' + id + '" - @funk = Function 'id', "return '#{format}'" @frag = $.nodes [$.tn(' '), $.el 'a', className: 'backlink'] @map = {} @@ -43,7 +41,7 @@ QuoteBacklink = if @isClone @nodes.backlinkContainer = $ '.backlink-container', @nodes.info for backlink in @nodes.backlinks - QuoteMarkers.parseQuotelink @, backlink, true, QuoteBacklink.funk Get.postDataFromLink(backlink).postID + QuoteMarkers.parseQuotelink @, backlink, true, Conf['backlink'].replace(/%id/g, Get.postDataFromLink(backlink).postID) return @nodes.backlinkContainer = container = $.el 'span', className: 'backlink-container' @@ -57,7 +55,7 @@ QuoteBacklink = frag = QuoteBacklink.frag.cloneNode true a = frag.lastElementChild a.href = Build.path quoter.board.ID, quoter.thread.ID, quoter.ID - a.textContent = text = QuoteBacklink.funk quoter.ID + a.textContent = text = Conf['backlink'].replace /%id/g, quoter.ID if quoter.isDead $.addClass a, 'deadlink' if quoter.isHidden