From 92ac7893d3896ad0dd3075464b46c1af2324f2ac Mon Sep 17 00:00:00 2001 From: Mayhem Date: Fri, 4 Apr 2014 23:33:01 +0200 Subject: [PATCH 1/8] Update deps. --- package.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index e74731b7c..04ec95b96 100644 --- a/package.json +++ b/package.json @@ -22,15 +22,15 @@ }, "devDependencies": { "font-awesome": "~4.0.3", - "grunt": "~0.4.2", + "grunt": "~0.4.4", "grunt-bump": "~0.0.13", "grunt-concurrent": "~0.5.0", "grunt-contrib-clean": "~0.5.0", - "grunt-contrib-coffee": "~0.10.0", + "grunt-contrib-coffee": "~0.10.1", "grunt-contrib-compress": "~0.7.0", - "grunt-contrib-concat": "~0.3.0", + "grunt-contrib-concat": "~0.4.0", "grunt-contrib-copy": "~0.5.0", - "grunt-contrib-watch": "~0.6.0", + "grunt-contrib-watch": "~0.6.1", "grunt-shell": "~0.6.4", "load-grunt-tasks": "~0.4.0" }, From 0bc93400c178c97c1a1c8aac6e0e65ac08de6797 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Sat, 5 Apr 2014 00:32:44 +0200 Subject: [PATCH 2/8] .webm #1533 --- CHANGELOG.md | 2 ++ src/Filtering/Filter.coffee | 3 ++- src/General/Build.coffee | 5 +++-- src/General/Post.coffee | 6 ++++-- src/General/Settings.coffee | 1 + src/Images/AutoGIF.coffee | 1 - src/Images/ImageExpand.coffee | 27 ++++++++++++++++++--------- src/Images/ImageHover.coffee | 19 +++++++++++++------ src/Miscellaneous/FileInfo.coffee | 2 +- src/Posting/QR.coffee | 17 ++++------------- 10 files changed, 48 insertions(+), 35 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 898c937b1..637e6eccb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,5 @@ +- Add support for .webm files. + ### 3.19.5 - *2014-04-03* - Fix captcha submission:
diff --git a/src/Filtering/Filter.coffee b/src/Filtering/Filter.coffee index 12dcde4ed..dd3cdbad9 100644 --- a/src/Filtering/Filter.coffee +++ b/src/Filtering/Filter.coffee @@ -146,7 +146,8 @@ Filter = return post.file.name false dimensions: (post) -> - if post.file and post.file.isImage + {file} = post + if file and (file.isImage or file.isVideo) return post.file.dimensions false filesize: (post) -> diff --git a/src/General/Build.coffee b/src/General/Build.coffee index e1bfa9bae..decdc8465 100644 --- a/src/General/Build.coffee +++ b/src/General/Build.coffee @@ -7,8 +7,9 @@ Build = # OPs have a +10 characters threshold. # The file extension is not taken into account. threshold = if isReply then 30 else 40 - if filename.length - 4 > threshold - "#{filename[...threshold - 5]}(...).#{filename[-3..]}" + ext = filename.match(/\.[^.]+$/)[0] + if filename.length - ext.length > threshold + "#{filename[...threshold - 5]}(...)#{ext}" else filename thumbRotate: do -> diff --git a/src/General/Post.coffee b/src/General/Post.coffee index f2db77261..8556d3fe6 100644 --- a/src/General/Post.coffee +++ b/src/General/Post.coffee @@ -113,7 +113,7 @@ class Post parseFile: (that) -> return unless (fileEl = $ '.file', @nodes.post) and thumb = $ 'img[data-md5]', fileEl - # Supports JPG/PNG/GIF/PDF. + # Supports JPG/PNG/GIF/WEBM/PDF. # Flash files are not supported. anchor = thumb.parentNode fileText = fileEl.firstElementChild @@ -144,7 +144,9 @@ class Post # http://www.whatwg.org/specs/web-apps/current-work/#multipart-form-data @file.name = @file.name.replace /%22/g, '"' <% } %> - if @file.isImage = /(jpg|png|gif)$/i.test @file.name + @file.isImage = /(jpg|png|gif)$/i.test @file.name + @file.isVideo = /webm$/i.test @file.name + if @file.isImage or @file.isVideo @file.dimensions = fileText.textContent.match(/\d+x\d+/)[0] cleanup: (root, post) -> diff --git a/src/General/Settings.coffee b/src/General/Settings.coffee index 3c934d32b..b6e614267 100644 --- a/src/General/Settings.coffee +++ b/src/General/Settings.coffee @@ -304,6 +304,7 @@ Settings = sizeInBytes: 276 * 1024 dimensions: '1280x720' isImage: true + isVideo: false isSpoiler: true funk = FileInfo.createFunc @value @nextElementSibling.innerHTML = funk FileInfo, data diff --git a/src/Images/AutoGIF.coffee b/src/Images/AutoGIF.coffee index c47a388bb..70acc351c 100644 --- a/src/Images/AutoGIF.coffee +++ b/src/Images/AutoGIF.coffee @@ -32,4 +32,3 @@ AutoGIF = else thumb.src = URL gif.src = URL - diff --git a/src/Images/ImageExpand.coffee b/src/Images/ImageExpand.coffee index 213543a0e..ccc23709a 100644 --- a/src/Images/ImageExpand.coffee +++ b/src/Images/ImageExpand.coffee @@ -13,7 +13,7 @@ ImageExpand = name: 'Image Expansion' cb: @node node: -> - return unless @file?.isImage + return unless @file and (@file.isImage or @file.isVideo) {thumb} = @file $.on thumb.parentNode, 'click', ImageExpand.cb.toggle if @isClone and $.hasClass thumb, 'expanding' @@ -42,7 +42,7 @@ ImageExpand = for ID, post of g.posts for post in [post].concat post.clones {file} = post - continue unless file and file.isImage and doc.contains post.nodes.root + continue unless file and (file.isImage or file.isVideo) and doc.contains post.nodes.root if ImageExpand.on and !post.isHidden and (!Conf['Expand spoilers'] and file.isSpoiler or Conf['Expand from here'] and Header.getTopOf(file.thumb) < 0) @@ -72,6 +72,7 @@ ImageExpand = $.rmClass post.nodes.root, 'expanded-image' $.rmClass post.file.thumb, 'expanding' post.file.isExpanded = false + post.file.fullImage.pause() if post.file.isVideo expand: (post, src) -> # Do not expand images of hidden/filtered replies, or already expanded pictures. @@ -80,21 +81,29 @@ ImageExpand = $.addClass thumb, 'expanding' if post.file.fullImage # Expand already-loaded/ing picture. - $.asap (-> post.file.fullImage.naturalHeight), -> + $.asap (-> post.file.isVideo or post.file.fullImage.naturalHeight), -> ImageExpand.completeExpand post return - post.file.fullImage = img = $.el 'img', - className: 'full-image' - src: src or post.file.URL - $.on img, 'error', ImageExpand.error - $.asap (-> post.file.fullImage.naturalHeight), -> + file = if post.file.isImage + $.el 'img', + className: 'full-image' + src: src or post.file.URL + else + $.el 'video', + className: 'full-image' + src: src or post.file.URL + loop: true + post.file.fullImage = file + $.on file, 'error', ImageExpand.error + $.asap (-> post.file.isVideo or post.file.fullImage.naturalHeight), -> ImageExpand.completeExpand post - $.after thumb, img + $.after thumb, file completeExpand: (post) -> {thumb} = post.file return unless $.hasClass thumb, 'expanding' # contracted before the image loaded post.file.isExpanded = true + post.file.fullImage.play() if post.file.isVideo unless post.nodes.root.parentNode # Image might start/finish loading before the post is inserted. # Don't scroll when it's expanded in a QP for example. diff --git a/src/Images/ImageHover.coffee b/src/Images/ImageHover.coffee index 97e44971a..cdf35b575 100644 --- a/src/Images/ImageHover.coffee +++ b/src/Images/ImageHover.coffee @@ -9,19 +9,26 @@ ImageHover = name: 'Image Hover' cb: @catalogNode node: -> - return unless @file?.isImage + return unless @file and (@file.isImage or @file.isVideo) $.on @file.thumb, 'mouseover', ImageHover.mouseover catalogNode: -> - return unless @thread.OP.file?.isImage + return unless @thread.OP.file and (@thread.OP.file.isImage @thread.OP.file.isVideo) $.on @nodes.thumb, 'mouseover', ImageHover.mouseover mouseover: (e) -> post = if $.hasClass @, 'thumb' g.posts[@parentNode.dataset.fullID] else Get.postFromNode @ - el = $.el 'img', - id: 'ihover' - src: post.file.URL + el = if post.file.isImage + $.el 'img', + id: 'ihover' + src: post.file.URL + else + $.el 'video', + id: 'ihover' + src: post.file.URL + autoplay: true + loop: true el.dataset.fullID = post.fullID $.add d.body, el UI.hover @@ -29,7 +36,7 @@ ImageHover = el: el latestEvent: e endEvents: 'mouseout click' - asapTest: -> el.naturalHeight + asapTest: -> post.file.isVideo or el.naturalHeight $.on el, 'error', ImageHover.error error: -> return unless doc.contains @ diff --git a/src/Miscellaneous/FileInfo.coffee b/src/Miscellaneous/FileInfo.coffee index 0534b2c33..c94bb41bd 100644 --- a/src/Miscellaneous/FileInfo.coffee +++ b/src/Miscellaneous/FileInfo.coffee @@ -47,4 +47,4 @@ FileInfo = B: -> FileInfo.convertUnit @file.sizeInBytes, 'B' K: -> FileInfo.convertUnit @file.sizeInBytes, 'KB' M: -> FileInfo.convertUnit @file.sizeInBytes, 'MB' - r: -> if @file.isImage then @file.dimensions else 'PDF' + r: -> @file.dimensions or 'PDF' diff --git a/src/Posting/QR.coffee b/src/Posting/QR.coffee index 0d4a9673d..f6e440268 100644 --- a/src/Posting/QR.coffee +++ b/src/Posting/QR.coffee @@ -1,6 +1,4 @@ QR = - # Add empty mimeType to avoid errors with URLs selected in Window's file dialog. - mimeTypes: ['image/jpeg', 'image/png', 'image/gif', 'application/pdf', 'application/x-shockwave-flash', ''] init: -> return if !Conf['Quick Reply'] @@ -258,21 +256,14 @@ QR = if file.size > max QR.error "#{file.name}: File too large (file: #{$.bytesToString file.size}, max: #{$.bytesToString max})." return - unless file.type in QR.mimeTypes - unless /^text/.test file.type - QR.error "#{file.name}: Unsupported file type." - return - if isSingle - post = QR.selected - else if (post = QR.posts[QR.posts.length - 1]).com - post = new QR.post() - post.pasteText file - return if isSingle post = QR.selected else if (post = QR.posts[QR.posts.length - 1]).file post = new QR.post() - post.setFile file + if /^text/.test file.type + post.pasteText file + else + post.setFile file openFileInput: -> QR.nodes.fileInput.click() From f04f411018163e1ce16e08b52de050235374ea19 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Sat, 5 Apr 2014 00:35:50 +0200 Subject: [PATCH 3/8] Release 4chan X v3.20.0. --- CHANGELOG.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 637e6eccb..d48ede46b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,5 @@ +## 3.20.0 - *2014-04-05* + - Add support for .webm files. ### 3.19.5 - *2014-04-03* diff --git a/package.json b/package.json index 04ec95b96..5e94d7500 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "4chan-X", - "version": "3.19.5", + "version": "3.20.0", "description": "Cross-browser extension for productive lurking on 4chan.", "meta": { "name": "4chan X", From 4d8e4b62da6098ddf7e3abf13b303b9d43062ad3 Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Sat, 5 Apr 2014 00:46:16 -0700 Subject: [PATCH 4/8] Reload captcha if there are posts in the queue. --- LICENSE | 2 +- builds/4chan-X.user.js | 6 +++++- builds/crx/script.js | 6 +++++- src/Posting/QR.coffee | 3 +++ 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/LICENSE b/LICENSE index 4eb64e47f..e10abf149 100755 --- a/LICENSE +++ b/LICENSE @@ -1,5 +1,5 @@ /* -* 4chan X - Version 1.5.1 - 2014-04-04 +* 4chan X - Version 1.5.1 - 2014-04-05 * * Licensed under the MIT license. * https://github.com/ccd0/4chan-x/blob/master/LICENSE diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index 18028219d..f940b50e0 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -24,7 +24,7 @@ // ==/UserScript== /* -* 4chan X - Version 1.5.1 - 2014-04-04 +* 4chan X - Version 1.5.1 - 2014-04-05 * * Licensed under the MIT license. * https://github.com/ccd0/4chan-x/blob/master/LICENSE @@ -6804,6 +6804,10 @@ if (!(Conf['Persistent QR'] || QR.cooldown.auto)) { QR.close(); } else { + if (QR.posts.length > 1) { + QR.captcha.setup(); + QR.captcha.afterSetup(); + } post.rm(); } QR.cooldown.set({ diff --git a/builds/crx/script.js b/builds/crx/script.js index 0b5a27e0a..4caa60bd8 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -1,6 +1,6 @@ // Generated by CoffeeScript /* -* 4chan X - Version 1.5.1 - 2014-04-04 +* 4chan X - Version 1.5.1 - 2014-04-05 * * Licensed under the MIT license. * https://github.com/ccd0/4chan-x/blob/master/LICENSE @@ -6849,6 +6849,10 @@ if (!(Conf['Persistent QR'] || QR.cooldown.auto)) { QR.close(); } else { + if (QR.posts.length > 1) { + QR.captcha.setup(); + QR.captcha.afterSetup(); + } post.rm(); } QR.cooldown.set({ diff --git a/src/Posting/QR.coffee b/src/Posting/QR.coffee index 558eb0a57..ec898a265 100644 --- a/src/Posting/QR.coffee +++ b/src/Posting/QR.coffee @@ -791,6 +791,9 @@ QR = unless Conf['Persistent QR'] or QR.cooldown.auto QR.close() else + if QR.posts.length > 1 + QR.captcha.setup() + QR.captcha.afterSetup() post.rm() QR.cooldown.set {req, post, isReply, threadID} From 2ba7ae5d280c7f5c8c0ef803f99fcdd0606e7270 Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Sat, 5 Apr 2014 00:58:57 -0700 Subject: [PATCH 5/8] I like that better --- builds/4chan-X.user.js | 7 +++---- builds/crx/script.js | 7 +++---- src/Posting/QR.coffee | 3 --- src/Posting/QR.post.coffee | 2 ++ 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index f940b50e0..e1aedac33 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -6804,10 +6804,6 @@ if (!(Conf['Persistent QR'] || QR.cooldown.auto)) { QR.close(); } else { - if (QR.posts.length > 1) { - QR.captcha.setup(); - QR.captcha.afterSetup(); - } post.rm(); } QR.cooldown.set({ @@ -7249,6 +7245,9 @@ $.rmClass(QR.nodes.el, 'dump'); } else if (this === QR.selected) { (QR.posts[index - 1] || QR.posts[index + 1]).select(); + if (QR.captcha.isEnabled) { + QR.captcha.setup(); + } } QR.posts.splice(index, 1); return QR.status(); diff --git a/builds/crx/script.js b/builds/crx/script.js index 4caa60bd8..b12bbbbcf 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -6849,10 +6849,6 @@ if (!(Conf['Persistent QR'] || QR.cooldown.auto)) { QR.close(); } else { - if (QR.posts.length > 1) { - QR.captcha.setup(); - QR.captcha.afterSetup(); - } post.rm(); } QR.cooldown.set({ @@ -7288,6 +7284,9 @@ $.rmClass(QR.nodes.el, 'dump'); } else if (this === QR.selected) { (QR.posts[index - 1] || QR.posts[index + 1]).select(); + if (QR.captcha.isEnabled) { + QR.captcha.setup(); + } } QR.posts.splice(index, 1); return QR.status(); diff --git a/src/Posting/QR.coffee b/src/Posting/QR.coffee index ec898a265..558eb0a57 100644 --- a/src/Posting/QR.coffee +++ b/src/Posting/QR.coffee @@ -791,9 +791,6 @@ QR = unless Conf['Persistent QR'] or QR.cooldown.auto QR.close() else - if QR.posts.length > 1 - QR.captcha.setup() - QR.captcha.afterSetup() post.rm() QR.cooldown.set {req, post, isReply, threadID} diff --git a/src/Posting/QR.post.coffee b/src/Posting/QR.post.coffee index 6e6daa84a..0e2d2d320 100644 --- a/src/Posting/QR.post.coffee +++ b/src/Posting/QR.post.coffee @@ -80,6 +80,8 @@ QR.post = class $.rmClass QR.nodes.el, 'dump' else if @ is QR.selected (QR.posts[index-1] or QR.posts[index+1]).select() + if QR.captcha.isEnabled + QR.captcha.setup() QR.posts.splice index, 1 QR.status() delete: -> From df78c2e1f824ecb1490bf8e91bc6e1523aecc7cc Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Sat, 5 Apr 2014 01:02:43 -0700 Subject: [PATCH 6/8] Handle captcha errors with a new captcha! --- builds/4chan-X.user.js | 1 + builds/crx/script.js | 1 + src/Posting/QR.coffee | 1 + 3 files changed, 3 insertions(+) diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index e1aedac33..91328acdd 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -6123,6 +6123,7 @@ } if (QR.captcha.isEnabled && /captcha|verification/i.test(el.textContent)) { QR.captcha.nodes.input.focus(); + QR.captcha.setup(); if (Conf['Captcha Warning Notifications'] && !d.hidden) { QR.notify(el); } else { diff --git a/builds/crx/script.js b/builds/crx/script.js index b12bbbbcf..d29c43881 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -6178,6 +6178,7 @@ } if (QR.captcha.isEnabled && /captcha|verification/i.test(el.textContent)) { QR.captcha.nodes.input.focus(); + QR.captcha.setup(); if (Conf['Captcha Warning Notifications'] && !d.hidden) { QR.notify(el); } else { diff --git a/src/Posting/QR.coffee b/src/Posting/QR.coffee index 558eb0a57..1e74ee756 100644 --- a/src/Posting/QR.coffee +++ b/src/Posting/QR.coffee @@ -144,6 +144,7 @@ QR = if QR.captcha.isEnabled and /captcha|verification/i.test el.textContent # Focus the captcha input on captcha error. QR.captcha.nodes.input.focus() + QR.captcha.setup() if Conf['Captcha Warning Notifications'] and !d.hidden QR.notify el else From 813ebd3039346adc7a9ba8902c179ca4c6aa6f2c Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Sat, 5 Apr 2014 05:32:13 -0700 Subject: [PATCH 7/8] Fix file input --- builds/4chan-X.user.js | 3 ++- builds/crx/script.js | 3 ++- src/Posting/QR.coffee | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index 91328acdd..ad45766b3 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -6429,7 +6429,8 @@ if (e.target.nodeName === 'INPUT' || (e.keyCode && ((_ref = e.keyCode) !== 32 && _ref !== 13)) || e.ctrlKey) { return; } - return e.preventDefault(); + e.preventDefault(); + return QR.nodes.fileInput.click(); }, generatePostableThreadsList: function() { var list, options, thread, val, _i, _len, _ref; diff --git a/builds/crx/script.js b/builds/crx/script.js index d29c43881..384165c65 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -6485,7 +6485,8 @@ if (e.target.nodeName === 'INPUT' || (e.keyCode && ((_ref = e.keyCode) !== 32 && _ref !== 13)) || e.ctrlKey) { return; } - return e.preventDefault(); + e.preventDefault(); + return QR.nodes.fileInput.click(); }, generatePostableThreadsList: function() { var list, options, thread, val, _i, _len, _ref; diff --git a/src/Posting/QR.coffee b/src/Posting/QR.coffee index 1e74ee756..151d02db2 100644 --- a/src/Posting/QR.coffee +++ b/src/Posting/QR.coffee @@ -406,6 +406,7 @@ QR = return $.on QR.nodes.filename, 'blur', -> $.rmClass QR.nodes.filename, 'edit' return if e.target.nodeName is 'INPUT' or (e.keyCode and e.keyCode not in [32, 13]) or e.ctrlKey e.preventDefault() + QR.nodes.fileInput.click() generatePostableThreadsList: -> return unless QR.nodes From 22d7295217a86badf739efc713671d8a1c97a286 Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Sat, 5 Apr 2014 05:39:01 -0700 Subject: [PATCH 8/8] I'm having a bad morning. --- builds/4chan-X.user.js | 2 +- builds/crx/script.js | 2 +- src/Posting/QR.coffee | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index ad45766b3..e0227ad78 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -6413,7 +6413,7 @@ return post.setFile(file); } }, - openFileInput: function() { + openFileInput: function(e) { var _ref; e.stopPropagation(); if (e.shiftKey && e.type === 'click') { diff --git a/builds/crx/script.js b/builds/crx/script.js index 384165c65..c05435dd7 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -6469,7 +6469,7 @@ return post.setFile(file); } }, - openFileInput: function() { + openFileInput: function(e) { var _ref; e.stopPropagation(); if (e.shiftKey && e.type === 'click') { diff --git a/src/Posting/QR.coffee b/src/Posting/QR.coffee index 151d02db2..a4ea8ca58 100644 --- a/src/Posting/QR.coffee +++ b/src/Posting/QR.coffee @@ -396,7 +396,7 @@ QR = post.pasteText file else post.setFile file - openFileInput: -> + openFileInput: (e) -> e.stopPropagation() if e.shiftKey and e.type is 'click' return QR.selected.rmFile()