From 08e7a8a6c43ccf82d43ade20e08652050ee4a4aa Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Sat, 10 Aug 2013 02:04:41 -0700 Subject: [PATCH 1/9] This will get better when MediaCrush's API improves? --- LICENSE | 2 +- builds/4chan-X.user.js | 19 +++++++++++++---- builds/crx/script.js | 19 +++++++++++++---- src/Linkification/Linkify.coffee | 36 +++++++++++++++++++++++++++++--- 4 files changed, 64 insertions(+), 12 deletions(-) diff --git a/LICENSE b/LICENSE index b6e66b546..a98499ab6 100644 --- a/LICENSE +++ b/LICENSE @@ -1,5 +1,5 @@ /* -* 4chan X - Version 1.2.25 - 2013-08-09 +* 4chan X - Version 1.2.25 - 2013-08-10 * * Licensed under the MIT license. * https://github.com/seaweedchan/4chan-x/blob/master/LICENSE diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index eccc4fea7..d10334602 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -19,7 +19,7 @@ // @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAgMAAAAqbBEUAAAACVBMVEUAAGcAAABmzDNZt9VtAAAAAXRSTlMAQObYZgAAAHFJREFUKFOt0LENACEIBdBv4Qju4wgWanEj3D6OcIVMKaitYHEU/jwTCQj8W75kiVCSBvdQ5/AvfVHBin11BgdRq3ysBgfwBDRrj3MCIA+oAQaku/Q1cNctrAmyDl577tOThYt/Y1RBM4DgOHzM0HFTAyLukH/cmRnqAAAAAElFTkSuQmCC // ==/UserScript== /* -* 4chan X - Version 1.2.25 - 2013-08-09 +* 4chan X - Version 1.2.25 - 2013-08-10 * * Licensed under the MIT license. * https://github.com/seaweedchan/4chan-x/blob/master/LICENSE @@ -4385,10 +4385,12 @@ if (this.isClone) { if (Conf['Embedding']) { i = 0; - items = $$('.embedded', this.nodes.comment); + items = $$('.embed', this.nodes.comment); while (el = items[i++]) { - $.on(el, "click", Linkify.cb.toggle); - Linkify.cb.toggle.call(el); + $.on(el, 'click', Linkify.cb.toggle); + if ($.hasClass(el, 'embedded')) { + Linkify.cb.toggle.call(el); + } } } return; @@ -4676,6 +4678,15 @@ }); } }, + MediaCrush: { + regExp: /.*(?:mediacru.sh\/)([0-9a-z_]+)/i, + style: 'border: 0; width: 640px; height: 480px; resize: both;', + el: function(a) { + return $.el('iframe', { + src: "https://mediacru.sh/" + a.dataset.uid + }); + } + }, pastebin: { regExp: /.*(?:pastebin.com\/(?!u\/))([^#\&\?]*).*/, el: function(a) { diff --git a/builds/crx/script.js b/builds/crx/script.js index 0ff3f6cf7..233ab106b 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -1,6 +1,6 @@ // Generated by CoffeeScript /* -* 4chan X - Version 1.2.25 - 2013-08-09 +* 4chan X - Version 1.2.25 - 2013-08-10 * * Licensed under the MIT license. * https://github.com/seaweedchan/4chan-x/blob/master/LICENSE @@ -4390,10 +4390,12 @@ if (this.isClone) { if (Conf['Embedding']) { i = 0; - items = $$('.embedded', this.nodes.comment); + items = $$('.embed', this.nodes.comment); while (el = items[i++]) { - $.on(el, "click", Linkify.cb.toggle); - Linkify.cb.toggle.call(el); + $.on(el, 'click', Linkify.cb.toggle); + if ($.hasClass(el, 'embedded')) { + Linkify.cb.toggle.call(el); + } } } return; @@ -4681,6 +4683,15 @@ }); } }, + MediaCrush: { + regExp: /.*(?:mediacru.sh\/)([0-9a-z_]+)/i, + style: 'border: 0; width: 640px; height: 480px; resize: both;', + el: function(a) { + return $.el('iframe', { + src: "https://mediacru.sh/" + a.dataset.uid + }); + } + }, pastebin: { regExp: /.*(?:pastebin.com\/(?!u\/))([^#\&\?]*).*/, el: function(a) { diff --git a/src/Linkification/Linkify.coffee b/src/Linkification/Linkify.coffee index b2151e945..b935fba66 100644 --- a/src/Linkification/Linkify.coffee +++ b/src/Linkification/Linkify.coffee @@ -36,10 +36,10 @@ Linkify = if @isClone if Conf['Embedding'] i = 0 - items = $$ '.embedded', @nodes.comment + items = $$ '.embed', @nodes.comment while el = items[i++] - $.on el, "click", Linkify.cb.toggle - Linkify.cb.toggle.call el + $.on el, 'click', Linkify.cb.toggle + Linkify.cb.toggle.call el if $.hasClass el, 'embedded' return @@ -279,6 +279,36 @@ Linkify = $.el 'object', innerHTML: "" + MediaCrush: + regExp: /.*(?:mediacru.sh\/)([0-9a-z_]+)/i + style: 'border: 0; width: 640px; height: 480px; resize: both;' + el: (a) -> + $.el 'iframe', + src: "https://mediacru.sh/#{a.dataset.uid}" +# MediaCrush CORS When? +# +# el = $.el 'div' +# $.cache "https://mediacru.sh/#{a.dataset.uid}.json", -> +# {status} = @ +# return unless [200, 304].contains status +# {files} = JSON.parse req.response +# file = file for file of files when files.hasOwnProperty file +# el.innerHTML = switch file.type +# when 'video/mp4', 'video/ogv' +# """ +#""" +# when 'image/png', 'image/gif', 'image/jpeg' +# "" +# when 'image/svg', 'image/svg+xml' +# "" +# when 'audio/mpeg' +# "" +# el + + pastebin: regExp: /.*(?:pastebin.com\/(?!u\/))([^#\&\?]*).*/ el: (a) -> From c53b84709932f29c09c49583b374d6809ba670ab Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Sat, 10 Aug 2013 02:06:42 -0700 Subject: [PATCH 2/9] Only Appchan has dropmarkers --- builds/4chan-X.user.js | 2 +- builds/crx/script.js | 2 +- src/Menu/Menu.coffee | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index d10334602..8073cd317 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -7035,7 +7035,7 @@ a = $.el('a', { className: 'menu-button brackets-wrap', - innerHTML: '', + innerHTML: '', href: 'javascript:;' }); return { diff --git a/builds/crx/script.js b/builds/crx/script.js index 233ab106b..68f8eea56 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -7016,7 +7016,7 @@ a = $.el('a', { className: 'menu-button brackets-wrap', - innerHTML: '', + innerHTML: '', href: 'javascript:;' }); return { diff --git a/src/Menu/Menu.coffee b/src/Menu/Menu.coffee index 29fc8399e..2d7076f1b 100644 --- a/src/Menu/Menu.coffee +++ b/src/Menu/Menu.coffee @@ -1,7 +1,7 @@ Menu = do -> a = $.el 'a', className: 'menu-button brackets-wrap' - innerHTML: '' + innerHTML: '' href: 'javascript:;' init: -> From a12d50981b3ee682a62a2f5c8266cc7447031d27 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Sat, 10 Aug 2013 15:05:44 +0200 Subject: [PATCH 3/9] Shorter dice format. --- src/Miscellaneous/Dice.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Miscellaneous/Dice.coffee b/src/Miscellaneous/Dice.coffee index 93bdb06cd..7b7a3c386 100644 --- a/src/Miscellaneous/Dice.coffee +++ b/src/Miscellaneous/Dice.coffee @@ -8,4 +8,4 @@ Dice = return if @isClone or not dicestats = @info.email?.match /dice[+\s](\d+)d(\d+)/ # Use the text node directly, as the has two
. roll = $('b', @nodes.comment).firstChild - roll.data = "Rolled #{dicestats[1]}d#{dicestats[2]} and got #{roll.data.slice 7}" + roll.data = "Rolled #{dicestats[1]}d#{dicestats[2]}: #{roll.data.slice 7}" From 4b332e19e0153887b28ff4292461fde68b488ab7 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Sat, 10 Aug 2013 15:26:34 +0200 Subject: [PATCH 4/9] Fix #1196, #1222. --- src/Quotelinks/Quotify.coffee | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Quotelinks/Quotify.coffee b/src/Quotelinks/Quotify.coffee index 1d26c6e79..8f94ee226 100644 --- a/src/Quotelinks/Quotify.coffee +++ b/src/Quotelinks/Quotify.coffee @@ -21,11 +21,15 @@ Quotify = # This won't be necessary once 4chan # stops quotifying inside code tags: # https://github.com/4chan/4chan-JS/issues/77 - $.replace deadlink, [deadlink.childNodes...] + Quotify.fixDeadlink deadlink return quote = deadlink.textContent return unless postID = quote.match(/\d+$/)?[0] + if postID[0] is '0' + # Fix quotelinks that start with a `0`. + Quotify.fixDeadlink deadlink + return boardID = if m = quote.match /^>>>\/([a-z\d]+)/ m[1] else @@ -70,3 +74,6 @@ Quotify = $.replace deadlink, a if $.hasClass a, 'quotelink' @nodes.quotelinks.push a + + fixDeadlink: (deadlink) -> + $.replace deadlink, [deadlink.childNodes...] From 79aa6eb975d5be5f9bcfbd357c40556e3d7f7e75 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Sat, 10 Aug 2013 15:34:22 +0200 Subject: [PATCH 5/9] Release 4chan X v3.6.0. --- CHANGELOG.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 353dce5e0..b3b04ffcf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,5 @@ +## 3.6.0 - *2013-08-10* + - **New feature**: `Show Dice Roll` - Shows dice that were entered into the email field on /tg/. - Fix impossibility to create new threads when in dead threads. diff --git a/package.json b/package.json index 33b87d4d9..2f097642f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "4chan-X", - "version": "3.5.7", + "version": "3.6.0", "description": "Cross-browser extension for productive lurking on 4chan.", "meta": { "name": "4chan X", From 1e439167d76d0f8d5fb7631405ee796110107287 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Sat, 10 Aug 2013 15:46:48 +0200 Subject: [PATCH 6/9] Shorter QuoteYou code. Not sure why I had written it that way. --- src/Quotelinks/QuoteYou.coffee | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/Quotelinks/QuoteYou.coffee b/src/Quotelinks/QuoteYou.coffee index 3013abd03..11e4763dc 100644 --- a/src/Quotelinks/QuoteYou.coffee +++ b/src/Quotelinks/QuoteYou.coffee @@ -10,11 +10,6 @@ QuoteYou = node: -> # Stop there if it's a clone. return if @isClone - # Stop there if there's no quotes in that post. - return unless (quotes = @quotes).length - {quotelinks} = @nodes - - for quotelink in quotelinks - if QR.db.get Get.postDataFromLink quotelink - $.add quotelink, $.tn QuoteYou.text + for quotelink in quotelinks when QR.db.get Get.postDataFromLink quotelink + $.add quotelink, $.tn QuoteYou.text return From 1d83ccbc12c4ce0e04887ca55aacae042c9432b7 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Sat, 10 Aug 2013 15:48:47 +0200 Subject: [PATCH 7/9] .nex files are not necessary anymore. --- Gruntfile.coffee | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/Gruntfile.coffee b/Gruntfile.coffee index 9410f0c6b..535eb2bca 100644 --- a/Gruntfile.coffee +++ b/Gruntfile.coffee @@ -69,15 +69,6 @@ module.exports = (grunt) -> dest: 'builds/crx/' expand: true flatten: true - # for_d19 - # 19 juin 2013 10:32:22 - # We're currently sniffing the type of the file based on file extension. - # We have a different type of content, Themes, which use a pure zip-file with a .zip ending. - # This solution is sub-optimal and will be changed in the future. - # For now, upload an unsigned ZIP-file with the ending .nex or .crx. - nex: - src: 'builds/<%= pkg.name %>.zip' - dest: 'builds/<%= pkg.name %>.nex' coffee: script: src: 'tmp-<%= pkg.type %>/script.coffee' @@ -158,7 +149,7 @@ module.exports = (grunt) -> 'clean:tmpuserscript' ] - grunt.registerTask 'release', ['shell:commit', 'shell:push', 'build-crx', 'compress:crx', 'copy:nex'] + grunt.registerTask 'release', ['shell:commit', 'shell:push', 'build-crx', 'compress:crx'] grunt.registerTask 'patch', ['bump', 'updcl:3', 'release'] grunt.registerTask 'minor', ['bump:minor', 'updcl:2', 'release'] grunt.registerTask 'major', ['bump:major', 'updcl:1', 'release'] From e890680dc4f187d1d010a8606961aa3e9126ae51 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Sat, 10 Aug 2013 15:52:24 +0200 Subject: [PATCH 8/9] Fix missing `@nodes.`. --- src/Quotelinks/QuoteYou.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Quotelinks/QuoteYou.coffee b/src/Quotelinks/QuoteYou.coffee index 11e4763dc..acc4d2e64 100644 --- a/src/Quotelinks/QuoteYou.coffee +++ b/src/Quotelinks/QuoteYou.coffee @@ -10,6 +10,6 @@ QuoteYou = node: -> # Stop there if it's a clone. return if @isClone - for quotelink in quotelinks when QR.db.get Get.postDataFromLink quotelink + for quotelink in @nodes.quotelinks when QR.db.get Get.postDataFromLink quotelink $.add quotelink, $.tn QuoteYou.text return From 34e580f475048fab340d431fc77fdaa04a1b1581 Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Sat, 10 Aug 2013 13:54:03 -0700 Subject: [PATCH 9/9] ~ --- builds/4chan-X.user.js | 14 +++++++------- builds/crx/script.js | 8 ++++---- src/Posting/QuickReply.coffee | 8 ++++++-- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index 8073cd317..0378f4f4e 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -5904,7 +5904,7 @@ } }, dialog: function() { - var dialog, elm, mimeTypes, name, nodes, thread, _i, _j, _len, _len1, _ref, _ref1; + var dialog, elm, i, items, mimeTypes, name, nodes, thread; dialog = UI.dialog('qr', 'top:0;right:0;', "
×
No selected file×+
"); QR.nodes = nodes = { @@ -5965,9 +5965,9 @@ })); } $.on(nodes.filename.parentNode, 'click keyup', QR.openFileInput); - _ref = $$('*', QR.nodes.el); - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - elm = _ref[_i]; + items = $$('*', QR.nodes.el); + i = 0; + while (elm = items[i++]) { $.on(elm, 'blur', QR.focusout); $.on(elm, 'focus', QR.focusin); } @@ -5992,9 +5992,9 @@ return QR.selected.nodes.spoiler.click(); }); $.on(nodes.fileInput, 'change', QR.fileInput); - _ref1 = ['name', 'email', 'sub', 'com']; - for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) { - name = _ref1[_j]; + items = ['name', 'email', 'sub', 'com']; + i = 0; + while (name = items[i++]) { $.on(nodes[name], 'input', function() { return QR.selected.save(this); }); diff --git a/builds/crx/script.js b/builds/crx/script.js index 68f8eea56..03cb0407c 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -5902,7 +5902,7 @@ } }, dialog: function() { - var dialog, mimeTypes, name, nodes, thread, _i, _len, _ref; + var dialog, i, items, mimeTypes, name, nodes, thread; dialog = UI.dialog('qr', 'top:0;right:0;', "
×
No selected file×+
"); QR.nodes = nodes = { @@ -5984,9 +5984,9 @@ return QR.selected.nodes.spoiler.click(); }); $.on(nodes.fileInput, 'change', QR.fileInput); - _ref = ['name', 'email', 'sub', 'com']; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - name = _ref[_i]; + items = ['name', 'email', 'sub', 'com']; + i = 0; + while (name = items[i++]) { $.on(nodes[name], 'input', function() { return QR.selected.save(this); }); diff --git a/src/Posting/QuickReply.coffee b/src/Posting/QuickReply.coffee index d0ccd85e2..332ab2fe8 100644 --- a/src/Posting/QuickReply.coffee +++ b/src/Posting/QuickReply.coffee @@ -930,7 +930,9 @@ QR = <% if (type === 'userscript') { %> # XXX Firefox lacks focusin/focusout support. - for elm in $$ '*', QR.nodes.el + items = $$ '*', QR.nodes.el + i = 0 + while elm = items[i++] $.on elm, 'blur', QR.focusout $.on elm, 'focus', QR.focusin <% } %> @@ -946,7 +948,9 @@ QR = $.on nodes.spoiler, 'change', -> QR.selected.nodes.spoiler.click() $.on nodes.fileInput, 'change', QR.fileInput # save selected post's data - for name in ['name', 'email', 'sub', 'com'] + items = ['name', 'email', 'sub', 'com'] + i = 0 + while name = items[i++] $.on nodes[name], 'input', -> QR.selected.save @ $.on nodes.thread, 'change', -> QR.selected.save @