diff --git a/CHANGELOG.md b/CHANGELOG.md index fe14db7c8..cfe98db53 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,27 @@ **ParrotParrot**: - Added `Original filename` variable to Sauce panel. +### v1.3.10 +*2014-02-20* + +**Spittie** +- I keep breaking and fixing stuff. But mostly breaking. + +### v1.3.9 +*2014-02-20* + +**Spittie** +- Fix uploading (>me in charge of not being an idiot) + +### v1.3.8 +*2014-02-20* + +**MayhemYDG** +- Fix QR + +**Spittie** +- Better url handling + ### v1.3.7 *2014-02-15* diff --git a/LICENSE b/LICENSE index a6b55bd56..6c121836a 100755 --- a/LICENSE +++ b/LICENSE @@ -1,5 +1,5 @@ /* -* 4chan X - Version 1.3.7 - 2014-02-23 +* 4chan X - Version 1.3.10 - 2014-02-23 * * Licensed under the MIT license. * https://github.com/Spittie/4chan-x/blob/master/LICENSE diff --git a/README.md b/README.md index 22ff4a5dc..554d5e573 100755 --- a/README.md +++ b/README.md @@ -1,8 +1,10 @@ Personal fork of Seaweed's 4chan X. +#### [Why 4chan X needs to access data on every site?](https://github.com/Spittie/4chan-x/wiki/Why-4chan-X-needs-to-access-data-from-every-website%3F) + ##[Install](https://github.com/Spittie/4chan-x/raw/master/builds/4chan-X.user.js) (Firefox) ##[Install](https://github.com/Spittie/4chan-x/raw/master/builds/crx.crx) (Chrom*) -##[Install](http://a.pomf.se/pmnhcu.xpi) (Firefox Mobile) +##[Install](http://a.pomf.se/ermdzx.xpi) (Firefox Mobile) ## If you have any problems, try resetting your 4chan X settings before calling me a faggot (but feel free to do so) diff --git a/builds/4chan-X.meta.js b/builds/4chan-X.meta.js index c72846c5e..6a29f104e 100755 --- a/builds/4chan-X.meta.js +++ b/builds/4chan-X.meta.js @@ -1,6 +1,6 @@ // ==UserScript== // @name 4chan X -// @version 1.3.7 +// @version 1.3.10 // @minGMVer 1.14 // @minFFVer 26 // @namespace 4chan-X diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index 33133ff35..df386fa2b 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -1,7 +1,7 @@ // Generated by CoffeeScript // ==UserScript== // @name 4chan X -// @version 1.3.7 +// @version 1.3.10 // @minGMVer 1.14 // @minFFVer 26 // @namespace 4chan-X @@ -24,7 +24,7 @@ // ==/UserScript== /* -* 4chan X - Version 1.3.7 - 2014-02-23 +* 4chan X - Version 1.3.10 - 2014-02-23 * * Licensed under the MIT license. * https://github.com/Spittie/4chan-x/blob/master/LICENSE @@ -364,7 +364,7 @@ doc = d.documentElement; g = { - VERSION: '1.3.7', + VERSION: '1.3.10', NAMESPACE: '4chan X.', boards: {} }; @@ -5909,8 +5909,26 @@ QR.handleFiles(files); return $.addClass(QR.nodes.el, 'dump'); }, - handleBlob: function(blob) { - var _ref; + handleBlob: function(urlBlob, header, url) { + var blob, end, endnl, endsc, mime, name, name_end, name_start, start, _ref; + name = url.substr(url.lastIndexOf('/') + 1, url.length); + start = header.indexOf("Content-Type: ") + 14; + endsc = header.substr(start, header.length).indexOf(";"); + endnl = header.substr(start, header.length).indexOf("\n") - 1; + end = endnl; + if (endsc !== -1 && endsc < endnl) { + end = endsc; + } + mime = header.substr(start, end); + blob = new Blob([urlBlob], { + type: mime + }); + blob.name = url.substr(url.lastIndexOf('/') + 1, url.length); + name_start = header.indexOf('name="') + 6; + if (name_start - 6 !== -1) { + name_end = header.substr(name_start, header.length).indexOf('"'); + blob.name = header.substr(name_start, name_end); + } if (blob.type === null) { return QR.error("Unsupported file type."); } @@ -5930,7 +5948,7 @@ url: url, overrideMimeType: "text/plain; charset=x-user-defined", onload: function(xhr) { - var data, end, header, i, mime, r, start, urlBlob; + var data, i, r; r = xhr.responseText; data = new Uint8Array(r.length); i = 0; @@ -5938,18 +5956,7 @@ data[i] = r.charCodeAt(i); i++; } - header = xhr.responseHeaders; - start = header.indexOf("Content-Type: ") + 14; - end = header.substr(start, header.length).indexOf("\n") - 1; - mime = header.substr(start, end); - if (mime === null) { - return; - } - urlBlob = new Blob([data], { - type: mime - }); - urlBlob.name = url.substr(url.lastIndexOf('/') + 1, url.length); - QR.handleBlob(urlBlob); + QR.handleBlob(data, xhr.responseHeaders, url); return; return { onerror: function(xhr) { @@ -10417,8 +10424,8 @@ } }, { name: "Foolz Beta", - boards: ["a", "co", "gd", "jp", "m", "s4s", "sp", "tg", "tv", "u", "v", "vg", "vp", "vr", "wsg"], - files: ["a", "gd", "jp", "m", "s4s", "tg", "u", "vg", "vp", "vr", "wsg"], + boards: ["a", "biz", "co", "d", "gd", "jp", "m", "mlp", "s4s", "sp", "tg", "tv", "u", "v", "vg", "vp", "vr", "wsg"], + files: ["a", "biz", "d", "gd", "jp", "m", "s4s", "tg", "u", "vg", "vp", "vr", "wsg"], data: { domain: "beta.foolz.us", http: true, diff --git a/builds/crx.crx b/builds/crx.crx index 85cd36e95..d00f0381a 100644 Binary files a/builds/crx.crx and b/builds/crx.crx differ diff --git a/builds/crx/manifest.json b/builds/crx/manifest.json index 187d2efd1..5e92724b7 100755 --- a/builds/crx/manifest.json +++ b/builds/crx/manifest.json @@ -1,6 +1,6 @@ { "name": "4chan X", - "version": "1.3.7", + "version": "1.3.10", "manifest_version": 2, "description": "Cross-browser userscript for maximum lurking on 4chan.", "icons": { diff --git a/builds/crx/script.js b/builds/crx/script.js index 39c9da9a0..06171ddc0 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -1,6 +1,6 @@ // Generated by CoffeeScript /* -* 4chan X - Version 1.3.7 - 2014-02-23 +* 4chan X - Version 1.3.10 - 2014-02-23 * * Licensed under the MIT license. * https://github.com/Spittie/4chan-x/blob/master/LICENSE @@ -340,7 +340,7 @@ doc = d.documentElement; g = { - VERSION: '1.3.7', + VERSION: '1.3.10', NAMESPACE: '4chan X.', boards: {} }; @@ -5953,8 +5953,26 @@ QR.handleFiles(files); return $.addClass(QR.nodes.el, 'dump'); }, - handleBlob: function(blob) { - var _ref; + handleBlob: function(urlBlob, header, url) { + var blob, end, endnl, endsc, mime, name, name_end, name_start, start, _ref; + name = url.substr(url.lastIndexOf('/') + 1, url.length); + start = header.indexOf("Content-Type: ") + 14; + endsc = header.substr(start, header.length).indexOf(";"); + endnl = header.substr(start, header.length).indexOf("\n") - 1; + end = endnl; + if (endsc !== -1 && endsc < endnl) { + end = endsc; + } + mime = header.substr(start, end); + blob = new Blob([urlBlob], { + type: mime + }); + blob.name = url.substr(url.lastIndexOf('/') + 1, url.length); + name_start = header.indexOf('name="') + 6; + if (name_start - 6 !== -1) { + name_end = header.substr(name_start, header.length).indexOf('"'); + blob.name = header.substr(name_start, name_end); + } if (blob.type === null) { return QR.error("Unsupported file type."); } @@ -5973,13 +5991,8 @@ xhr.open('GET', url, true); xhr.responseType = 'blob'; xhr.onload = function(e) { - var urlBlob; if (this.readyState === this.DONE && xhr.status === 200) { - urlBlob = new Blob([this.response], { - type: this.getResponseHeader('content-type') - }); - urlBlob.name = url.substr(url.lastIndexOf('/') + 1, url.length); - QR.handleBlob(urlBlob); + QR.handleBlob(this.response, this.getResponseHeader('Content-Type'), url); } else { QR.error("Can't load image."); } @@ -10414,8 +10427,8 @@ } }, { name: "Foolz Beta", - boards: ["a", "co", "gd", "jp", "m", "s4s", "sp", "tg", "tv", "u", "v", "vg", "vp", "vr", "wsg"], - files: ["a", "gd", "jp", "m", "s4s", "tg", "u", "vg", "vp", "vr", "wsg"], + boards: ["a", "biz", "co", "d", "gd", "jp", "m", "mlp", "s4s", "sp", "tg", "tv", "u", "v", "vg", "vp", "vr", "wsg"], + files: ["a", "biz", "d", "gd", "jp", "m", "s4s", "tg", "u", "vg", "vp", "vr", "wsg"], data: { domain: "beta.foolz.us", http: true, diff --git a/builds/xpi/4chanx.xpi b/builds/xpi/4chanx.xpi index 4e84eb064..349303a0a 100644 Binary files a/builds/xpi/4chanx.xpi and b/builds/xpi/4chanx.xpi differ diff --git a/builds/xpi/data/4chan-X.user.js b/builds/xpi/data/4chan-X.user.js index 5456ed885..312a80c33 100644 --- a/builds/xpi/data/4chan-X.user.js +++ b/builds/xpi/data/4chan-X.user.js @@ -1,7 +1,7 @@ // Generated by CoffeeScript // ==UserScript== // @name 4chan X -// @version 1.3.7 +// @version 1.3.10 // @minGMVer 1.13 // @minFFVer 26 // @namespace 4chan-X @@ -23,7 +23,7 @@ // ==/UserScript== /* -* 4chan X - Version 1.3.7 - 2014-02-15 +* 4chan X - Version 1.3.10 - 2014-02-21 * * Licensed under the MIT license. * https://github.com/Spittie/4chan-x/blob/master/LICENSE @@ -360,7 +360,7 @@ doc = d.documentElement; g = { - VERSION: '1.3.7', + VERSION: '1.3.10', NAMESPACE: '4chan X.', boards: {}, threads: {}, @@ -5339,6 +5339,7 @@ }; QR = { + mimeTypes: ['image/jpeg', 'image/png', 'image/gif', 'application/pdf', 'application/x-shockwave-flash', ''], init: function() { var sc; if (!Conf['Quick Reply']) { @@ -5663,8 +5664,26 @@ QR.handleFiles(files); return $.addClass(QR.nodes.el, 'dump'); }, - handleBlob: function(blob) { - var _ref; + handleBlob: function(urlBlob, header, url) { + var blob, end, endnl, endsc, mime, name, name_end, name_start, start, _ref; + name = url.substr(url.lastIndexOf('/') + 1, url.length); + start = header.indexOf("Content-Type: ") + 14; + endsc = header.substr(start, header.length).indexOf(";"); + endnl = header.substr(start, header.length).indexOf("\n") - 1; + end = endnl; + if (endsc !== -1 && endsc < endnl) { + end = endsc; + } + mime = header.substr(start, end); + blob = new Blob([urlBlob], { + type: mime + }); + blob.name = url.substr(url.lastIndexOf('/') + 1, url.length); + name_start = header.indexOf('name="') + 6; + if (name_start - 6 !== -1) { + name_end = header.substr(name_start, header.length).indexOf('"'); + blob.name = header.substr(name_start, name_end); + } if (blob.type === null) { return QR.error("Unsupported file type."); } @@ -5684,7 +5703,7 @@ url: url, overrideMimeType: "text/plain; charset=x-user-defined", onload: function(xhr) { - var data, end, header, i, mime, r, start, urlBlob; + var data, i, r; r = xhr.responseText; data = new Uint8Array(r.length); i = 0; @@ -5692,18 +5711,7 @@ data[i] = r.charCodeAt(i); i++; } - header = xhr.responseHeaders; - start = header.indexOf("Content-Type: ") + 14; - end = header.substr(start, header.length).indexOf("\n") - 1; - mime = header.substr(start, end); - if (mime === null) { - return; - } - urlBlob = new Blob([data], { - type: mime - }); - urlBlob.name = url.substr(url.lastIndexOf('/') + 1, url.length); - QR.handleBlob(urlBlob); + QR.handleBlob(data, xhr.responseHeaders, url); return; return { onerror: function(xhr) { @@ -5800,7 +5808,7 @@ return list.value = g.VIEW === 'thread' ? g.THREADID : 'new'; }, dialog: function() { - var check, dialog, elm, event, flagSelector, i, items, key, mimeTypes, name, node, nodes, save, value, _ref; + var dialog, elm, event, flagSelector, i, items, key, name, node, nodes, save, value, _ref; QR.nodes = nodes = { el: dialog = UI.dialog('qr', 'top:0;right:0;', "
") }; @@ -5834,16 +5842,6 @@ value = _ref[key]; nodes[key] = $(value, dialog); } - check = { - jpg: 'image/jpeg', - pdf: 'application/pdf', - swf: 'application/x-shockwave-flash' - }; - mimeTypes = $('ul.rules > li').textContent.trim().match(/: (.+)/)[1].toLowerCase().replace(/\w+/g, function(type) { - return check[type] || ("image/" + type); - }); - QR.mimeTypes = mimeTypes.split(', '); - QR.mimeTypes.push(''); nodes.fileInput.max = $('input[name=MAX_FILE_SIZE]').value; QR.spoiler = !!$('input[name=spoiler]'); if (QR.spoiler) { @@ -9910,16 +9908,38 @@ Redirect = { init: function() { - var archive, archives, boardID, boards, data, files, id, name, o, record, software, type, _i, _len, _ref, _ref1; + var archive, archives, boardID, boards, data, files, id, name, o, record, software, type, _i, _j, _len, _len1, _ref, _ref1, _ref2; o = { thread: {}, post: {}, file: {} }; - archives = Redirect.archives; - _ref = Conf['selectedArchives']; - for (boardID in _ref) { - record = _ref[boardID]; + archives = {}; + _ref = Redirect.archives; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + _ref1 = _ref[_i], name = _ref1.name, boards = _ref1.boards, files = _ref1.files, data = _ref1.data; + archives[name] = { + boards: boards, + files: files, + data: data + }; + software = data.software; + for (_j = 0, _len1 = boards.length; _j < _len1; _j++) { + boardID = boards[_j]; + if (!(boardID in o.thread)) { + o.thread[boardID] = data; + } + if (!(boardID in o.post || software !== 'foolfuuka')) { + o.post[boardID] = data; + } + if (!(boardID in o.file || __indexOf.call(files, boardID) < 0)) { + o.file[boardID] = data; + } + } + } + _ref2 = Conf['selectedArchives']; + for (boardID in _ref2) { + record = _ref2[boardID]; for (type in record) { id = record[type]; if (!((archive = archives[id]))) { @@ -9932,26 +9952,11 @@ o[type][boardID] = archive.data; } } - for (name in archives) { - _ref1 = archives[name], data = _ref1.data, boards = _ref1.boards, files = _ref1.files; - software = data.software; - for (_i = 0, _len = boards.length; _i < _len; _i++) { - boardID = boards[_i]; - if (!(boardID in o.thread)) { - o.thread[boardID] = data; - } - if (!(boardID in o.post || software !== 'foolfuuka')) { - o.post[boardID] = data; - } - if (!(boardID in o.file || __indexOf.call(files, boardID) < 0)) { - o.file[boardID] = data; - } - } - } return Redirect.data = o; }, - archives: { - "Foolz": { + archives: [ + { + name: "Foolz", boards: ["a", "biz", "co", "gd", "jp", "m", "sp", "tg", "tv", "v", "vg", "vp", "vr", "wsg"], files: ["a", "biz", "gd", "jp", "m", "tg", "vg", "vp", "vr", "wsg"], data: { @@ -9960,8 +9965,8 @@ https: true, software: "foolfuuka" } - }, - "NSFW Foolz": { + }, { + name: "NSFW Foolz", boards: ["u"], files: ["u"], data: { @@ -9970,8 +9975,8 @@ https: true, software: "foolfuuka" } - }, - "The Dark Cave": { + }, { + name: "The Dark Cave", boards: ["c", "int", "out", "po"], files: ["c", "po"], data: { @@ -9980,8 +9985,8 @@ https: true, software: "foolfuuka" } - }, - "4plebs": { + }, { + name: "4plebs", boards: ["adv", "hr", "o", "pol", "s4s", "tg", "tv", "x"], files: ["adv", "hr", "o", "pol", "s4s", "tg", "tv", "x"], data: { @@ -9990,8 +9995,8 @@ https: true, software: "foolfuuka" } - }, - "Nyafuu": { + }, { + name: "Nyafuu", boards: ["c", "e", "w", "wg"], files: ["c", "e", "w", "wg"], data: { @@ -10000,8 +10005,8 @@ https: true, software: "foolfuuka" } - }, - "Love is Over": { + }, { + name: "Love is Over", boards: ["d", "i"], files: ["d", "i"], data: { @@ -10010,8 +10015,8 @@ https: true, software: "foolfuuka" } - }, - "Install Gentoo (.net)": { + }, { + name: "Install Gentoo", boards: ["diy", "g", "sci"], files: [], data: { @@ -10020,28 +10025,18 @@ https: true, software: "fuuka" } - }, - "Install Gentoo (.com)": { - boards: ["t", "g"], - files: ["t", "g"], - data: { - domain: "archive.installgentoo.com/", - http: true, - https: true, - software: "foolfuuka" - } - }, - "Rebecca Black Tech": { + }, { + name: "Rebecca Black Tech", boards: ["cgl", "g", "mu", "w"], files: ["cgl", "g", "mu", "w"], data: { - domain: "rbt.asia", + domain: "archive.rebeccablacktech.com", http: true, https: true, software: "fuuka" } - }, - "Heinessen": { + }, { + name: "Heinessen", boards: ["an", "fit", "k", "mlp", "r9k", "toy"], files: ["an", "fit", "k", "r9k", "toy"], data: { @@ -10049,18 +10044,17 @@ http: true, software: "fuuka" } - }, - "warosu": { + }, { + name: "warosu", boards: ["3", "cgl", "ck", "fa", "ic", "jp", "lit", "tg", "vr"], files: ["3", "cgl", "ck", "fa", "ic", "jp", "lit", "tg", "vr"], data: { domain: "fuuka.warosu.org", - http: true, https: true, software: "fuuka" } - }, - "fgst": { + }, { + name: "fgts", boards: ["r", "soc"], files: ["r", "soc"], data: { @@ -10069,20 +10063,28 @@ https: true, software: "foolfuuka" } - }, - "maware": { + }, { + name: "maware", boards: ["t"], files: ["t"], data: { domain: "archive.mawa.re", http: true, - https: false, software: "foolfuuka" } - }, - "Foolz Beta": { - boards: ["a", "co", "gd", "jp", "m", "s4s", "sp", "tg", "tv", "u", "v", "vg", "vp", "vr", "wsg"], - files: ["a", "gd", "jp", "m", "s4s", "tg", "u", "vg", "vp", "vr", "wsg"], + }, { + name: "installgentoo.com", + boards: ["g", "t"], + files: ["g", "t"], + data: { + domain: "chan.installgentoo.com", + http: true, + software: "foolfuuka" + } + }, { + name: "Foolz Beta", + boards: ["a", "biz", "co", "d", "gd", "jp", "m", "mlp", "s4s", "sp", "tg", "tv", "u", "v", "vg", "vp", "vr", "wsg"], + files: ["a", "biz", "d", "gd", "jp", "m", "s4s", "tg", "u", "vg", "vp", "vr", "wsg"], data: { domain: "beta.foolz.us", http: true, @@ -10091,7 +10093,7 @@ software: "foolfuuka" } } - }, + ], to: function(dest, data) { var archive; archive = (dest === 'search' ? Redirect.data.thread : Redirect.data[dest])[data.boardID]; diff --git a/latest.js b/latest.js index d15637805..5d9e44b1a 100755 --- a/latest.js +++ b/latest.js @@ -1 +1 @@ -postMessage({version:'1.3.7'},'*') +postMessage({version:'1.3.10'},'*') diff --git a/package.json b/package.json index eacd94442..21f87abed 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "4chan-X", - "version": "1.3.7", + "version": "1.3.10", "description": "Cross-browser userscript for maximum lurking on 4chan.", "meta": { "name": "4chan X", diff --git a/src/Archive/Redirect.coffee b/src/Archive/Redirect.coffee index 77cb63abf..6c57b51c9 100755 --- a/src/Archive/Redirect.coffee +++ b/src/Archive/Redirect.coffee @@ -137,8 +137,8 @@ Redirect = software: "foolfuuka" , name: "Foolz Beta" - boards: ["a", "co", "gd", "jp", "m", "s4s", "sp", "tg", "tv", "u", "v", "vg", "vp", "vr", "wsg"], - files: ["a", "gd", "jp", "m", "s4s", "tg", "u", "vg", "vp", "vr", "wsg"] + boards: ["a", "biz", "co", "d", "gd", "jp", "m", "mlp", "s4s", "sp", "tg", "tv", "u", "v", "vg", "vp", "vr", "wsg"], + files: ["a", "biz", "d", "gd", "jp", "m", "s4s", "tg", "u", "vg", "vp", "vr", "wsg"] data: domain: "beta.foolz.us" http: true diff --git a/src/Posting/QR.coffee b/src/Posting/QR.coffee index 1a043b04f..24c0c1224 100644 --- a/src/Posting/QR.coffee +++ b/src/Posting/QR.coffee @@ -276,7 +276,23 @@ QR = QR.handleFiles files $.addClass QR.nodes.el, 'dump' - handleBlob: (blob) -> + handleBlob: (urlBlob, header, url) -> + name = url.substr(url.lastIndexOf('/')+1, url.length) + #QUALITY coding at work + start = header.indexOf("Content-Type: ") + 14 + endsc = header.substr(start, header.length).indexOf(";") + endnl = header.substr(start, header.length).indexOf("\n") - 1 + end = endnl + if (endsc != -1 and endsc < endnl) + end = endsc + mime = header.substr(start, end) + blob = new Blob([urlBlob], {type: mime}) + blob.name = url.substr(url.lastIndexOf('/')+1, url.length) + name_start = header.indexOf('name="') + 6 + if (name_start - 6 != -1) + name_end = header.substr(name_start, header.length).indexOf('"') + blob.name = header.substr(name_start, name_end) + return if blob.type is null QR.error "Unsupported file type." return unless blob.type in QR.mimeTypes @@ -292,9 +308,7 @@ QR = xhr.responseType = 'blob' xhr.onload = (e) -> if @readyState is @DONE && xhr.status is 200 - urlBlob = new Blob([@response], {type : @getResponseHeader('content-type')}) - urlBlob.name = url.substr(url.lastIndexOf('/')+1, url.length) - QR.handleBlob(urlBlob) + QR.handleBlob(@response, @getResponseHeader('Content-Type'), url) return else QR.error "Can't load image." @@ -320,17 +334,8 @@ QR = while i < r.length data[i] = r.charCodeAt(i) i++ - #QUALITY coding at work - header = xhr.responseHeaders - start = header.indexOf("Content-Type: ") + 14 - end = header.substr(start, header.length).indexOf("\n") - 1 - mime = header.substr(start, end) - return if mime is null - urlBlob = new Blob([data], {type: mime}) - - urlBlob.name = url.substr(url.lastIndexOf('/')+1, url.length) - QR.handleBlob(urlBlob) + QR.handleBlob(data, xhr.responseHeaders, url) return onerror: (xhr) ->