diff --git a/CHANGELOG.md b/CHANGELOG.md index 567223fce..5fdea8b66 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,15 @@ The attributions below are for work that has been incorporated into the script a The links to individual versions below are to copies of the script with the update URL removed. If you want automatic updates, install the script from the links on the [main page](https://github.com/ccd0/4chan-x). + +### v1.9.21.0 +*2015-01-26* - [[Firefox](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.21.0/builds/4chan-X-noupdate.user.js "Firefox version")] [[Chromium](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.21.0/builds/4chan-X-noupdate.crx "Chromium version")] + +- WebMs with controls now contract on click, provided the click is not on or near the controls. The contract button and dragging to the left have been removed. If `Autoplay` is disabled, the first click expands the video, the second click plays the video, and the third click contracts it. +- (Zixaphir) Restore downloading by original filename in the gallery. +- (Zixaphir) Embedded content is now shown after and underneath the `(embed)` link. +- Minor bugfixes. + ### v1.9.20.8 *2015-01-24* - [[Firefox](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.20.8/builds/4chan-X-noupdate.user.js "Firefox version")] [[Chromium](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.20.8/builds/4chan-X-noupdate.crx "Chromium version")] diff --git a/LICENSE b/LICENSE index f4a7ed7d2..00d42e2b7 100755 --- a/LICENSE +++ b/LICENSE @@ -1,5 +1,5 @@ /* -* 4chan X - Version 1.9.20.8 +* 4chan X - Version 1.9.21.0 * * Licensed under the MIT license. * https://github.com/ccd0/4chan-x/blob/master/LICENSE diff --git a/builds/4chan-X-beta.crx b/builds/4chan-X-beta.crx index 72874c737..50d195e57 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 72005be1b..c1b1423ad 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.9.20.8 +// @version 1.9.21.0 // @minGMVer 1.14 // @minFFVer 26 // @namespace 4chan-X diff --git a/builds/4chan-X-beta.user.js b/builds/4chan-X-beta.user.js index 31339264a..dcf485c8f 100644 --- a/builds/4chan-X-beta.user.js +++ b/builds/4chan-X-beta.user.js @@ -1,7 +1,7 @@ // Generated by CoffeeScript // ==UserScript== // @name 4chan X beta -// @version 1.9.20.8 +// @version 1.9.21.0 // @minGMVer 1.14 // @minFFVer 26 // @namespace 4chan-X @@ -25,12 +25,12 @@ // ==/UserScript== /* -* 4chan X - Version 1.9.20.8 +* 4chan X - Version 1.9.21.0 * * Licensed under the MIT license. * https://github.com/ccd0/4chan-x/blob/master/LICENSE * -* Appchan X Copyright © 2013-2014 Zixaphir +* Appchan X Copyright © 2013-2015 Zixaphir * http://zixaphir.github.io/appchan-x/ * 4chan x Copyright © 2009-2011 James Campos * https://github.com/aeosynth/4chan-x @@ -195,7 +195,7 @@ 'Werk Tyme': [false, 'Hide all post images when header menu item is checked.'], 'Autoplay': [true, 'Videos begin playing immediately when opened.'], 'Restart when Opened': [true, 'Restart GIFs and WebMs when you hover over or expand them.'], - 'Show Controls': [true, 'Show controls on videos expanded inline. Turn this off if you want to contract videos by clicking on them.'], + 'Show Controls': [true, 'Show controls on videos expanded inline.'], 'Loop in New Tab': [true, 'Loop videos opened in their own tabs.'] }, 'Menu': { @@ -396,7 +396,7 @@ doc = d.documentElement; g = { - VERSION: '1.9.20.8', + VERSION: '1.9.21.0', NAMESPACE: '4chan X.', NAME: '4chan X', FAQ: 'https://github.com/ccd0/4chan-x/wiki/Frequently-Asked-Questions', @@ -1511,7 +1511,6 @@ this.file.text = file.firstElementChild; this.file.thumb = $('.fileThumb > [data-md5]', file); this.file.fullImage = $('.full-image', file); - this.file.videoControls = $('.video-controls', this.file.text); if (contractThumb) { ImageExpand.contract(this); } @@ -3749,8 +3748,6 @@ }; flag = !flagCode ? { innerHTML: "" - } : false ? { - innerHTML: " \""" } : { innerHTML: " " }; @@ -6614,17 +6611,20 @@ mimeTypes: ['image/jpeg', 'image/png', 'image/gif', 'application/pdf', 'application/vnd.adobe.flash.movie', 'application/x-shockwave-flash', 'video/webm'], init: function() { var noscript, sc; - if (!Conf['Quick Reply'] || g.VIEW === 'archive') { + if (!Conf['Quick Reply']) { return; } this.db = new DataBoard('yourPosts'); this.posts = []; + if (g.VIEW === 'archive') { + return; + } $.globalEval('document.documentElement.dataset.jsEnabled = true;'); noscript = Conf['Force Noscript Captcha'] || !doc.dataset.jsEnabled; this.captcha = Captcha[noscript ? 'noscript' : 'v2']; if (Conf['QR Shortcut']) { sc = $.el('a', { - className: "qr-shortcut fa fa-comment-o " + (!Conf['Persistent QR'] ? 'disabled' : ''), + className: 'qr-shortcut fa fa-comment-o disabled', textContent: 'QR', title: 'Quick Reply', href: 'javascript:;' @@ -6635,11 +6635,9 @@ } if (Conf['Persistent QR'] || !QR.nodes || QR.nodes.el.hidden) { QR.open(); - QR.nodes.com.focus(); - return $.rmClass(this, 'disabled'); + return QR.nodes.com.focus(); } else { - QR.close(); - return $.addClass(this, 'disabled'); + return QR.close(); } }); Header.addShortcut(sc); @@ -6674,12 +6672,8 @@ }); QR.link = link.firstElementChild; $.on(link.firstChild, 'click', function() { - $.event('CloseMenu'); QR.open(); - QR.nodes.com.focus(); - if (Conf['QR Shortcut']) { - return $.rmClass($('.qr-shortcut'), 'disabled'); - } + return QR.nodes.com.focus(); }); if (Conf['Bottom QR Link'] && g.VIEW === 'thread') { linkBot = $.el('div', { @@ -6689,12 +6683,8 @@ innerHTML: "Reply to Thread" }); $.on(linkBot.firstElementChild, 'click', function() { - $.event('CloseMenu'); QR.open(); - QR.nodes.com.focus(); - if (Conf['QR Shortcut']) { - return $.rmClass($('.qr-shortcut'), 'disabled'); - } + return QR.nodes.com.focus(); }); $.prepend($('.navLinksBot'), linkBot); } @@ -6739,17 +6729,21 @@ } QR.nodes.el.hidden = false; QR.unhide(); - return; + } else { + try { + QR.dialog(); + } catch (_error) { + err = _error; + delete QR.nodes; + Main.handleErrors({ + message: 'Quick Reply dialog creation crashed.', + error: err + }); + return; + } } - try { - return QR.dialog(); - } catch (_error) { - err = _error; - delete QR.nodes; - return Main.handleErrors({ - message: 'Quick Reply dialog creation crashed.', - error: err - }); + if (Conf['QR Shortcut']) { + return $.rmClass($('.qr-shortcut'), 'disabled'); } }, close: function() { @@ -6763,7 +6757,7 @@ d.activeElement.blur(); $.rmClass(QR.nodes.el, 'dump'); if (Conf['QR Shortcut']) { - $.toggleClass($('.qr-shortcut'), 'disabled'); + $.addClass($('.qr-shortcut'), 'disabled'); } new QR.post(true); _ref = QR.posts.splice(0, QR.posts.length - 1); @@ -6957,10 +6951,7 @@ com.setSelectionRange(range, range); com.focus(); QR.selected.save(com); - QR.selected.save(thread); - if (Conf['QR Shortcut']) { - return $.rmClass($('.qr-shortcut'), 'disabled'); - } + return QR.selected.save(thread); }, characterCount: function() { var count, counter; @@ -7281,7 +7272,6 @@ nodes.flashTag.dataset["default"] = '4'; $.add(nodes.form, nodes.flashTag); } - QR.flagsInput(); $.on(nodes.filename.parentNode, 'click keydown', QR.openFileInput); $.on(nodes.autohide, 'change', QR.toggleHide); $.on(nodes.close, 'click', QR.close); @@ -7303,7 +7293,7 @@ return QR.selected.nodes.spoiler.click(); }); $.on(nodes.fileInput, 'change', QR.handleFiles); - items = ['thread', 'name', 'email', 'sub', 'com', 'filename', 'flag']; + items = ['thread', 'name', 'email', 'sub', 'com', 'filename']; i = 0; save = function() { return QR.selected.save(this); @@ -7336,43 +7326,6 @@ QR.captcha.setup(); return $.event('QRDialogCreation', null, dialog); }, - flags: function() { - var flag, fn, select, _i, _len, _ref; - select = $.el('select', { - name: 'flag', - className: 'flagSelector' - }); - fn = function(val) { - return $.add(select, $.el('option', { - value: val[0], - textContent: val[1] - })); - }; - _ref = [['0', 'None'], ['US', 'American'], ['KP', 'Best Korean'], ['BL', 'Black Nationalist'], ['CM', 'Communist'], ['CF', 'Confederate'], ['RE', 'Conservative'], ['EU', 'European'], ['GY', 'Gay'], ['PC', 'Hippie'], ['IL', 'Israeli'], ['DM', 'Liberal'], ['RP', 'Libertarian'], ['MF', 'Muslim'], ['NZ', 'Nazi'], ['OB', 'Obama'], ['PR', 'Pirate'], ['RB', 'Rebel'], ['TP', 'Tea Partier'], ['TX', 'Texan'], ['TR', 'Tree Hugger'], ['WP', 'White Supremacist']]; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - flag = _ref[_i]; - fn(flag); - } - return select; - }, - flagsInput: function() { - var flag, nodes; - nodes = QR.nodes; - if (!nodes) { - return; - } - if (nodes.flag) { - $.rm(nodes.flag); - delete nodes.flag; - } - if (false) { - flag = QR.flags(); - flag.dataset.name = 'flag'; - flag.dataset["default"] = '0'; - nodes.flag = flag; - return $.add(nodes.form, flag); - } - }, submit: function(e) { var captcha, cb, err, extra, filetag, formData, options, post, textOnly, thread, threadID; if (e != null) { @@ -7438,7 +7391,6 @@ upfile: post.file, filetag: filetag, spoiler: post.spoiler, - flag: post.flag, textonly: textOnly, mode: 'regist', pwd: QR.persona.pwd @@ -8460,8 +8412,7 @@ persona = _arg['QR.persona']; persona = { name: post.name, - email: /^sage$/.test(post.email) ? persona.email : post.email, - flag: post.flag + email: /^sage$/.test(post.email) ? persona.email : post.email }; return $.set('QR.persona', persona); }); @@ -8522,9 +8473,6 @@ _this.name = 'name' in QR.persona.always ? QR.persona.always.name : prev ? prev.name : persona.name; _this.email = 'email' in QR.persona.always ? QR.persona.always.email : prev && !/^sage$/.test(prev.email) ? prev.email : persona.email; _this.sub = 'sub' in QR.persona.always ? QR.persona.always.sub : ''; - if (QR.nodes.flag) { - _this.flag = prev ? prev.flag : persona.flag; - } if (QR.selected === _this) { return _this.load(); } @@ -8567,7 +8515,7 @@ if (this !== QR.selected) { return; } - _ref = ['thread', 'name', 'email', 'sub', 'com', 'fileButton', 'filename', 'spoiler', 'flag']; + _ref = ['thread', 'name', 'email', 'sub', 'com', 'fileButton', 'filename', 'spoiler']; for (_i = 0, _len = _ref.length; _i < _len; _i++) { name = _ref[_i]; if (node = QR.nodes[name]) { @@ -8601,7 +8549,7 @@ _Class.prototype.load = function() { var name, node, _i, _len, _ref; - _ref = ['thread', 'name', 'email', 'sub', 'com', 'filename', 'flag']; + _ref = ['thread', 'name', 'email', 'sub', 'com', 'filename']; for (_i = 0, _len = _ref.length; _i < _len; _i++) { name = _ref[_i]; if (!(node = QR.nodes[name])) { @@ -8651,7 +8599,7 @@ if (this !== QR.selected) { return; } - _ref = ['thread', 'name', 'email', 'sub', 'com', 'filename', 'spoiler', 'flag']; + _ref = ['thread', 'name', 'email', 'sub', 'com', 'filename', 'spoiler']; for (_i = 0, _len = _ref.length; _i < _len; _i++) { name = _ref[_i]; if (!(node = QR.nodes[name])) { @@ -8826,7 +8774,7 @@ FappeTyme = { init: function() { var el, lc, type, _i, _len, _ref, _ref1; - if (!(Conf['Fappe Tyme'] || Conf['Werk Tyme']) || ((_ref = g.VIEW) !== 'index' && _ref !== 'thread') || g.BOARD === 'f') { + if (!((Conf['Fappe Tyme'] || Conf['Werk Tyme']) && ((_ref = g.VIEW) === 'index' || _ref === 'thread') && g.BOARD.ID !== 'f')) { return; } this.nodes = {}; @@ -8898,7 +8846,7 @@ Gallery = { init: function() { var el, _ref; - if (((_ref = g.VIEW) !== 'index' && _ref !== 'thread') || g.BOARD === 'f' || !Conf['Gallery']) { + if (!(this.enabled = Conf['Gallery'] && ((_ref = g.VIEW) === 'index' || _ref === 'thread') && g.BOARD.ID !== 'f')) { return; } this.delay = Conf['Slide Delay']; @@ -8970,6 +8918,7 @@ cb = Gallery.cb; $.on(nodes.frame, 'click', cb.blank); $.on(nodes.next, 'click', cb.click); + $.on(nodes.name, 'click', ImageCommon.download); $.on($('.gal-prev', dialog), 'click', cb.prev); $.on($('.gal-next', dialog), 'click', cb.next); $.on($('.gal-start', dialog), 'click', cb.start); @@ -9168,7 +9117,7 @@ case 'Right': return Gallery.cb.next; case 'Enter': - return Gallery.cb.enterKey; + return Gallery.cb.advance; case 'Left': case '': return Gallery.cb.prev; @@ -9204,16 +9153,20 @@ next: function() { return Gallery.cb.open.call(Gallery.images[+Gallery.nodes.current.dataset.id + 1] || Gallery.images[0]); }, - enterKey: function() { + click: function(e) { + if (ImageCommon.onControls(e)) { + return; + } + e.preventDefault(); + return Gallery.cb.advance(); + }, + advance: function() { if (Gallery.nodes.current.paused) { return Gallery.nodes.current.play(); } else { return Gallery.cb.next(); } }, - click: function() { - return Gallery.cb[Gallery.nodes.current.controls ? 'stop' : 'enterKey'](); - }, toggle: function() { return (Gallery.nodes ? Gallery.cb.close : Gallery.build)(); }, @@ -9285,8 +9238,8 @@ }, menu: { init: function() { - var el, _ref; - if (((_ref = g.VIEW) !== 'index' && _ref !== 'thread') || !Conf['Gallery']) { + var el; + if (!Gallery.enabled) { return; } el = $.el('span', { @@ -9440,13 +9393,32 @@ }); }; return $.on(video, 'mouseover', handler); + }, + onControls: function(e) { + return e.target.controls && e.target.getBoundingClientRect().bottom - e.clientY < 35; + }, + download: function(e) { + if (this.protocol === 'blob:') { + return true; + } + e.preventDefault(); + return CrossOrigin.file(this.href, (function(_this) { + return function(blob) { + if (blob) { + _this.href = URL.createObjectURL(blob); + return _this.click(); + } else { + return new Notice('error', "Could not download " + _this.href, 30); + } + }; + })(this)); } }; ImageExpand = { init: function() { var _ref; - if (((_ref = g.VIEW) !== 'index' && _ref !== 'thread') || !Conf['Image Expansion']) { + if (!(this.enabled = Conf['Image Expansion'] && ((_ref = g.VIEW) === 'index' || _ref === 'thread') && g.BOARD.ID !== 'f')) { return; } this.EAI = $.el('a', { @@ -9458,12 +9430,6 @@ $.on(this.EAI, 'click', this.cb.toggleAll); Header.addShortcut(this.EAI, 3); $.on(d, 'scroll visibilitychange', this.cb.playVideos); - this.videoControls = $.el('span', { - className: 'video-controls' - }); - $.extend(this.videoControls, { - innerHTML: " contract" - }); return Post.callbacks.push({ name: 'Image Expansion', cb: this.node @@ -9480,7 +9446,6 @@ ImageExpand.contract(this); return ImageExpand.expand(this); } else if (this.file.isExpanded && this.file.isVideo) { - ImageExpand.setupVideoCB(this); return ImageExpand.setupVideo(this, !((_ref = this.origin.file.fullImage) != null ? _ref.paused : void 0) || this.origin.file.wasPlaying, this.file.fullImage.controls); } } else if (ImageExpand.on && !this.isHidden && !this.isFetchedQuote && (Conf['Expand spoilers'] || !this.file.isSpoiler) && (Conf['Expand videos'] || !this.file.isVideo)) { @@ -9489,17 +9454,21 @@ }, cb: { toggle: function(e) { - var file, post; + var file, post, _ref; if (e.shiftKey || e.altKey || e.ctrlKey || e.metaKey || e.button !== 0) { return; } post = Get.postFromNode(this); file = post.file; - if (file.isExpanded && file.isVideo && file.fullImage.controls) { + if (file.isExpanded && ImageCommon.onControls(e)) { return; } e.preventDefault(); - return ImageExpand.toggle(post); + if ((_ref = file.fullImage) != null ? _ref.paused : void 0) { + return file.fullImage.play(); + } else { + return ImageExpand.toggle(post); + } }, toggleAll: function() { var func, toggle; @@ -9581,7 +9550,7 @@ } }, contract: function(post) { - var bottom, cb, el, eventName, file, oldHeight, scrollY, top, x, _i, _len, _ref, _ref1; + var bottom, el, file, oldHeight, scrollY, top, x, _i, _len, _ref; file = post.file; if (el = file.fullImage) { top = Header.getTopOf(el); @@ -9591,12 +9560,9 @@ } $.rmClass(post.nodes.root, 'expanded-image'); $.rmClass(file.thumb, 'expanding'); - if (file.videoControls) { - $.rm(file.videoControls); - } file.thumb.parentNode.href = file.URL; file.thumb.parentNode.target = '_blank'; - _ref = ['isExpanding', 'isExpanded', 'videoControls', 'wasPlaying', 'scrollIntoView']; + _ref = ['isExpanding', 'isExpanded', 'wasPlaying', 'scrollIntoView']; for (_i = 0, _len = _ref.length; _i < _len; _i++) { x = _ref[_i]; delete file[x]; @@ -9618,11 +9584,6 @@ ImageCommon.pushCache(el); if (file.isVideo) { el.pause(); - _ref1 = ImageExpand.videoCB; - for (eventName in _ref1) { - cb = _ref1[eventName]; - $.off(el, eventName, cb); - } } if (Conf['Restart when Opened']) { ImageCommon.rewind(file.thumb); @@ -9666,14 +9627,9 @@ el.className = 'full-image'; $.after(thumb, el); if (isVideo) { - if (Conf['Show Controls'] && !file.videoControls) { - file.videoControls = ImageExpand.videoControls.cloneNode(true); - $.add(file.text, file.videoControls); - } thumb.parentNode.removeAttribute('href'); thumb.parentNode.removeAttribute('target'); el.loop = true; - ImageExpand.setupVideoCB(post); } if (!isVideo) { return $.asap((function() { @@ -9741,49 +9697,6 @@ return ImageCommon.addControls(fullImage); } }, - videoCB: (function() { - var mousedown; - mousedown = false; - return { - mouseover: function() { - return mousedown = false; - }, - mousedown: function(e) { - if (e.button === 0) { - return mousedown = true; - } - }, - mouseup: function(e) { - if (e.button === 0) { - return mousedown = false; - } - }, - mouseout: function(e) { - if (mousedown && e.clientX <= this.getBoundingClientRect().left) { - return ImageExpand.toggle(Get.postFromNode(this)); - } - }, - click: function(e) { - if (this.paused && !this.controls) { - this.play(); - return e.stopPropagation(); - } - } - }; - })(), - setupVideoCB: function(post) { - var cb, eventName, _ref; - _ref = ImageExpand.videoCB; - for (eventName in _ref) { - cb = _ref[eventName]; - $.on(post.file.fullImage, eventName, cb); - } - if (post.file.videoControls) { - return $.on(post.file.videoControls.firstElementChild, 'click', function() { - return ImageExpand.toggle(post); - }); - } - }, error: function() { var post; post = Get.postFromNode(this); @@ -9809,8 +9722,8 @@ }, menu: { init: function() { - var conf, createSubEntry, el, name, subEntries, _ref, _ref1; - if (((_ref = g.VIEW) !== 'index' && _ref !== 'thread') || !Conf['Image Expansion']) { + var conf, createSubEntry, el, name, subEntries, _ref; + if (!ImageExpand.enabled) { return; } el = $.el('span', { @@ -9819,9 +9732,9 @@ }); createSubEntry = ImageExpand.menu.createSubEntry; subEntries = []; - _ref1 = Config.imageExpansion; - for (name in _ref1) { - conf = _ref1[name]; + _ref = Config.imageExpansion; + for (name in _ref) { + conf = _ref[name]; subEntries.push(createSubEntry(name, conf[1])); } return Header.menu.addEntry({ @@ -9967,7 +9880,7 @@ ImageLoader = { init: function() { var prefetch, _ref; - if ((_ref = g.VIEW) !== 'index' && _ref !== 'thread') { + if (!(((_ref = g.VIEW) === 'index' || _ref === 'thread') && g.BOARD.ID !== 'f')) { return; } if (!(Conf['Image Prefetching'] || Conf['Replace JPG'] || Conf['Replace PNG'] || Conf['Replace GIF'] || Conf['Replace WEBM'])) { @@ -10434,23 +10347,20 @@ return; } if ($.hasClass(this, "embedded")) { - if (!$.hasClass(this.previousElementSibling, 'linkify')) { - $.rm(this.previousElementSibling); - } - this.previousElementSibling.hidden = false; + $.rm(this.nextElementSibling); this.textContent = '(embed)'; } else { - this.previousElementSibling.hidden = true; - $.before(this, Embedding.cb.embed(this)); + $.after(this, Embedding.cb.embed(this)); this.textContent = '(unembed)'; } return $.toggleClass(this, 'embedded'); }, embed: function(a) { - var el, type; - el = (type = Embedding.types[a.dataset.key]).el(a); - el.style.cssText = type.style != null ? type.style : "border: 0; width: 640px; height: 390px"; - return el; + var container, el, type; + container = $.el('div'); + $.add(container, el = (type = Embedding.types[a.dataset.key]).el(a)); + el.style.cssText = type.style != null ? type.style : "border:0;width:640px;height:390px"; + return container; }, title: function(req, data) { var key, link, link2, options, post, post2, service, status, text, uid, _i, _j, _len, _len1, _ref, _ref1; @@ -11226,22 +11136,7 @@ className: 'download-link', textContent: 'Download file' }); - $.on(a, 'click', function(e) { - if (this.protocol === 'blob:') { - return true; - } - e.preventDefault(); - return CrossOrigin.file(this.href, (function(_this) { - return function(blob) { - if (blob) { - _this.href = URL.createObjectURL(blob); - return _this.click(); - } else { - return new Notice('error', "Could not download " + _this.href, 30); - } - }; - })(this)); - }); + $.on(a, 'click', ImageCommon.download); return Menu.menu.addEntry({ el: a, order: 100, @@ -14101,7 +13996,7 @@ return Conf[hotkey] = key; }, keydown: function(e) { - var form, key, notification, notifications, op, searchInput, target, thread, threadRoot, _i, _len, _ref, _ref1, _ref2, _ref3, _ref4, _ref5, _ref6; + var form, key, notification, notifications, op, searchInput, target, thread, threadRoot, _i, _len, _ref, _ref1, _ref2, _ref3, _ref4, _ref5; if (!(key = Keybinds.keyCode(e))) { return; } @@ -14128,10 +14023,13 @@ Header.toggleBarVisibility(); break; case Conf['Open empty QR']: + if (!QR.postingIsEnabled) { + return; + } Keybinds.qr(); break; case Conf['Open QR']: - if (!threadRoot) { + if (!(QR.postingIsEnabled && threadRoot)) { return; } Keybinds.qr(threadRoot); @@ -14222,31 +14120,31 @@ ThreadWatcher.toggle(thread); break; case Conf['Expand image']: - if (!threadRoot) { + if (!(ImageExpand.enabled && threadRoot)) { return; } Keybinds.img(threadRoot); break; case Conf['Expand images']: - if (!threadRoot) { + if (!(ImageExpand.enabled && threadRoot)) { return; } Keybinds.img(threadRoot, true); break; case Conf['Open Gallery']: - if ((_ref2 = g.VIEW) !== 'index' && _ref2 !== 'thread') { + if (!Gallery.enabled) { return; } Gallery.cb.toggle(); break; case Conf['fappeTyme']: - if (!Conf['Fappe Tyme'] || ((_ref3 = g.VIEW) !== 'index' && _ref3 !== 'thread') || g.BOARD === 'f') { + if (!(Conf['Fappe Tyme'] && ((_ref2 = g.VIEW) === 'index' || _ref2 === 'thread') && g.BOARD.ID !== 'f')) { return; } FappeTyme.toggle('fappe'); break; case Conf['werkTyme']: - if (!Conf['Werk Tyme'] || ((_ref4 = g.VIEW) !== 'index' && _ref4 !== 'thread') || g.BOARD === 'f') { + if (!(Conf['Werk Tyme'] && ((_ref3 = g.VIEW) === 'index' || _ref3 === 'thread') && g.BOARD.ID !== 'f')) { return; } FappeTyme.toggle('werk'); @@ -14266,7 +14164,7 @@ return; } if (Conf['JSON Navigation']) { - if ((_ref5 = Conf['Index Mode']) !== 'paged' && _ref5 !== 'infinite') { + if ((_ref4 = Conf['Index Mode']) !== 'paged' && _ref4 !== 'infinite') { return; } $('.next button', Index.pagelist).click(); @@ -14281,7 +14179,7 @@ return; } if (Conf['JSON Navigation']) { - if ((_ref6 = Conf['Index Mode']) !== 'paged' && _ref6 !== 'infinite') { + if ((_ref5 = Conf['Index Mode']) !== 'paged' && _ref5 !== 'infinite') { return; } $('.prev button', Index.pagelist).click(); @@ -14425,17 +14323,11 @@ return key; }, qr: function(thread) { - if (!(Conf['Quick Reply'] && QR.postingIsEnabled)) { - return; - } QR.open(); if (thread != null) { QR.quote.call($('input', $('.post.highlight', thread) || thread)); } - QR.nodes.com.focus(); - if (Conf['QR Shortcut']) { - return $.rmClass($('.qr-shortcut'), 'disabled'); - } + return QR.nodes.com.focus(); }, tags: function(tag, ta) { var range, selEnd, selStart, supported, value; diff --git a/builds/4chan-X-noupdate.crx b/builds/4chan-X-noupdate.crx index 95e699069..79ffa8f1f 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 4df776a1a..81392088c 100644 --- a/builds/4chan-X-noupdate.user.js +++ b/builds/4chan-X-noupdate.user.js @@ -1,7 +1,7 @@ // Generated by CoffeeScript // ==UserScript== // @name 4chan X -// @version 1.9.20.8 +// @version 1.9.21.0 // @minGMVer 1.14 // @minFFVer 26 // @namespace 4chan-X @@ -24,12 +24,12 @@ // ==/UserScript== /* -* 4chan X - Version 1.9.20.8 +* 4chan X - Version 1.9.21.0 * * Licensed under the MIT license. * https://github.com/ccd0/4chan-x/blob/master/LICENSE * -* Appchan X Copyright © 2013-2014 Zixaphir +* Appchan X Copyright © 2013-2015 Zixaphir * http://zixaphir.github.io/appchan-x/ * 4chan x Copyright © 2009-2011 James Campos * https://github.com/aeosynth/4chan-x @@ -194,7 +194,7 @@ 'Werk Tyme': [false, 'Hide all post images when header menu item is checked.'], 'Autoplay': [true, 'Videos begin playing immediately when opened.'], 'Restart when Opened': [true, 'Restart GIFs and WebMs when you hover over or expand them.'], - 'Show Controls': [true, 'Show controls on videos expanded inline. Turn this off if you want to contract videos by clicking on them.'], + 'Show Controls': [true, 'Show controls on videos expanded inline.'], 'Loop in New Tab': [true, 'Loop videos opened in their own tabs.'] }, 'Menu': { @@ -395,7 +395,7 @@ doc = d.documentElement; g = { - VERSION: '1.9.20.8', + VERSION: '1.9.21.0', NAMESPACE: '4chan X.', NAME: '4chan X', FAQ: 'https://github.com/ccd0/4chan-x/wiki/Frequently-Asked-Questions', @@ -1510,7 +1510,6 @@ this.file.text = file.firstElementChild; this.file.thumb = $('.fileThumb > [data-md5]', file); this.file.fullImage = $('.full-image', file); - this.file.videoControls = $('.video-controls', this.file.text); if (contractThumb) { ImageExpand.contract(this); } @@ -3748,8 +3747,6 @@ }; flag = !flagCode ? { innerHTML: "" - } : false ? { - innerHTML: " \""" } : { innerHTML: " " }; @@ -6613,17 +6610,20 @@ mimeTypes: ['image/jpeg', 'image/png', 'image/gif', 'application/pdf', 'application/vnd.adobe.flash.movie', 'application/x-shockwave-flash', 'video/webm'], init: function() { var noscript, sc; - if (!Conf['Quick Reply'] || g.VIEW === 'archive') { + if (!Conf['Quick Reply']) { return; } this.db = new DataBoard('yourPosts'); this.posts = []; + if (g.VIEW === 'archive') { + return; + } $.globalEval('document.documentElement.dataset.jsEnabled = true;'); noscript = Conf['Force Noscript Captcha'] || !doc.dataset.jsEnabled; this.captcha = Captcha[noscript ? 'noscript' : 'v2']; if (Conf['QR Shortcut']) { sc = $.el('a', { - className: "qr-shortcut fa fa-comment-o " + (!Conf['Persistent QR'] ? 'disabled' : ''), + className: 'qr-shortcut fa fa-comment-o disabled', textContent: 'QR', title: 'Quick Reply', href: 'javascript:;' @@ -6634,11 +6634,9 @@ } if (Conf['Persistent QR'] || !QR.nodes || QR.nodes.el.hidden) { QR.open(); - QR.nodes.com.focus(); - return $.rmClass(this, 'disabled'); + return QR.nodes.com.focus(); } else { - QR.close(); - return $.addClass(this, 'disabled'); + return QR.close(); } }); Header.addShortcut(sc); @@ -6673,12 +6671,8 @@ }); QR.link = link.firstElementChild; $.on(link.firstChild, 'click', function() { - $.event('CloseMenu'); QR.open(); - QR.nodes.com.focus(); - if (Conf['QR Shortcut']) { - return $.rmClass($('.qr-shortcut'), 'disabled'); - } + return QR.nodes.com.focus(); }); if (Conf['Bottom QR Link'] && g.VIEW === 'thread') { linkBot = $.el('div', { @@ -6688,12 +6682,8 @@ innerHTML: "Reply to Thread" }); $.on(linkBot.firstElementChild, 'click', function() { - $.event('CloseMenu'); QR.open(); - QR.nodes.com.focus(); - if (Conf['QR Shortcut']) { - return $.rmClass($('.qr-shortcut'), 'disabled'); - } + return QR.nodes.com.focus(); }); $.prepend($('.navLinksBot'), linkBot); } @@ -6738,17 +6728,21 @@ } QR.nodes.el.hidden = false; QR.unhide(); - return; + } else { + try { + QR.dialog(); + } catch (_error) { + err = _error; + delete QR.nodes; + Main.handleErrors({ + message: 'Quick Reply dialog creation crashed.', + error: err + }); + return; + } } - try { - return QR.dialog(); - } catch (_error) { - err = _error; - delete QR.nodes; - return Main.handleErrors({ - message: 'Quick Reply dialog creation crashed.', - error: err - }); + if (Conf['QR Shortcut']) { + return $.rmClass($('.qr-shortcut'), 'disabled'); } }, close: function() { @@ -6762,7 +6756,7 @@ d.activeElement.blur(); $.rmClass(QR.nodes.el, 'dump'); if (Conf['QR Shortcut']) { - $.toggleClass($('.qr-shortcut'), 'disabled'); + $.addClass($('.qr-shortcut'), 'disabled'); } new QR.post(true); _ref = QR.posts.splice(0, QR.posts.length - 1); @@ -6956,10 +6950,7 @@ com.setSelectionRange(range, range); com.focus(); QR.selected.save(com); - QR.selected.save(thread); - if (Conf['QR Shortcut']) { - return $.rmClass($('.qr-shortcut'), 'disabled'); - } + return QR.selected.save(thread); }, characterCount: function() { var count, counter; @@ -7280,7 +7271,6 @@ nodes.flashTag.dataset["default"] = '4'; $.add(nodes.form, nodes.flashTag); } - QR.flagsInput(); $.on(nodes.filename.parentNode, 'click keydown', QR.openFileInput); $.on(nodes.autohide, 'change', QR.toggleHide); $.on(nodes.close, 'click', QR.close); @@ -7302,7 +7292,7 @@ return QR.selected.nodes.spoiler.click(); }); $.on(nodes.fileInput, 'change', QR.handleFiles); - items = ['thread', 'name', 'email', 'sub', 'com', 'filename', 'flag']; + items = ['thread', 'name', 'email', 'sub', 'com', 'filename']; i = 0; save = function() { return QR.selected.save(this); @@ -7335,43 +7325,6 @@ QR.captcha.setup(); return $.event('QRDialogCreation', null, dialog); }, - flags: function() { - var flag, fn, select, _i, _len, _ref; - select = $.el('select', { - name: 'flag', - className: 'flagSelector' - }); - fn = function(val) { - return $.add(select, $.el('option', { - value: val[0], - textContent: val[1] - })); - }; - _ref = [['0', 'None'], ['US', 'American'], ['KP', 'Best Korean'], ['BL', 'Black Nationalist'], ['CM', 'Communist'], ['CF', 'Confederate'], ['RE', 'Conservative'], ['EU', 'European'], ['GY', 'Gay'], ['PC', 'Hippie'], ['IL', 'Israeli'], ['DM', 'Liberal'], ['RP', 'Libertarian'], ['MF', 'Muslim'], ['NZ', 'Nazi'], ['OB', 'Obama'], ['PR', 'Pirate'], ['RB', 'Rebel'], ['TP', 'Tea Partier'], ['TX', 'Texan'], ['TR', 'Tree Hugger'], ['WP', 'White Supremacist']]; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - flag = _ref[_i]; - fn(flag); - } - return select; - }, - flagsInput: function() { - var flag, nodes; - nodes = QR.nodes; - if (!nodes) { - return; - } - if (nodes.flag) { - $.rm(nodes.flag); - delete nodes.flag; - } - if (false) { - flag = QR.flags(); - flag.dataset.name = 'flag'; - flag.dataset["default"] = '0'; - nodes.flag = flag; - return $.add(nodes.form, flag); - } - }, submit: function(e) { var captcha, cb, err, extra, filetag, formData, options, post, textOnly, thread, threadID; if (e != null) { @@ -7437,7 +7390,6 @@ upfile: post.file, filetag: filetag, spoiler: post.spoiler, - flag: post.flag, textonly: textOnly, mode: 'regist', pwd: QR.persona.pwd @@ -8459,8 +8411,7 @@ persona = _arg['QR.persona']; persona = { name: post.name, - email: /^sage$/.test(post.email) ? persona.email : post.email, - flag: post.flag + email: /^sage$/.test(post.email) ? persona.email : post.email }; return $.set('QR.persona', persona); }); @@ -8521,9 +8472,6 @@ _this.name = 'name' in QR.persona.always ? QR.persona.always.name : prev ? prev.name : persona.name; _this.email = 'email' in QR.persona.always ? QR.persona.always.email : prev && !/^sage$/.test(prev.email) ? prev.email : persona.email; _this.sub = 'sub' in QR.persona.always ? QR.persona.always.sub : ''; - if (QR.nodes.flag) { - _this.flag = prev ? prev.flag : persona.flag; - } if (QR.selected === _this) { return _this.load(); } @@ -8566,7 +8514,7 @@ if (this !== QR.selected) { return; } - _ref = ['thread', 'name', 'email', 'sub', 'com', 'fileButton', 'filename', 'spoiler', 'flag']; + _ref = ['thread', 'name', 'email', 'sub', 'com', 'fileButton', 'filename', 'spoiler']; for (_i = 0, _len = _ref.length; _i < _len; _i++) { name = _ref[_i]; if (node = QR.nodes[name]) { @@ -8600,7 +8548,7 @@ _Class.prototype.load = function() { var name, node, _i, _len, _ref; - _ref = ['thread', 'name', 'email', 'sub', 'com', 'filename', 'flag']; + _ref = ['thread', 'name', 'email', 'sub', 'com', 'filename']; for (_i = 0, _len = _ref.length; _i < _len; _i++) { name = _ref[_i]; if (!(node = QR.nodes[name])) { @@ -8650,7 +8598,7 @@ if (this !== QR.selected) { return; } - _ref = ['thread', 'name', 'email', 'sub', 'com', 'filename', 'spoiler', 'flag']; + _ref = ['thread', 'name', 'email', 'sub', 'com', 'filename', 'spoiler']; for (_i = 0, _len = _ref.length; _i < _len; _i++) { name = _ref[_i]; if (!(node = QR.nodes[name])) { @@ -8825,7 +8773,7 @@ FappeTyme = { init: function() { var el, lc, type, _i, _len, _ref, _ref1; - if (!(Conf['Fappe Tyme'] || Conf['Werk Tyme']) || ((_ref = g.VIEW) !== 'index' && _ref !== 'thread') || g.BOARD === 'f') { + if (!((Conf['Fappe Tyme'] || Conf['Werk Tyme']) && ((_ref = g.VIEW) === 'index' || _ref === 'thread') && g.BOARD.ID !== 'f')) { return; } this.nodes = {}; @@ -8897,7 +8845,7 @@ Gallery = { init: function() { var el, _ref; - if (((_ref = g.VIEW) !== 'index' && _ref !== 'thread') || g.BOARD === 'f' || !Conf['Gallery']) { + if (!(this.enabled = Conf['Gallery'] && ((_ref = g.VIEW) === 'index' || _ref === 'thread') && g.BOARD.ID !== 'f')) { return; } this.delay = Conf['Slide Delay']; @@ -8969,6 +8917,7 @@ cb = Gallery.cb; $.on(nodes.frame, 'click', cb.blank); $.on(nodes.next, 'click', cb.click); + $.on(nodes.name, 'click', ImageCommon.download); $.on($('.gal-prev', dialog), 'click', cb.prev); $.on($('.gal-next', dialog), 'click', cb.next); $.on($('.gal-start', dialog), 'click', cb.start); @@ -9167,7 +9116,7 @@ case 'Right': return Gallery.cb.next; case 'Enter': - return Gallery.cb.enterKey; + return Gallery.cb.advance; case 'Left': case '': return Gallery.cb.prev; @@ -9203,16 +9152,20 @@ next: function() { return Gallery.cb.open.call(Gallery.images[+Gallery.nodes.current.dataset.id + 1] || Gallery.images[0]); }, - enterKey: function() { + click: function(e) { + if (ImageCommon.onControls(e)) { + return; + } + e.preventDefault(); + return Gallery.cb.advance(); + }, + advance: function() { if (Gallery.nodes.current.paused) { return Gallery.nodes.current.play(); } else { return Gallery.cb.next(); } }, - click: function() { - return Gallery.cb[Gallery.nodes.current.controls ? 'stop' : 'enterKey'](); - }, toggle: function() { return (Gallery.nodes ? Gallery.cb.close : Gallery.build)(); }, @@ -9284,8 +9237,8 @@ }, menu: { init: function() { - var el, _ref; - if (((_ref = g.VIEW) !== 'index' && _ref !== 'thread') || !Conf['Gallery']) { + var el; + if (!Gallery.enabled) { return; } el = $.el('span', { @@ -9439,13 +9392,32 @@ }); }; return $.on(video, 'mouseover', handler); + }, + onControls: function(e) { + return e.target.controls && e.target.getBoundingClientRect().bottom - e.clientY < 35; + }, + download: function(e) { + if (this.protocol === 'blob:') { + return true; + } + e.preventDefault(); + return CrossOrigin.file(this.href, (function(_this) { + return function(blob) { + if (blob) { + _this.href = URL.createObjectURL(blob); + return _this.click(); + } else { + return new Notice('error', "Could not download " + _this.href, 30); + } + }; + })(this)); } }; ImageExpand = { init: function() { var _ref; - if (((_ref = g.VIEW) !== 'index' && _ref !== 'thread') || !Conf['Image Expansion']) { + if (!(this.enabled = Conf['Image Expansion'] && ((_ref = g.VIEW) === 'index' || _ref === 'thread') && g.BOARD.ID !== 'f')) { return; } this.EAI = $.el('a', { @@ -9457,12 +9429,6 @@ $.on(this.EAI, 'click', this.cb.toggleAll); Header.addShortcut(this.EAI, 3); $.on(d, 'scroll visibilitychange', this.cb.playVideos); - this.videoControls = $.el('span', { - className: 'video-controls' - }); - $.extend(this.videoControls, { - innerHTML: " contract" - }); return Post.callbacks.push({ name: 'Image Expansion', cb: this.node @@ -9479,7 +9445,6 @@ ImageExpand.contract(this); return ImageExpand.expand(this); } else if (this.file.isExpanded && this.file.isVideo) { - ImageExpand.setupVideoCB(this); return ImageExpand.setupVideo(this, !((_ref = this.origin.file.fullImage) != null ? _ref.paused : void 0) || this.origin.file.wasPlaying, this.file.fullImage.controls); } } else if (ImageExpand.on && !this.isHidden && !this.isFetchedQuote && (Conf['Expand spoilers'] || !this.file.isSpoiler) && (Conf['Expand videos'] || !this.file.isVideo)) { @@ -9488,17 +9453,21 @@ }, cb: { toggle: function(e) { - var file, post; + var file, post, _ref; if (e.shiftKey || e.altKey || e.ctrlKey || e.metaKey || e.button !== 0) { return; } post = Get.postFromNode(this); file = post.file; - if (file.isExpanded && file.isVideo && file.fullImage.controls) { + if (file.isExpanded && ImageCommon.onControls(e)) { return; } e.preventDefault(); - return ImageExpand.toggle(post); + if ((_ref = file.fullImage) != null ? _ref.paused : void 0) { + return file.fullImage.play(); + } else { + return ImageExpand.toggle(post); + } }, toggleAll: function() { var func, toggle; @@ -9580,7 +9549,7 @@ } }, contract: function(post) { - var bottom, cb, el, eventName, file, oldHeight, scrollY, top, x, _i, _len, _ref, _ref1; + var bottom, el, file, oldHeight, scrollY, top, x, _i, _len, _ref; file = post.file; if (el = file.fullImage) { top = Header.getTopOf(el); @@ -9590,12 +9559,9 @@ } $.rmClass(post.nodes.root, 'expanded-image'); $.rmClass(file.thumb, 'expanding'); - if (file.videoControls) { - $.rm(file.videoControls); - } file.thumb.parentNode.href = file.URL; file.thumb.parentNode.target = '_blank'; - _ref = ['isExpanding', 'isExpanded', 'videoControls', 'wasPlaying', 'scrollIntoView']; + _ref = ['isExpanding', 'isExpanded', 'wasPlaying', 'scrollIntoView']; for (_i = 0, _len = _ref.length; _i < _len; _i++) { x = _ref[_i]; delete file[x]; @@ -9617,11 +9583,6 @@ ImageCommon.pushCache(el); if (file.isVideo) { el.pause(); - _ref1 = ImageExpand.videoCB; - for (eventName in _ref1) { - cb = _ref1[eventName]; - $.off(el, eventName, cb); - } } if (Conf['Restart when Opened']) { ImageCommon.rewind(file.thumb); @@ -9665,14 +9626,9 @@ el.className = 'full-image'; $.after(thumb, el); if (isVideo) { - if (Conf['Show Controls'] && !file.videoControls) { - file.videoControls = ImageExpand.videoControls.cloneNode(true); - $.add(file.text, file.videoControls); - } thumb.parentNode.removeAttribute('href'); thumb.parentNode.removeAttribute('target'); el.loop = true; - ImageExpand.setupVideoCB(post); } if (!isVideo) { return $.asap((function() { @@ -9740,49 +9696,6 @@ return ImageCommon.addControls(fullImage); } }, - videoCB: (function() { - var mousedown; - mousedown = false; - return { - mouseover: function() { - return mousedown = false; - }, - mousedown: function(e) { - if (e.button === 0) { - return mousedown = true; - } - }, - mouseup: function(e) { - if (e.button === 0) { - return mousedown = false; - } - }, - mouseout: function(e) { - if (mousedown && e.clientX <= this.getBoundingClientRect().left) { - return ImageExpand.toggle(Get.postFromNode(this)); - } - }, - click: function(e) { - if (this.paused && !this.controls) { - this.play(); - return e.stopPropagation(); - } - } - }; - })(), - setupVideoCB: function(post) { - var cb, eventName, _ref; - _ref = ImageExpand.videoCB; - for (eventName in _ref) { - cb = _ref[eventName]; - $.on(post.file.fullImage, eventName, cb); - } - if (post.file.videoControls) { - return $.on(post.file.videoControls.firstElementChild, 'click', function() { - return ImageExpand.toggle(post); - }); - } - }, error: function() { var post; post = Get.postFromNode(this); @@ -9808,8 +9721,8 @@ }, menu: { init: function() { - var conf, createSubEntry, el, name, subEntries, _ref, _ref1; - if (((_ref = g.VIEW) !== 'index' && _ref !== 'thread') || !Conf['Image Expansion']) { + var conf, createSubEntry, el, name, subEntries, _ref; + if (!ImageExpand.enabled) { return; } el = $.el('span', { @@ -9818,9 +9731,9 @@ }); createSubEntry = ImageExpand.menu.createSubEntry; subEntries = []; - _ref1 = Config.imageExpansion; - for (name in _ref1) { - conf = _ref1[name]; + _ref = Config.imageExpansion; + for (name in _ref) { + conf = _ref[name]; subEntries.push(createSubEntry(name, conf[1])); } return Header.menu.addEntry({ @@ -9966,7 +9879,7 @@ ImageLoader = { init: function() { var prefetch, _ref; - if ((_ref = g.VIEW) !== 'index' && _ref !== 'thread') { + if (!(((_ref = g.VIEW) === 'index' || _ref === 'thread') && g.BOARD.ID !== 'f')) { return; } if (!(Conf['Image Prefetching'] || Conf['Replace JPG'] || Conf['Replace PNG'] || Conf['Replace GIF'] || Conf['Replace WEBM'])) { @@ -10433,23 +10346,20 @@ return; } if ($.hasClass(this, "embedded")) { - if (!$.hasClass(this.previousElementSibling, 'linkify')) { - $.rm(this.previousElementSibling); - } - this.previousElementSibling.hidden = false; + $.rm(this.nextElementSibling); this.textContent = '(embed)'; } else { - this.previousElementSibling.hidden = true; - $.before(this, Embedding.cb.embed(this)); + $.after(this, Embedding.cb.embed(this)); this.textContent = '(unembed)'; } return $.toggleClass(this, 'embedded'); }, embed: function(a) { - var el, type; - el = (type = Embedding.types[a.dataset.key]).el(a); - el.style.cssText = type.style != null ? type.style : "border: 0; width: 640px; height: 390px"; - return el; + var container, el, type; + container = $.el('div'); + $.add(container, el = (type = Embedding.types[a.dataset.key]).el(a)); + el.style.cssText = type.style != null ? type.style : "border:0;width:640px;height:390px"; + return container; }, title: function(req, data) { var key, link, link2, options, post, post2, service, status, text, uid, _i, _j, _len, _len1, _ref, _ref1; @@ -11225,22 +11135,7 @@ className: 'download-link', textContent: 'Download file' }); - $.on(a, 'click', function(e) { - if (this.protocol === 'blob:') { - return true; - } - e.preventDefault(); - return CrossOrigin.file(this.href, (function(_this) { - return function(blob) { - if (blob) { - _this.href = URL.createObjectURL(blob); - return _this.click(); - } else { - return new Notice('error', "Could not download " + _this.href, 30); - } - }; - })(this)); - }); + $.on(a, 'click', ImageCommon.download); return Menu.menu.addEntry({ el: a, order: 100, @@ -14100,7 +13995,7 @@ return Conf[hotkey] = key; }, keydown: function(e) { - var form, key, notification, notifications, op, searchInput, target, thread, threadRoot, _i, _len, _ref, _ref1, _ref2, _ref3, _ref4, _ref5, _ref6; + var form, key, notification, notifications, op, searchInput, target, thread, threadRoot, _i, _len, _ref, _ref1, _ref2, _ref3, _ref4, _ref5; if (!(key = Keybinds.keyCode(e))) { return; } @@ -14127,10 +14022,13 @@ Header.toggleBarVisibility(); break; case Conf['Open empty QR']: + if (!QR.postingIsEnabled) { + return; + } Keybinds.qr(); break; case Conf['Open QR']: - if (!threadRoot) { + if (!(QR.postingIsEnabled && threadRoot)) { return; } Keybinds.qr(threadRoot); @@ -14221,31 +14119,31 @@ ThreadWatcher.toggle(thread); break; case Conf['Expand image']: - if (!threadRoot) { + if (!(ImageExpand.enabled && threadRoot)) { return; } Keybinds.img(threadRoot); break; case Conf['Expand images']: - if (!threadRoot) { + if (!(ImageExpand.enabled && threadRoot)) { return; } Keybinds.img(threadRoot, true); break; case Conf['Open Gallery']: - if ((_ref2 = g.VIEW) !== 'index' && _ref2 !== 'thread') { + if (!Gallery.enabled) { return; } Gallery.cb.toggle(); break; case Conf['fappeTyme']: - if (!Conf['Fappe Tyme'] || ((_ref3 = g.VIEW) !== 'index' && _ref3 !== 'thread') || g.BOARD === 'f') { + if (!(Conf['Fappe Tyme'] && ((_ref2 = g.VIEW) === 'index' || _ref2 === 'thread') && g.BOARD.ID !== 'f')) { return; } FappeTyme.toggle('fappe'); break; case Conf['werkTyme']: - if (!Conf['Werk Tyme'] || ((_ref4 = g.VIEW) !== 'index' && _ref4 !== 'thread') || g.BOARD === 'f') { + if (!(Conf['Werk Tyme'] && ((_ref3 = g.VIEW) === 'index' || _ref3 === 'thread') && g.BOARD.ID !== 'f')) { return; } FappeTyme.toggle('werk'); @@ -14265,7 +14163,7 @@ return; } if (Conf['JSON Navigation']) { - if ((_ref5 = Conf['Index Mode']) !== 'paged' && _ref5 !== 'infinite') { + if ((_ref4 = Conf['Index Mode']) !== 'paged' && _ref4 !== 'infinite') { return; } $('.next button', Index.pagelist).click(); @@ -14280,7 +14178,7 @@ return; } if (Conf['JSON Navigation']) { - if ((_ref6 = Conf['Index Mode']) !== 'paged' && _ref6 !== 'infinite') { + if ((_ref5 = Conf['Index Mode']) !== 'paged' && _ref5 !== 'infinite') { return; } $('.prev button', Index.pagelist).click(); @@ -14424,17 +14322,11 @@ return key; }, qr: function(thread) { - if (!(Conf['Quick Reply'] && QR.postingIsEnabled)) { - return; - } QR.open(); if (thread != null) { QR.quote.call($('input', $('.post.highlight', thread) || thread)); } - QR.nodes.com.focus(); - if (Conf['QR Shortcut']) { - return $.rmClass($('.qr-shortcut'), 'disabled'); - } + return QR.nodes.com.focus(); }, tags: function(tag, ta) { var range, selEnd, selStart, supported, value; diff --git a/builds/4chan-X.crx b/builds/4chan-X.crx index 7a57f79da..e5904e2bf 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 9028da6b2..995c76e11 100644 --- a/builds/4chan-X.meta.js +++ b/builds/4chan-X.meta.js @@ -1,6 +1,6 @@ // ==UserScript== // @name 4chan X -// @version 1.9.20.8 +// @version 1.9.21.0 // @minGMVer 1.14 // @minFFVer 26 // @namespace 4chan-X diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index b43a7e225..8854b2ac4 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.9.20.8 +// @version 1.9.21.0 // @minGMVer 1.14 // @minFFVer 26 // @namespace 4chan-X @@ -25,12 +25,12 @@ // ==/UserScript== /* -* 4chan X - Version 1.9.20.8 +* 4chan X - Version 1.9.21.0 * * Licensed under the MIT license. * https://github.com/ccd0/4chan-x/blob/master/LICENSE * -* Appchan X Copyright © 2013-2014 Zixaphir +* Appchan X Copyright © 2013-2015 Zixaphir * http://zixaphir.github.io/appchan-x/ * 4chan x Copyright © 2009-2011 James Campos * https://github.com/aeosynth/4chan-x @@ -195,7 +195,7 @@ 'Werk Tyme': [false, 'Hide all post images when header menu item is checked.'], 'Autoplay': [true, 'Videos begin playing immediately when opened.'], 'Restart when Opened': [true, 'Restart GIFs and WebMs when you hover over or expand them.'], - 'Show Controls': [true, 'Show controls on videos expanded inline. Turn this off if you want to contract videos by clicking on them.'], + 'Show Controls': [true, 'Show controls on videos expanded inline.'], 'Loop in New Tab': [true, 'Loop videos opened in their own tabs.'] }, 'Menu': { @@ -396,7 +396,7 @@ doc = d.documentElement; g = { - VERSION: '1.9.20.8', + VERSION: '1.9.21.0', NAMESPACE: '4chan X.', NAME: '4chan X', FAQ: 'https://github.com/ccd0/4chan-x/wiki/Frequently-Asked-Questions', @@ -1511,7 +1511,6 @@ this.file.text = file.firstElementChild; this.file.thumb = $('.fileThumb > [data-md5]', file); this.file.fullImage = $('.full-image', file); - this.file.videoControls = $('.video-controls', this.file.text); if (contractThumb) { ImageExpand.contract(this); } @@ -3749,8 +3748,6 @@ }; flag = !flagCode ? { innerHTML: "" - } : false ? { - innerHTML: " \""" } : { innerHTML: " " }; @@ -6614,17 +6611,20 @@ mimeTypes: ['image/jpeg', 'image/png', 'image/gif', 'application/pdf', 'application/vnd.adobe.flash.movie', 'application/x-shockwave-flash', 'video/webm'], init: function() { var noscript, sc; - if (!Conf['Quick Reply'] || g.VIEW === 'archive') { + if (!Conf['Quick Reply']) { return; } this.db = new DataBoard('yourPosts'); this.posts = []; + if (g.VIEW === 'archive') { + return; + } $.globalEval('document.documentElement.dataset.jsEnabled = true;'); noscript = Conf['Force Noscript Captcha'] || !doc.dataset.jsEnabled; this.captcha = Captcha[noscript ? 'noscript' : 'v2']; if (Conf['QR Shortcut']) { sc = $.el('a', { - className: "qr-shortcut fa fa-comment-o " + (!Conf['Persistent QR'] ? 'disabled' : ''), + className: 'qr-shortcut fa fa-comment-o disabled', textContent: 'QR', title: 'Quick Reply', href: 'javascript:;' @@ -6635,11 +6635,9 @@ } if (Conf['Persistent QR'] || !QR.nodes || QR.nodes.el.hidden) { QR.open(); - QR.nodes.com.focus(); - return $.rmClass(this, 'disabled'); + return QR.nodes.com.focus(); } else { - QR.close(); - return $.addClass(this, 'disabled'); + return QR.close(); } }); Header.addShortcut(sc); @@ -6674,12 +6672,8 @@ }); QR.link = link.firstElementChild; $.on(link.firstChild, 'click', function() { - $.event('CloseMenu'); QR.open(); - QR.nodes.com.focus(); - if (Conf['QR Shortcut']) { - return $.rmClass($('.qr-shortcut'), 'disabled'); - } + return QR.nodes.com.focus(); }); if (Conf['Bottom QR Link'] && g.VIEW === 'thread') { linkBot = $.el('div', { @@ -6689,12 +6683,8 @@ innerHTML: "Reply to Thread" }); $.on(linkBot.firstElementChild, 'click', function() { - $.event('CloseMenu'); QR.open(); - QR.nodes.com.focus(); - if (Conf['QR Shortcut']) { - return $.rmClass($('.qr-shortcut'), 'disabled'); - } + return QR.nodes.com.focus(); }); $.prepend($('.navLinksBot'), linkBot); } @@ -6739,17 +6729,21 @@ } QR.nodes.el.hidden = false; QR.unhide(); - return; + } else { + try { + QR.dialog(); + } catch (_error) { + err = _error; + delete QR.nodes; + Main.handleErrors({ + message: 'Quick Reply dialog creation crashed.', + error: err + }); + return; + } } - try { - return QR.dialog(); - } catch (_error) { - err = _error; - delete QR.nodes; - return Main.handleErrors({ - message: 'Quick Reply dialog creation crashed.', - error: err - }); + if (Conf['QR Shortcut']) { + return $.rmClass($('.qr-shortcut'), 'disabled'); } }, close: function() { @@ -6763,7 +6757,7 @@ d.activeElement.blur(); $.rmClass(QR.nodes.el, 'dump'); if (Conf['QR Shortcut']) { - $.toggleClass($('.qr-shortcut'), 'disabled'); + $.addClass($('.qr-shortcut'), 'disabled'); } new QR.post(true); _ref = QR.posts.splice(0, QR.posts.length - 1); @@ -6957,10 +6951,7 @@ com.setSelectionRange(range, range); com.focus(); QR.selected.save(com); - QR.selected.save(thread); - if (Conf['QR Shortcut']) { - return $.rmClass($('.qr-shortcut'), 'disabled'); - } + return QR.selected.save(thread); }, characterCount: function() { var count, counter; @@ -7281,7 +7272,6 @@ nodes.flashTag.dataset["default"] = '4'; $.add(nodes.form, nodes.flashTag); } - QR.flagsInput(); $.on(nodes.filename.parentNode, 'click keydown', QR.openFileInput); $.on(nodes.autohide, 'change', QR.toggleHide); $.on(nodes.close, 'click', QR.close); @@ -7303,7 +7293,7 @@ return QR.selected.nodes.spoiler.click(); }); $.on(nodes.fileInput, 'change', QR.handleFiles); - items = ['thread', 'name', 'email', 'sub', 'com', 'filename', 'flag']; + items = ['thread', 'name', 'email', 'sub', 'com', 'filename']; i = 0; save = function() { return QR.selected.save(this); @@ -7336,43 +7326,6 @@ QR.captcha.setup(); return $.event('QRDialogCreation', null, dialog); }, - flags: function() { - var flag, fn, select, _i, _len, _ref; - select = $.el('select', { - name: 'flag', - className: 'flagSelector' - }); - fn = function(val) { - return $.add(select, $.el('option', { - value: val[0], - textContent: val[1] - })); - }; - _ref = [['0', 'None'], ['US', 'American'], ['KP', 'Best Korean'], ['BL', 'Black Nationalist'], ['CM', 'Communist'], ['CF', 'Confederate'], ['RE', 'Conservative'], ['EU', 'European'], ['GY', 'Gay'], ['PC', 'Hippie'], ['IL', 'Israeli'], ['DM', 'Liberal'], ['RP', 'Libertarian'], ['MF', 'Muslim'], ['NZ', 'Nazi'], ['OB', 'Obama'], ['PR', 'Pirate'], ['RB', 'Rebel'], ['TP', 'Tea Partier'], ['TX', 'Texan'], ['TR', 'Tree Hugger'], ['WP', 'White Supremacist']]; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - flag = _ref[_i]; - fn(flag); - } - return select; - }, - flagsInput: function() { - var flag, nodes; - nodes = QR.nodes; - if (!nodes) { - return; - } - if (nodes.flag) { - $.rm(nodes.flag); - delete nodes.flag; - } - if (false) { - flag = QR.flags(); - flag.dataset.name = 'flag'; - flag.dataset["default"] = '0'; - nodes.flag = flag; - return $.add(nodes.form, flag); - } - }, submit: function(e) { var captcha, cb, err, extra, filetag, formData, options, post, textOnly, thread, threadID; if (e != null) { @@ -7438,7 +7391,6 @@ upfile: post.file, filetag: filetag, spoiler: post.spoiler, - flag: post.flag, textonly: textOnly, mode: 'regist', pwd: QR.persona.pwd @@ -8460,8 +8412,7 @@ persona = _arg['QR.persona']; persona = { name: post.name, - email: /^sage$/.test(post.email) ? persona.email : post.email, - flag: post.flag + email: /^sage$/.test(post.email) ? persona.email : post.email }; return $.set('QR.persona', persona); }); @@ -8522,9 +8473,6 @@ _this.name = 'name' in QR.persona.always ? QR.persona.always.name : prev ? prev.name : persona.name; _this.email = 'email' in QR.persona.always ? QR.persona.always.email : prev && !/^sage$/.test(prev.email) ? prev.email : persona.email; _this.sub = 'sub' in QR.persona.always ? QR.persona.always.sub : ''; - if (QR.nodes.flag) { - _this.flag = prev ? prev.flag : persona.flag; - } if (QR.selected === _this) { return _this.load(); } @@ -8567,7 +8515,7 @@ if (this !== QR.selected) { return; } - _ref = ['thread', 'name', 'email', 'sub', 'com', 'fileButton', 'filename', 'spoiler', 'flag']; + _ref = ['thread', 'name', 'email', 'sub', 'com', 'fileButton', 'filename', 'spoiler']; for (_i = 0, _len = _ref.length; _i < _len; _i++) { name = _ref[_i]; if (node = QR.nodes[name]) { @@ -8601,7 +8549,7 @@ _Class.prototype.load = function() { var name, node, _i, _len, _ref; - _ref = ['thread', 'name', 'email', 'sub', 'com', 'filename', 'flag']; + _ref = ['thread', 'name', 'email', 'sub', 'com', 'filename']; for (_i = 0, _len = _ref.length; _i < _len; _i++) { name = _ref[_i]; if (!(node = QR.nodes[name])) { @@ -8651,7 +8599,7 @@ if (this !== QR.selected) { return; } - _ref = ['thread', 'name', 'email', 'sub', 'com', 'filename', 'spoiler', 'flag']; + _ref = ['thread', 'name', 'email', 'sub', 'com', 'filename', 'spoiler']; for (_i = 0, _len = _ref.length; _i < _len; _i++) { name = _ref[_i]; if (!(node = QR.nodes[name])) { @@ -8826,7 +8774,7 @@ FappeTyme = { init: function() { var el, lc, type, _i, _len, _ref, _ref1; - if (!(Conf['Fappe Tyme'] || Conf['Werk Tyme']) || ((_ref = g.VIEW) !== 'index' && _ref !== 'thread') || g.BOARD === 'f') { + if (!((Conf['Fappe Tyme'] || Conf['Werk Tyme']) && ((_ref = g.VIEW) === 'index' || _ref === 'thread') && g.BOARD.ID !== 'f')) { return; } this.nodes = {}; @@ -8898,7 +8846,7 @@ Gallery = { init: function() { var el, _ref; - if (((_ref = g.VIEW) !== 'index' && _ref !== 'thread') || g.BOARD === 'f' || !Conf['Gallery']) { + if (!(this.enabled = Conf['Gallery'] && ((_ref = g.VIEW) === 'index' || _ref === 'thread') && g.BOARD.ID !== 'f')) { return; } this.delay = Conf['Slide Delay']; @@ -8970,6 +8918,7 @@ cb = Gallery.cb; $.on(nodes.frame, 'click', cb.blank); $.on(nodes.next, 'click', cb.click); + $.on(nodes.name, 'click', ImageCommon.download); $.on($('.gal-prev', dialog), 'click', cb.prev); $.on($('.gal-next', dialog), 'click', cb.next); $.on($('.gal-start', dialog), 'click', cb.start); @@ -9168,7 +9117,7 @@ case 'Right': return Gallery.cb.next; case 'Enter': - return Gallery.cb.enterKey; + return Gallery.cb.advance; case 'Left': case '': return Gallery.cb.prev; @@ -9204,16 +9153,20 @@ next: function() { return Gallery.cb.open.call(Gallery.images[+Gallery.nodes.current.dataset.id + 1] || Gallery.images[0]); }, - enterKey: function() { + click: function(e) { + if (ImageCommon.onControls(e)) { + return; + } + e.preventDefault(); + return Gallery.cb.advance(); + }, + advance: function() { if (Gallery.nodes.current.paused) { return Gallery.nodes.current.play(); } else { return Gallery.cb.next(); } }, - click: function() { - return Gallery.cb[Gallery.nodes.current.controls ? 'stop' : 'enterKey'](); - }, toggle: function() { return (Gallery.nodes ? Gallery.cb.close : Gallery.build)(); }, @@ -9285,8 +9238,8 @@ }, menu: { init: function() { - var el, _ref; - if (((_ref = g.VIEW) !== 'index' && _ref !== 'thread') || !Conf['Gallery']) { + var el; + if (!Gallery.enabled) { return; } el = $.el('span', { @@ -9440,13 +9393,32 @@ }); }; return $.on(video, 'mouseover', handler); + }, + onControls: function(e) { + return e.target.controls && e.target.getBoundingClientRect().bottom - e.clientY < 35; + }, + download: function(e) { + if (this.protocol === 'blob:') { + return true; + } + e.preventDefault(); + return CrossOrigin.file(this.href, (function(_this) { + return function(blob) { + if (blob) { + _this.href = URL.createObjectURL(blob); + return _this.click(); + } else { + return new Notice('error', "Could not download " + _this.href, 30); + } + }; + })(this)); } }; ImageExpand = { init: function() { var _ref; - if (((_ref = g.VIEW) !== 'index' && _ref !== 'thread') || !Conf['Image Expansion']) { + if (!(this.enabled = Conf['Image Expansion'] && ((_ref = g.VIEW) === 'index' || _ref === 'thread') && g.BOARD.ID !== 'f')) { return; } this.EAI = $.el('a', { @@ -9458,12 +9430,6 @@ $.on(this.EAI, 'click', this.cb.toggleAll); Header.addShortcut(this.EAI, 3); $.on(d, 'scroll visibilitychange', this.cb.playVideos); - this.videoControls = $.el('span', { - className: 'video-controls' - }); - $.extend(this.videoControls, { - innerHTML: " contract" - }); return Post.callbacks.push({ name: 'Image Expansion', cb: this.node @@ -9480,7 +9446,6 @@ ImageExpand.contract(this); return ImageExpand.expand(this); } else if (this.file.isExpanded && this.file.isVideo) { - ImageExpand.setupVideoCB(this); return ImageExpand.setupVideo(this, !((_ref = this.origin.file.fullImage) != null ? _ref.paused : void 0) || this.origin.file.wasPlaying, this.file.fullImage.controls); } } else if (ImageExpand.on && !this.isHidden && !this.isFetchedQuote && (Conf['Expand spoilers'] || !this.file.isSpoiler) && (Conf['Expand videos'] || !this.file.isVideo)) { @@ -9489,17 +9454,21 @@ }, cb: { toggle: function(e) { - var file, post; + var file, post, _ref; if (e.shiftKey || e.altKey || e.ctrlKey || e.metaKey || e.button !== 0) { return; } post = Get.postFromNode(this); file = post.file; - if (file.isExpanded && file.isVideo && file.fullImage.controls) { + if (file.isExpanded && ImageCommon.onControls(e)) { return; } e.preventDefault(); - return ImageExpand.toggle(post); + if ((_ref = file.fullImage) != null ? _ref.paused : void 0) { + return file.fullImage.play(); + } else { + return ImageExpand.toggle(post); + } }, toggleAll: function() { var func, toggle; @@ -9581,7 +9550,7 @@ } }, contract: function(post) { - var bottom, cb, el, eventName, file, oldHeight, scrollY, top, x, _i, _len, _ref, _ref1; + var bottom, el, file, oldHeight, scrollY, top, x, _i, _len, _ref; file = post.file; if (el = file.fullImage) { top = Header.getTopOf(el); @@ -9591,12 +9560,9 @@ } $.rmClass(post.nodes.root, 'expanded-image'); $.rmClass(file.thumb, 'expanding'); - if (file.videoControls) { - $.rm(file.videoControls); - } file.thumb.parentNode.href = file.URL; file.thumb.parentNode.target = '_blank'; - _ref = ['isExpanding', 'isExpanded', 'videoControls', 'wasPlaying', 'scrollIntoView']; + _ref = ['isExpanding', 'isExpanded', 'wasPlaying', 'scrollIntoView']; for (_i = 0, _len = _ref.length; _i < _len; _i++) { x = _ref[_i]; delete file[x]; @@ -9618,11 +9584,6 @@ ImageCommon.pushCache(el); if (file.isVideo) { el.pause(); - _ref1 = ImageExpand.videoCB; - for (eventName in _ref1) { - cb = _ref1[eventName]; - $.off(el, eventName, cb); - } } if (Conf['Restart when Opened']) { ImageCommon.rewind(file.thumb); @@ -9666,14 +9627,9 @@ el.className = 'full-image'; $.after(thumb, el); if (isVideo) { - if (Conf['Show Controls'] && !file.videoControls) { - file.videoControls = ImageExpand.videoControls.cloneNode(true); - $.add(file.text, file.videoControls); - } thumb.parentNode.removeAttribute('href'); thumb.parentNode.removeAttribute('target'); el.loop = true; - ImageExpand.setupVideoCB(post); } if (!isVideo) { return $.asap((function() { @@ -9741,49 +9697,6 @@ return ImageCommon.addControls(fullImage); } }, - videoCB: (function() { - var mousedown; - mousedown = false; - return { - mouseover: function() { - return mousedown = false; - }, - mousedown: function(e) { - if (e.button === 0) { - return mousedown = true; - } - }, - mouseup: function(e) { - if (e.button === 0) { - return mousedown = false; - } - }, - mouseout: function(e) { - if (mousedown && e.clientX <= this.getBoundingClientRect().left) { - return ImageExpand.toggle(Get.postFromNode(this)); - } - }, - click: function(e) { - if (this.paused && !this.controls) { - this.play(); - return e.stopPropagation(); - } - } - }; - })(), - setupVideoCB: function(post) { - var cb, eventName, _ref; - _ref = ImageExpand.videoCB; - for (eventName in _ref) { - cb = _ref[eventName]; - $.on(post.file.fullImage, eventName, cb); - } - if (post.file.videoControls) { - return $.on(post.file.videoControls.firstElementChild, 'click', function() { - return ImageExpand.toggle(post); - }); - } - }, error: function() { var post; post = Get.postFromNode(this); @@ -9809,8 +9722,8 @@ }, menu: { init: function() { - var conf, createSubEntry, el, name, subEntries, _ref, _ref1; - if (((_ref = g.VIEW) !== 'index' && _ref !== 'thread') || !Conf['Image Expansion']) { + var conf, createSubEntry, el, name, subEntries, _ref; + if (!ImageExpand.enabled) { return; } el = $.el('span', { @@ -9819,9 +9732,9 @@ }); createSubEntry = ImageExpand.menu.createSubEntry; subEntries = []; - _ref1 = Config.imageExpansion; - for (name in _ref1) { - conf = _ref1[name]; + _ref = Config.imageExpansion; + for (name in _ref) { + conf = _ref[name]; subEntries.push(createSubEntry(name, conf[1])); } return Header.menu.addEntry({ @@ -9967,7 +9880,7 @@ ImageLoader = { init: function() { var prefetch, _ref; - if ((_ref = g.VIEW) !== 'index' && _ref !== 'thread') { + if (!(((_ref = g.VIEW) === 'index' || _ref === 'thread') && g.BOARD.ID !== 'f')) { return; } if (!(Conf['Image Prefetching'] || Conf['Replace JPG'] || Conf['Replace PNG'] || Conf['Replace GIF'] || Conf['Replace WEBM'])) { @@ -10434,23 +10347,20 @@ return; } if ($.hasClass(this, "embedded")) { - if (!$.hasClass(this.previousElementSibling, 'linkify')) { - $.rm(this.previousElementSibling); - } - this.previousElementSibling.hidden = false; + $.rm(this.nextElementSibling); this.textContent = '(embed)'; } else { - this.previousElementSibling.hidden = true; - $.before(this, Embedding.cb.embed(this)); + $.after(this, Embedding.cb.embed(this)); this.textContent = '(unembed)'; } return $.toggleClass(this, 'embedded'); }, embed: function(a) { - var el, type; - el = (type = Embedding.types[a.dataset.key]).el(a); - el.style.cssText = type.style != null ? type.style : "border: 0; width: 640px; height: 390px"; - return el; + var container, el, type; + container = $.el('div'); + $.add(container, el = (type = Embedding.types[a.dataset.key]).el(a)); + el.style.cssText = type.style != null ? type.style : "border:0;width:640px;height:390px"; + return container; }, title: function(req, data) { var key, link, link2, options, post, post2, service, status, text, uid, _i, _j, _len, _len1, _ref, _ref1; @@ -11226,22 +11136,7 @@ className: 'download-link', textContent: 'Download file' }); - $.on(a, 'click', function(e) { - if (this.protocol === 'blob:') { - return true; - } - e.preventDefault(); - return CrossOrigin.file(this.href, (function(_this) { - return function(blob) { - if (blob) { - _this.href = URL.createObjectURL(blob); - return _this.click(); - } else { - return new Notice('error', "Could not download " + _this.href, 30); - } - }; - })(this)); - }); + $.on(a, 'click', ImageCommon.download); return Menu.menu.addEntry({ el: a, order: 100, @@ -14101,7 +13996,7 @@ return Conf[hotkey] = key; }, keydown: function(e) { - var form, key, notification, notifications, op, searchInput, target, thread, threadRoot, _i, _len, _ref, _ref1, _ref2, _ref3, _ref4, _ref5, _ref6; + var form, key, notification, notifications, op, searchInput, target, thread, threadRoot, _i, _len, _ref, _ref1, _ref2, _ref3, _ref4, _ref5; if (!(key = Keybinds.keyCode(e))) { return; } @@ -14128,10 +14023,13 @@ Header.toggleBarVisibility(); break; case Conf['Open empty QR']: + if (!QR.postingIsEnabled) { + return; + } Keybinds.qr(); break; case Conf['Open QR']: - if (!threadRoot) { + if (!(QR.postingIsEnabled && threadRoot)) { return; } Keybinds.qr(threadRoot); @@ -14222,31 +14120,31 @@ ThreadWatcher.toggle(thread); break; case Conf['Expand image']: - if (!threadRoot) { + if (!(ImageExpand.enabled && threadRoot)) { return; } Keybinds.img(threadRoot); break; case Conf['Expand images']: - if (!threadRoot) { + if (!(ImageExpand.enabled && threadRoot)) { return; } Keybinds.img(threadRoot, true); break; case Conf['Open Gallery']: - if ((_ref2 = g.VIEW) !== 'index' && _ref2 !== 'thread') { + if (!Gallery.enabled) { return; } Gallery.cb.toggle(); break; case Conf['fappeTyme']: - if (!Conf['Fappe Tyme'] || ((_ref3 = g.VIEW) !== 'index' && _ref3 !== 'thread') || g.BOARD === 'f') { + if (!(Conf['Fappe Tyme'] && ((_ref2 = g.VIEW) === 'index' || _ref2 === 'thread') && g.BOARD.ID !== 'f')) { return; } FappeTyme.toggle('fappe'); break; case Conf['werkTyme']: - if (!Conf['Werk Tyme'] || ((_ref4 = g.VIEW) !== 'index' && _ref4 !== 'thread') || g.BOARD === 'f') { + if (!(Conf['Werk Tyme'] && ((_ref3 = g.VIEW) === 'index' || _ref3 === 'thread') && g.BOARD.ID !== 'f')) { return; } FappeTyme.toggle('werk'); @@ -14266,7 +14164,7 @@ return; } if (Conf['JSON Navigation']) { - if ((_ref5 = Conf['Index Mode']) !== 'paged' && _ref5 !== 'infinite') { + if ((_ref4 = Conf['Index Mode']) !== 'paged' && _ref4 !== 'infinite') { return; } $('.next button', Index.pagelist).click(); @@ -14281,7 +14179,7 @@ return; } if (Conf['JSON Navigation']) { - if ((_ref6 = Conf['Index Mode']) !== 'paged' && _ref6 !== 'infinite') { + if ((_ref5 = Conf['Index Mode']) !== 'paged' && _ref5 !== 'infinite') { return; } $('.prev button', Index.pagelist).click(); @@ -14425,17 +14323,11 @@ return key; }, qr: function(thread) { - if (!(Conf['Quick Reply'] && QR.postingIsEnabled)) { - return; - } QR.open(); if (thread != null) { QR.quote.call($('input', $('.post.highlight', thread) || thread)); } - QR.nodes.com.focus(); - if (Conf['QR Shortcut']) { - return $.rmClass($('.qr-shortcut'), 'disabled'); - } + return QR.nodes.com.focus(); }, tags: function(tag, ta) { var range, selEnd, selStart, supported, value; diff --git a/builds/4chan-X.zip b/builds/4chan-X.zip index 2c99f7a4e..d39542336 100644 Binary files a/builds/4chan-X.zip and b/builds/4chan-X.zip differ diff --git a/builds/updates-beta.xml b/builds/updates-beta.xml index 5fa6f6d4d..bcd7998ad 100644 --- a/builds/updates-beta.xml +++ b/builds/updates-beta.xml @@ -1,7 +1,7 @@ - + diff --git a/builds/updates.xml b/builds/updates.xml index 7728a0633..9805c6385 100644 --- a/builds/updates.xml +++ b/builds/updates.xml @@ -1,7 +1,7 @@ - + diff --git a/package.json b/package.json index e986019cb..853366a8d 100755 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "description": "Cross-browser userscript for maximum lurking on 4chan.", "meta": { "name": "4chan X", - "version": "1.9.20.8", + "version": "1.9.21.0", "repo": "https://github.com/ccd0/4chan-x/", "page": "https://github.com/ccd0/4chan-x", "downloads": "https://ccd0.github.io/4chan-x/builds/",