Release 4chan X v1.9.21.0.

This commit is contained in:
ccd0 2015-01-26 19:32:02 -08:00
parent a720609a1c
commit e2c7a9553e
14 changed files with 330 additions and 645 deletions

View File

@ -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). 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.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.x --> <!-- v1.9.20.x -->
### v1.9.20.8 ### 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")] *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")]

View File

@ -1,5 +1,5 @@
/* /*
* 4chan X - Version 1.9.20.8 * 4chan X - Version 1.9.21.0
* *
* Licensed under the MIT license. * Licensed under the MIT license.
* https://github.com/ccd0/4chan-x/blob/master/LICENSE * https://github.com/ccd0/4chan-x/blob/master/LICENSE

Binary file not shown.

View File

@ -1,6 +1,6 @@
// ==UserScript== // ==UserScript==
// @name 4chan X beta // @name 4chan X beta
// @version 1.9.20.8 // @version 1.9.21.0
// @minGMVer 1.14 // @minGMVer 1.14
// @minFFVer 26 // @minFFVer 26
// @namespace 4chan-X // @namespace 4chan-X

View File

@ -1,7 +1,7 @@
// Generated by CoffeeScript // Generated by CoffeeScript
// ==UserScript== // ==UserScript==
// @name 4chan X beta // @name 4chan X beta
// @version 1.9.20.8 // @version 1.9.21.0
// @minGMVer 1.14 // @minGMVer 1.14
// @minFFVer 26 // @minFFVer 26
// @namespace 4chan-X // @namespace 4chan-X
@ -25,12 +25,12 @@
// ==/UserScript== // ==/UserScript==
/* /*
* 4chan X - Version 1.9.20.8 * 4chan X - Version 1.9.21.0
* *
* Licensed under the MIT license. * Licensed under the MIT license.
* https://github.com/ccd0/4chan-x/blob/master/LICENSE * https://github.com/ccd0/4chan-x/blob/master/LICENSE
* *
* Appchan X Copyright © 2013-2014 Zixaphir <zixaphirmoxphar@gmail.com> * Appchan X Copyright © 2013-2015 Zixaphir <zixaphirmoxphar@gmail.com>
* http://zixaphir.github.io/appchan-x/ * http://zixaphir.github.io/appchan-x/
* 4chan x Copyright © 2009-2011 James Campos <james.r.campos@gmail.com> * 4chan x Copyright © 2009-2011 James Campos <james.r.campos@gmail.com>
* https://github.com/aeosynth/4chan-x * https://github.com/aeosynth/4chan-x
@ -195,7 +195,7 @@
'Werk Tyme': [false, 'Hide all post images when header menu item is checked.'], 'Werk Tyme': [false, 'Hide all post images when header menu item is checked.'],
'Autoplay': [true, 'Videos begin playing immediately when opened.'], 'Autoplay': [true, 'Videos begin playing immediately when opened.'],
'Restart when Opened': [true, 'Restart GIFs and WebMs when you hover over or expand them.'], '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.'] 'Loop in New Tab': [true, 'Loop videos opened in their own tabs.']
}, },
'Menu': { 'Menu': {
@ -396,7 +396,7 @@
doc = d.documentElement; doc = d.documentElement;
g = { g = {
VERSION: '1.9.20.8', VERSION: '1.9.21.0',
NAMESPACE: '4chan X.', NAMESPACE: '4chan X.',
NAME: '4chan X', NAME: '4chan X',
FAQ: 'https://github.com/ccd0/4chan-x/wiki/Frequently-Asked-Questions', FAQ: 'https://github.com/ccd0/4chan-x/wiki/Frequently-Asked-Questions',
@ -1511,7 +1511,6 @@
this.file.text = file.firstElementChild; this.file.text = file.firstElementChild;
this.file.thumb = $('.fileThumb > [data-md5]', file); this.file.thumb = $('.fileThumb > [data-md5]', file);
this.file.fullImage = $('.full-image', file); this.file.fullImage = $('.full-image', file);
this.file.videoControls = $('.video-controls', this.file.text);
if (contractThumb) { if (contractThumb) {
ImageExpand.contract(this); ImageExpand.contract(this);
} }
@ -3749,8 +3748,6 @@
}; };
flag = !flagCode ? { flag = !flagCode ? {
innerHTML: "" innerHTML: ""
} : false ? {
innerHTML: " <img src=\"//s.4cdn.org/image/country/troll/" + E(flagCode.toLowerCase()) + ".gif\" alt=\"" + E(flagCode) + "\" title=\"" + E(flagName) + "\" class=\"countryFlag\">"
} : { } : {
innerHTML: " <span title=\"" + E(flagName) + "\" class=\"flag flag-" + E(flagCode.toLowerCase()) + "\"></span>" innerHTML: " <span title=\"" + E(flagName) + "\" class=\"flag flag-" + E(flagCode.toLowerCase()) + "\"></span>"
}; };
@ -6614,17 +6611,20 @@
mimeTypes: ['image/jpeg', 'image/png', 'image/gif', 'application/pdf', 'application/vnd.adobe.flash.movie', 'application/x-shockwave-flash', 'video/webm'], mimeTypes: ['image/jpeg', 'image/png', 'image/gif', 'application/pdf', 'application/vnd.adobe.flash.movie', 'application/x-shockwave-flash', 'video/webm'],
init: function() { init: function() {
var noscript, sc; var noscript, sc;
if (!Conf['Quick Reply'] || g.VIEW === 'archive') { if (!Conf['Quick Reply']) {
return; return;
} }
this.db = new DataBoard('yourPosts'); this.db = new DataBoard('yourPosts');
this.posts = []; this.posts = [];
if (g.VIEW === 'archive') {
return;
}
$.globalEval('document.documentElement.dataset.jsEnabled = true;'); $.globalEval('document.documentElement.dataset.jsEnabled = true;');
noscript = Conf['Force Noscript Captcha'] || !doc.dataset.jsEnabled; noscript = Conf['Force Noscript Captcha'] || !doc.dataset.jsEnabled;
this.captcha = Captcha[noscript ? 'noscript' : 'v2']; this.captcha = Captcha[noscript ? 'noscript' : 'v2'];
if (Conf['QR Shortcut']) { if (Conf['QR Shortcut']) {
sc = $.el('a', { sc = $.el('a', {
className: "qr-shortcut fa fa-comment-o " + (!Conf['Persistent QR'] ? 'disabled' : ''), className: 'qr-shortcut fa fa-comment-o disabled',
textContent: 'QR', textContent: 'QR',
title: 'Quick Reply', title: 'Quick Reply',
href: 'javascript:;' href: 'javascript:;'
@ -6635,11 +6635,9 @@
} }
if (Conf['Persistent QR'] || !QR.nodes || QR.nodes.el.hidden) { if (Conf['Persistent QR'] || !QR.nodes || QR.nodes.el.hidden) {
QR.open(); QR.open();
QR.nodes.com.focus(); return QR.nodes.com.focus();
return $.rmClass(this, 'disabled');
} else { } else {
QR.close(); return QR.close();
return $.addClass(this, 'disabled');
} }
}); });
Header.addShortcut(sc); Header.addShortcut(sc);
@ -6674,12 +6672,8 @@
}); });
QR.link = link.firstElementChild; QR.link = link.firstElementChild;
$.on(link.firstChild, 'click', function() { $.on(link.firstChild, 'click', function() {
$.event('CloseMenu');
QR.open(); QR.open();
QR.nodes.com.focus(); return QR.nodes.com.focus();
if (Conf['QR Shortcut']) {
return $.rmClass($('.qr-shortcut'), 'disabled');
}
}); });
if (Conf['Bottom QR Link'] && g.VIEW === 'thread') { if (Conf['Bottom QR Link'] && g.VIEW === 'thread') {
linkBot = $.el('div', { linkBot = $.el('div', {
@ -6689,12 +6683,8 @@
innerHTML: "<a href=\"javascript:;\" class=\"qr-link-bottom\">Reply to Thread</a>" innerHTML: "<a href=\"javascript:;\" class=\"qr-link-bottom\">Reply to Thread</a>"
}); });
$.on(linkBot.firstElementChild, 'click', function() { $.on(linkBot.firstElementChild, 'click', function() {
$.event('CloseMenu');
QR.open(); QR.open();
QR.nodes.com.focus(); return QR.nodes.com.focus();
if (Conf['QR Shortcut']) {
return $.rmClass($('.qr-shortcut'), 'disabled');
}
}); });
$.prepend($('.navLinksBot'), linkBot); $.prepend($('.navLinksBot'), linkBot);
} }
@ -6739,17 +6729,21 @@
} }
QR.nodes.el.hidden = false; QR.nodes.el.hidden = false;
QR.unhide(); 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 { if (Conf['QR Shortcut']) {
return QR.dialog(); return $.rmClass($('.qr-shortcut'), 'disabled');
} catch (_error) {
err = _error;
delete QR.nodes;
return Main.handleErrors({
message: 'Quick Reply dialog creation crashed.',
error: err
});
} }
}, },
close: function() { close: function() {
@ -6763,7 +6757,7 @@
d.activeElement.blur(); d.activeElement.blur();
$.rmClass(QR.nodes.el, 'dump'); $.rmClass(QR.nodes.el, 'dump');
if (Conf['QR Shortcut']) { if (Conf['QR Shortcut']) {
$.toggleClass($('.qr-shortcut'), 'disabled'); $.addClass($('.qr-shortcut'), 'disabled');
} }
new QR.post(true); new QR.post(true);
_ref = QR.posts.splice(0, QR.posts.length - 1); _ref = QR.posts.splice(0, QR.posts.length - 1);
@ -6957,10 +6951,7 @@
com.setSelectionRange(range, range); com.setSelectionRange(range, range);
com.focus(); com.focus();
QR.selected.save(com); QR.selected.save(com);
QR.selected.save(thread); return QR.selected.save(thread);
if (Conf['QR Shortcut']) {
return $.rmClass($('.qr-shortcut'), 'disabled');
}
}, },
characterCount: function() { characterCount: function() {
var count, counter; var count, counter;
@ -7281,7 +7272,6 @@
nodes.flashTag.dataset["default"] = '4'; nodes.flashTag.dataset["default"] = '4';
$.add(nodes.form, nodes.flashTag); $.add(nodes.form, nodes.flashTag);
} }
QR.flagsInput();
$.on(nodes.filename.parentNode, 'click keydown', QR.openFileInput); $.on(nodes.filename.parentNode, 'click keydown', QR.openFileInput);
$.on(nodes.autohide, 'change', QR.toggleHide); $.on(nodes.autohide, 'change', QR.toggleHide);
$.on(nodes.close, 'click', QR.close); $.on(nodes.close, 'click', QR.close);
@ -7303,7 +7293,7 @@
return QR.selected.nodes.spoiler.click(); return QR.selected.nodes.spoiler.click();
}); });
$.on(nodes.fileInput, 'change', QR.handleFiles); $.on(nodes.fileInput, 'change', QR.handleFiles);
items = ['thread', 'name', 'email', 'sub', 'com', 'filename', 'flag']; items = ['thread', 'name', 'email', 'sub', 'com', 'filename'];
i = 0; i = 0;
save = function() { save = function() {
return QR.selected.save(this); return QR.selected.save(this);
@ -7336,43 +7326,6 @@
QR.captcha.setup(); QR.captcha.setup();
return $.event('QRDialogCreation', null, dialog); 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) { submit: function(e) {
var captcha, cb, err, extra, filetag, formData, options, post, textOnly, thread, threadID; var captcha, cb, err, extra, filetag, formData, options, post, textOnly, thread, threadID;
if (e != null) { if (e != null) {
@ -7438,7 +7391,6 @@
upfile: post.file, upfile: post.file,
filetag: filetag, filetag: filetag,
spoiler: post.spoiler, spoiler: post.spoiler,
flag: post.flag,
textonly: textOnly, textonly: textOnly,
mode: 'regist', mode: 'regist',
pwd: QR.persona.pwd pwd: QR.persona.pwd
@ -8460,8 +8412,7 @@
persona = _arg['QR.persona']; persona = _arg['QR.persona'];
persona = { persona = {
name: post.name, name: post.name,
email: /^sage$/.test(post.email) ? persona.email : post.email, email: /^sage$/.test(post.email) ? persona.email : post.email
flag: post.flag
}; };
return $.set('QR.persona', persona); 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.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.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 : ''; _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) { if (QR.selected === _this) {
return _this.load(); return _this.load();
} }
@ -8567,7 +8515,7 @@
if (this !== QR.selected) { if (this !== QR.selected) {
return; 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++) { for (_i = 0, _len = _ref.length; _i < _len; _i++) {
name = _ref[_i]; name = _ref[_i];
if (node = QR.nodes[name]) { if (node = QR.nodes[name]) {
@ -8601,7 +8549,7 @@
_Class.prototype.load = function() { _Class.prototype.load = function() {
var name, node, _i, _len, _ref; 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++) { for (_i = 0, _len = _ref.length; _i < _len; _i++) {
name = _ref[_i]; name = _ref[_i];
if (!(node = QR.nodes[name])) { if (!(node = QR.nodes[name])) {
@ -8651,7 +8599,7 @@
if (this !== QR.selected) { if (this !== QR.selected) {
return; 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++) { for (_i = 0, _len = _ref.length; _i < _len; _i++) {
name = _ref[_i]; name = _ref[_i];
if (!(node = QR.nodes[name])) { if (!(node = QR.nodes[name])) {
@ -8826,7 +8774,7 @@
FappeTyme = { FappeTyme = {
init: function() { init: function() {
var el, lc, type, _i, _len, _ref, _ref1; 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; return;
} }
this.nodes = {}; this.nodes = {};
@ -8898,7 +8846,7 @@
Gallery = { Gallery = {
init: function() { init: function() {
var el, _ref; 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; return;
} }
this.delay = Conf['Slide Delay']; this.delay = Conf['Slide Delay'];
@ -8970,6 +8918,7 @@
cb = Gallery.cb; cb = Gallery.cb;
$.on(nodes.frame, 'click', cb.blank); $.on(nodes.frame, 'click', cb.blank);
$.on(nodes.next, 'click', cb.click); $.on(nodes.next, 'click', cb.click);
$.on(nodes.name, 'click', ImageCommon.download);
$.on($('.gal-prev', dialog), 'click', cb.prev); $.on($('.gal-prev', dialog), 'click', cb.prev);
$.on($('.gal-next', dialog), 'click', cb.next); $.on($('.gal-next', dialog), 'click', cb.next);
$.on($('.gal-start', dialog), 'click', cb.start); $.on($('.gal-start', dialog), 'click', cb.start);
@ -9168,7 +9117,7 @@
case 'Right': case 'Right':
return Gallery.cb.next; return Gallery.cb.next;
case 'Enter': case 'Enter':
return Gallery.cb.enterKey; return Gallery.cb.advance;
case 'Left': case 'Left':
case '': case '':
return Gallery.cb.prev; return Gallery.cb.prev;
@ -9204,16 +9153,20 @@
next: function() { next: function() {
return Gallery.cb.open.call(Gallery.images[+Gallery.nodes.current.dataset.id + 1] || Gallery.images[0]); 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) { if (Gallery.nodes.current.paused) {
return Gallery.nodes.current.play(); return Gallery.nodes.current.play();
} else { } else {
return Gallery.cb.next(); return Gallery.cb.next();
} }
}, },
click: function() {
return Gallery.cb[Gallery.nodes.current.controls ? 'stop' : 'enterKey']();
},
toggle: function() { toggle: function() {
return (Gallery.nodes ? Gallery.cb.close : Gallery.build)(); return (Gallery.nodes ? Gallery.cb.close : Gallery.build)();
}, },
@ -9285,8 +9238,8 @@
}, },
menu: { menu: {
init: function() { init: function() {
var el, _ref; var el;
if (((_ref = g.VIEW) !== 'index' && _ref !== 'thread') || !Conf['Gallery']) { if (!Gallery.enabled) {
return; return;
} }
el = $.el('span', { el = $.el('span', {
@ -9440,13 +9393,32 @@
}); });
}; };
return $.on(video, 'mouseover', handler); 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 = { ImageExpand = {
init: function() { init: function() {
var _ref; 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; return;
} }
this.EAI = $.el('a', { this.EAI = $.el('a', {
@ -9458,12 +9430,6 @@
$.on(this.EAI, 'click', this.cb.toggleAll); $.on(this.EAI, 'click', this.cb.toggleAll);
Header.addShortcut(this.EAI, 3); Header.addShortcut(this.EAI, 3);
$.on(d, 'scroll visibilitychange', this.cb.playVideos); $.on(d, 'scroll visibilitychange', this.cb.playVideos);
this.videoControls = $.el('span', {
className: 'video-controls'
});
$.extend(this.videoControls, {
innerHTML: " <a href=\"javascript:;\" title=\"You can also contract the video by dragging it to the left.\">contract</a>"
});
return Post.callbacks.push({ return Post.callbacks.push({
name: 'Image Expansion', name: 'Image Expansion',
cb: this.node cb: this.node
@ -9480,7 +9446,6 @@
ImageExpand.contract(this); ImageExpand.contract(this);
return ImageExpand.expand(this); return ImageExpand.expand(this);
} else if (this.file.isExpanded && this.file.isVideo) { } 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); 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)) { } 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: { cb: {
toggle: function(e) { toggle: function(e) {
var file, post; var file, post, _ref;
if (e.shiftKey || e.altKey || e.ctrlKey || e.metaKey || e.button !== 0) { if (e.shiftKey || e.altKey || e.ctrlKey || e.metaKey || e.button !== 0) {
return; return;
} }
post = Get.postFromNode(this); post = Get.postFromNode(this);
file = post.file; file = post.file;
if (file.isExpanded && file.isVideo && file.fullImage.controls) { if (file.isExpanded && ImageCommon.onControls(e)) {
return; return;
} }
e.preventDefault(); 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() { toggleAll: function() {
var func, toggle; var func, toggle;
@ -9581,7 +9550,7 @@
} }
}, },
contract: function(post) { 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; file = post.file;
if (el = file.fullImage) { if (el = file.fullImage) {
top = Header.getTopOf(el); top = Header.getTopOf(el);
@ -9591,12 +9560,9 @@
} }
$.rmClass(post.nodes.root, 'expanded-image'); $.rmClass(post.nodes.root, 'expanded-image');
$.rmClass(file.thumb, 'expanding'); $.rmClass(file.thumb, 'expanding');
if (file.videoControls) {
$.rm(file.videoControls);
}
file.thumb.parentNode.href = file.URL; file.thumb.parentNode.href = file.URL;
file.thumb.parentNode.target = '_blank'; 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++) { for (_i = 0, _len = _ref.length; _i < _len; _i++) {
x = _ref[_i]; x = _ref[_i];
delete file[x]; delete file[x];
@ -9618,11 +9584,6 @@
ImageCommon.pushCache(el); ImageCommon.pushCache(el);
if (file.isVideo) { if (file.isVideo) {
el.pause(); el.pause();
_ref1 = ImageExpand.videoCB;
for (eventName in _ref1) {
cb = _ref1[eventName];
$.off(el, eventName, cb);
}
} }
if (Conf['Restart when Opened']) { if (Conf['Restart when Opened']) {
ImageCommon.rewind(file.thumb); ImageCommon.rewind(file.thumb);
@ -9666,14 +9627,9 @@
el.className = 'full-image'; el.className = 'full-image';
$.after(thumb, el); $.after(thumb, el);
if (isVideo) { 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('href');
thumb.parentNode.removeAttribute('target'); thumb.parentNode.removeAttribute('target');
el.loop = true; el.loop = true;
ImageExpand.setupVideoCB(post);
} }
if (!isVideo) { if (!isVideo) {
return $.asap((function() { return $.asap((function() {
@ -9741,49 +9697,6 @@
return ImageCommon.addControls(fullImage); 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() { error: function() {
var post; var post;
post = Get.postFromNode(this); post = Get.postFromNode(this);
@ -9809,8 +9722,8 @@
}, },
menu: { menu: {
init: function() { init: function() {
var conf, createSubEntry, el, name, subEntries, _ref, _ref1; var conf, createSubEntry, el, name, subEntries, _ref;
if (((_ref = g.VIEW) !== 'index' && _ref !== 'thread') || !Conf['Image Expansion']) { if (!ImageExpand.enabled) {
return; return;
} }
el = $.el('span', { el = $.el('span', {
@ -9819,9 +9732,9 @@
}); });
createSubEntry = ImageExpand.menu.createSubEntry; createSubEntry = ImageExpand.menu.createSubEntry;
subEntries = []; subEntries = [];
_ref1 = Config.imageExpansion; _ref = Config.imageExpansion;
for (name in _ref1) { for (name in _ref) {
conf = _ref1[name]; conf = _ref[name];
subEntries.push(createSubEntry(name, conf[1])); subEntries.push(createSubEntry(name, conf[1]));
} }
return Header.menu.addEntry({ return Header.menu.addEntry({
@ -9967,7 +9880,7 @@
ImageLoader = { ImageLoader = {
init: function() { init: function() {
var prefetch, _ref; var prefetch, _ref;
if ((_ref = g.VIEW) !== 'index' && _ref !== 'thread') { if (!(((_ref = g.VIEW) === 'index' || _ref === 'thread') && g.BOARD.ID !== 'f')) {
return; return;
} }
if (!(Conf['Image Prefetching'] || Conf['Replace JPG'] || Conf['Replace PNG'] || Conf['Replace GIF'] || Conf['Replace WEBM'])) { if (!(Conf['Image Prefetching'] || Conf['Replace JPG'] || Conf['Replace PNG'] || Conf['Replace GIF'] || Conf['Replace WEBM'])) {
@ -10434,23 +10347,20 @@
return; return;
} }
if ($.hasClass(this, "embedded")) { if ($.hasClass(this, "embedded")) {
if (!$.hasClass(this.previousElementSibling, 'linkify')) { $.rm(this.nextElementSibling);
$.rm(this.previousElementSibling);
}
this.previousElementSibling.hidden = false;
this.textContent = '(embed)'; this.textContent = '(embed)';
} else { } else {
this.previousElementSibling.hidden = true; $.after(this, Embedding.cb.embed(this));
$.before(this, Embedding.cb.embed(this));
this.textContent = '(unembed)'; this.textContent = '(unembed)';
} }
return $.toggleClass(this, 'embedded'); return $.toggleClass(this, 'embedded');
}, },
embed: function(a) { embed: function(a) {
var el, type; var container, el, type;
el = (type = Embedding.types[a.dataset.key]).el(a); container = $.el('div');
el.style.cssText = type.style != null ? type.style : "border: 0; width: 640px; height: 390px"; $.add(container, el = (type = Embedding.types[a.dataset.key]).el(a));
return el; el.style.cssText = type.style != null ? type.style : "border:0;width:640px;height:390px";
return container;
}, },
title: function(req, data) { title: function(req, data) {
var key, link, link2, options, post, post2, service, status, text, uid, _i, _j, _len, _len1, _ref, _ref1; var key, link, link2, options, post, post2, service, status, text, uid, _i, _j, _len, _len1, _ref, _ref1;
@ -11226,22 +11136,7 @@
className: 'download-link', className: 'download-link',
textContent: 'Download file' textContent: 'Download file'
}); });
$.on(a, 'click', function(e) { $.on(a, 'click', ImageCommon.download);
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));
});
return Menu.menu.addEntry({ return Menu.menu.addEntry({
el: a, el: a,
order: 100, order: 100,
@ -14101,7 +13996,7 @@
return Conf[hotkey] = key; return Conf[hotkey] = key;
}, },
keydown: function(e) { 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))) { if (!(key = Keybinds.keyCode(e))) {
return; return;
} }
@ -14128,10 +14023,13 @@
Header.toggleBarVisibility(); Header.toggleBarVisibility();
break; break;
case Conf['Open empty QR']: case Conf['Open empty QR']:
if (!QR.postingIsEnabled) {
return;
}
Keybinds.qr(); Keybinds.qr();
break; break;
case Conf['Open QR']: case Conf['Open QR']:
if (!threadRoot) { if (!(QR.postingIsEnabled && threadRoot)) {
return; return;
} }
Keybinds.qr(threadRoot); Keybinds.qr(threadRoot);
@ -14222,31 +14120,31 @@
ThreadWatcher.toggle(thread); ThreadWatcher.toggle(thread);
break; break;
case Conf['Expand image']: case Conf['Expand image']:
if (!threadRoot) { if (!(ImageExpand.enabled && threadRoot)) {
return; return;
} }
Keybinds.img(threadRoot); Keybinds.img(threadRoot);
break; break;
case Conf['Expand images']: case Conf['Expand images']:
if (!threadRoot) { if (!(ImageExpand.enabled && threadRoot)) {
return; return;
} }
Keybinds.img(threadRoot, true); Keybinds.img(threadRoot, true);
break; break;
case Conf['Open Gallery']: case Conf['Open Gallery']:
if ((_ref2 = g.VIEW) !== 'index' && _ref2 !== 'thread') { if (!Gallery.enabled) {
return; return;
} }
Gallery.cb.toggle(); Gallery.cb.toggle();
break; break;
case Conf['fappeTyme']: 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; return;
} }
FappeTyme.toggle('fappe'); FappeTyme.toggle('fappe');
break; break;
case Conf['werkTyme']: 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; return;
} }
FappeTyme.toggle('werk'); FappeTyme.toggle('werk');
@ -14266,7 +14164,7 @@
return; return;
} }
if (Conf['JSON Navigation']) { if (Conf['JSON Navigation']) {
if ((_ref5 = Conf['Index Mode']) !== 'paged' && _ref5 !== 'infinite') { if ((_ref4 = Conf['Index Mode']) !== 'paged' && _ref4 !== 'infinite') {
return; return;
} }
$('.next button', Index.pagelist).click(); $('.next button', Index.pagelist).click();
@ -14281,7 +14179,7 @@
return; return;
} }
if (Conf['JSON Navigation']) { if (Conf['JSON Navigation']) {
if ((_ref6 = Conf['Index Mode']) !== 'paged' && _ref6 !== 'infinite') { if ((_ref5 = Conf['Index Mode']) !== 'paged' && _ref5 !== 'infinite') {
return; return;
} }
$('.prev button', Index.pagelist).click(); $('.prev button', Index.pagelist).click();
@ -14425,17 +14323,11 @@
return key; return key;
}, },
qr: function(thread) { qr: function(thread) {
if (!(Conf['Quick Reply'] && QR.postingIsEnabled)) {
return;
}
QR.open(); QR.open();
if (thread != null) { if (thread != null) {
QR.quote.call($('input', $('.post.highlight', thread) || thread)); QR.quote.call($('input', $('.post.highlight', thread) || thread));
} }
QR.nodes.com.focus(); return QR.nodes.com.focus();
if (Conf['QR Shortcut']) {
return $.rmClass($('.qr-shortcut'), 'disabled');
}
}, },
tags: function(tag, ta) { tags: function(tag, ta) {
var range, selEnd, selStart, supported, value; var range, selEnd, selStart, supported, value;

Binary file not shown.

View File

@ -1,7 +1,7 @@
// Generated by CoffeeScript // Generated by CoffeeScript
// ==UserScript== // ==UserScript==
// @name 4chan X // @name 4chan X
// @version 1.9.20.8 // @version 1.9.21.0
// @minGMVer 1.14 // @minGMVer 1.14
// @minFFVer 26 // @minFFVer 26
// @namespace 4chan-X // @namespace 4chan-X
@ -24,12 +24,12 @@
// ==/UserScript== // ==/UserScript==
/* /*
* 4chan X - Version 1.9.20.8 * 4chan X - Version 1.9.21.0
* *
* Licensed under the MIT license. * Licensed under the MIT license.
* https://github.com/ccd0/4chan-x/blob/master/LICENSE * https://github.com/ccd0/4chan-x/blob/master/LICENSE
* *
* Appchan X Copyright © 2013-2014 Zixaphir <zixaphirmoxphar@gmail.com> * Appchan X Copyright © 2013-2015 Zixaphir <zixaphirmoxphar@gmail.com>
* http://zixaphir.github.io/appchan-x/ * http://zixaphir.github.io/appchan-x/
* 4chan x Copyright © 2009-2011 James Campos <james.r.campos@gmail.com> * 4chan x Copyright © 2009-2011 James Campos <james.r.campos@gmail.com>
* https://github.com/aeosynth/4chan-x * https://github.com/aeosynth/4chan-x
@ -194,7 +194,7 @@
'Werk Tyme': [false, 'Hide all post images when header menu item is checked.'], 'Werk Tyme': [false, 'Hide all post images when header menu item is checked.'],
'Autoplay': [true, 'Videos begin playing immediately when opened.'], 'Autoplay': [true, 'Videos begin playing immediately when opened.'],
'Restart when Opened': [true, 'Restart GIFs and WebMs when you hover over or expand them.'], '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.'] 'Loop in New Tab': [true, 'Loop videos opened in their own tabs.']
}, },
'Menu': { 'Menu': {
@ -395,7 +395,7 @@
doc = d.documentElement; doc = d.documentElement;
g = { g = {
VERSION: '1.9.20.8', VERSION: '1.9.21.0',
NAMESPACE: '4chan X.', NAMESPACE: '4chan X.',
NAME: '4chan X', NAME: '4chan X',
FAQ: 'https://github.com/ccd0/4chan-x/wiki/Frequently-Asked-Questions', FAQ: 'https://github.com/ccd0/4chan-x/wiki/Frequently-Asked-Questions',
@ -1510,7 +1510,6 @@
this.file.text = file.firstElementChild; this.file.text = file.firstElementChild;
this.file.thumb = $('.fileThumb > [data-md5]', file); this.file.thumb = $('.fileThumb > [data-md5]', file);
this.file.fullImage = $('.full-image', file); this.file.fullImage = $('.full-image', file);
this.file.videoControls = $('.video-controls', this.file.text);
if (contractThumb) { if (contractThumb) {
ImageExpand.contract(this); ImageExpand.contract(this);
} }
@ -3748,8 +3747,6 @@
}; };
flag = !flagCode ? { flag = !flagCode ? {
innerHTML: "" innerHTML: ""
} : false ? {
innerHTML: " <img src=\"//s.4cdn.org/image/country/troll/" + E(flagCode.toLowerCase()) + ".gif\" alt=\"" + E(flagCode) + "\" title=\"" + E(flagName) + "\" class=\"countryFlag\">"
} : { } : {
innerHTML: " <span title=\"" + E(flagName) + "\" class=\"flag flag-" + E(flagCode.toLowerCase()) + "\"></span>" innerHTML: " <span title=\"" + E(flagName) + "\" class=\"flag flag-" + E(flagCode.toLowerCase()) + "\"></span>"
}; };
@ -6613,17 +6610,20 @@
mimeTypes: ['image/jpeg', 'image/png', 'image/gif', 'application/pdf', 'application/vnd.adobe.flash.movie', 'application/x-shockwave-flash', 'video/webm'], mimeTypes: ['image/jpeg', 'image/png', 'image/gif', 'application/pdf', 'application/vnd.adobe.flash.movie', 'application/x-shockwave-flash', 'video/webm'],
init: function() { init: function() {
var noscript, sc; var noscript, sc;
if (!Conf['Quick Reply'] || g.VIEW === 'archive') { if (!Conf['Quick Reply']) {
return; return;
} }
this.db = new DataBoard('yourPosts'); this.db = new DataBoard('yourPosts');
this.posts = []; this.posts = [];
if (g.VIEW === 'archive') {
return;
}
$.globalEval('document.documentElement.dataset.jsEnabled = true;'); $.globalEval('document.documentElement.dataset.jsEnabled = true;');
noscript = Conf['Force Noscript Captcha'] || !doc.dataset.jsEnabled; noscript = Conf['Force Noscript Captcha'] || !doc.dataset.jsEnabled;
this.captcha = Captcha[noscript ? 'noscript' : 'v2']; this.captcha = Captcha[noscript ? 'noscript' : 'v2'];
if (Conf['QR Shortcut']) { if (Conf['QR Shortcut']) {
sc = $.el('a', { sc = $.el('a', {
className: "qr-shortcut fa fa-comment-o " + (!Conf['Persistent QR'] ? 'disabled' : ''), className: 'qr-shortcut fa fa-comment-o disabled',
textContent: 'QR', textContent: 'QR',
title: 'Quick Reply', title: 'Quick Reply',
href: 'javascript:;' href: 'javascript:;'
@ -6634,11 +6634,9 @@
} }
if (Conf['Persistent QR'] || !QR.nodes || QR.nodes.el.hidden) { if (Conf['Persistent QR'] || !QR.nodes || QR.nodes.el.hidden) {
QR.open(); QR.open();
QR.nodes.com.focus(); return QR.nodes.com.focus();
return $.rmClass(this, 'disabled');
} else { } else {
QR.close(); return QR.close();
return $.addClass(this, 'disabled');
} }
}); });
Header.addShortcut(sc); Header.addShortcut(sc);
@ -6673,12 +6671,8 @@
}); });
QR.link = link.firstElementChild; QR.link = link.firstElementChild;
$.on(link.firstChild, 'click', function() { $.on(link.firstChild, 'click', function() {
$.event('CloseMenu');
QR.open(); QR.open();
QR.nodes.com.focus(); return QR.nodes.com.focus();
if (Conf['QR Shortcut']) {
return $.rmClass($('.qr-shortcut'), 'disabled');
}
}); });
if (Conf['Bottom QR Link'] && g.VIEW === 'thread') { if (Conf['Bottom QR Link'] && g.VIEW === 'thread') {
linkBot = $.el('div', { linkBot = $.el('div', {
@ -6688,12 +6682,8 @@
innerHTML: "<a href=\"javascript:;\" class=\"qr-link-bottom\">Reply to Thread</a>" innerHTML: "<a href=\"javascript:;\" class=\"qr-link-bottom\">Reply to Thread</a>"
}); });
$.on(linkBot.firstElementChild, 'click', function() { $.on(linkBot.firstElementChild, 'click', function() {
$.event('CloseMenu');
QR.open(); QR.open();
QR.nodes.com.focus(); return QR.nodes.com.focus();
if (Conf['QR Shortcut']) {
return $.rmClass($('.qr-shortcut'), 'disabled');
}
}); });
$.prepend($('.navLinksBot'), linkBot); $.prepend($('.navLinksBot'), linkBot);
} }
@ -6738,17 +6728,21 @@
} }
QR.nodes.el.hidden = false; QR.nodes.el.hidden = false;
QR.unhide(); 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 { if (Conf['QR Shortcut']) {
return QR.dialog(); return $.rmClass($('.qr-shortcut'), 'disabled');
} catch (_error) {
err = _error;
delete QR.nodes;
return Main.handleErrors({
message: 'Quick Reply dialog creation crashed.',
error: err
});
} }
}, },
close: function() { close: function() {
@ -6762,7 +6756,7 @@
d.activeElement.blur(); d.activeElement.blur();
$.rmClass(QR.nodes.el, 'dump'); $.rmClass(QR.nodes.el, 'dump');
if (Conf['QR Shortcut']) { if (Conf['QR Shortcut']) {
$.toggleClass($('.qr-shortcut'), 'disabled'); $.addClass($('.qr-shortcut'), 'disabled');
} }
new QR.post(true); new QR.post(true);
_ref = QR.posts.splice(0, QR.posts.length - 1); _ref = QR.posts.splice(0, QR.posts.length - 1);
@ -6956,10 +6950,7 @@
com.setSelectionRange(range, range); com.setSelectionRange(range, range);
com.focus(); com.focus();
QR.selected.save(com); QR.selected.save(com);
QR.selected.save(thread); return QR.selected.save(thread);
if (Conf['QR Shortcut']) {
return $.rmClass($('.qr-shortcut'), 'disabled');
}
}, },
characterCount: function() { characterCount: function() {
var count, counter; var count, counter;
@ -7280,7 +7271,6 @@
nodes.flashTag.dataset["default"] = '4'; nodes.flashTag.dataset["default"] = '4';
$.add(nodes.form, nodes.flashTag); $.add(nodes.form, nodes.flashTag);
} }
QR.flagsInput();
$.on(nodes.filename.parentNode, 'click keydown', QR.openFileInput); $.on(nodes.filename.parentNode, 'click keydown', QR.openFileInput);
$.on(nodes.autohide, 'change', QR.toggleHide); $.on(nodes.autohide, 'change', QR.toggleHide);
$.on(nodes.close, 'click', QR.close); $.on(nodes.close, 'click', QR.close);
@ -7302,7 +7292,7 @@
return QR.selected.nodes.spoiler.click(); return QR.selected.nodes.spoiler.click();
}); });
$.on(nodes.fileInput, 'change', QR.handleFiles); $.on(nodes.fileInput, 'change', QR.handleFiles);
items = ['thread', 'name', 'email', 'sub', 'com', 'filename', 'flag']; items = ['thread', 'name', 'email', 'sub', 'com', 'filename'];
i = 0; i = 0;
save = function() { save = function() {
return QR.selected.save(this); return QR.selected.save(this);
@ -7335,43 +7325,6 @@
QR.captcha.setup(); QR.captcha.setup();
return $.event('QRDialogCreation', null, dialog); 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) { submit: function(e) {
var captcha, cb, err, extra, filetag, formData, options, post, textOnly, thread, threadID; var captcha, cb, err, extra, filetag, formData, options, post, textOnly, thread, threadID;
if (e != null) { if (e != null) {
@ -7437,7 +7390,6 @@
upfile: post.file, upfile: post.file,
filetag: filetag, filetag: filetag,
spoiler: post.spoiler, spoiler: post.spoiler,
flag: post.flag,
textonly: textOnly, textonly: textOnly,
mode: 'regist', mode: 'regist',
pwd: QR.persona.pwd pwd: QR.persona.pwd
@ -8459,8 +8411,7 @@
persona = _arg['QR.persona']; persona = _arg['QR.persona'];
persona = { persona = {
name: post.name, name: post.name,
email: /^sage$/.test(post.email) ? persona.email : post.email, email: /^sage$/.test(post.email) ? persona.email : post.email
flag: post.flag
}; };
return $.set('QR.persona', persona); 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.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.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 : ''; _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) { if (QR.selected === _this) {
return _this.load(); return _this.load();
} }
@ -8566,7 +8514,7 @@
if (this !== QR.selected) { if (this !== QR.selected) {
return; 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++) { for (_i = 0, _len = _ref.length; _i < _len; _i++) {
name = _ref[_i]; name = _ref[_i];
if (node = QR.nodes[name]) { if (node = QR.nodes[name]) {
@ -8600,7 +8548,7 @@
_Class.prototype.load = function() { _Class.prototype.load = function() {
var name, node, _i, _len, _ref; 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++) { for (_i = 0, _len = _ref.length; _i < _len; _i++) {
name = _ref[_i]; name = _ref[_i];
if (!(node = QR.nodes[name])) { if (!(node = QR.nodes[name])) {
@ -8650,7 +8598,7 @@
if (this !== QR.selected) { if (this !== QR.selected) {
return; 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++) { for (_i = 0, _len = _ref.length; _i < _len; _i++) {
name = _ref[_i]; name = _ref[_i];
if (!(node = QR.nodes[name])) { if (!(node = QR.nodes[name])) {
@ -8825,7 +8773,7 @@
FappeTyme = { FappeTyme = {
init: function() { init: function() {
var el, lc, type, _i, _len, _ref, _ref1; 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; return;
} }
this.nodes = {}; this.nodes = {};
@ -8897,7 +8845,7 @@
Gallery = { Gallery = {
init: function() { init: function() {
var el, _ref; 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; return;
} }
this.delay = Conf['Slide Delay']; this.delay = Conf['Slide Delay'];
@ -8969,6 +8917,7 @@
cb = Gallery.cb; cb = Gallery.cb;
$.on(nodes.frame, 'click', cb.blank); $.on(nodes.frame, 'click', cb.blank);
$.on(nodes.next, 'click', cb.click); $.on(nodes.next, 'click', cb.click);
$.on(nodes.name, 'click', ImageCommon.download);
$.on($('.gal-prev', dialog), 'click', cb.prev); $.on($('.gal-prev', dialog), 'click', cb.prev);
$.on($('.gal-next', dialog), 'click', cb.next); $.on($('.gal-next', dialog), 'click', cb.next);
$.on($('.gal-start', dialog), 'click', cb.start); $.on($('.gal-start', dialog), 'click', cb.start);
@ -9167,7 +9116,7 @@
case 'Right': case 'Right':
return Gallery.cb.next; return Gallery.cb.next;
case 'Enter': case 'Enter':
return Gallery.cb.enterKey; return Gallery.cb.advance;
case 'Left': case 'Left':
case '': case '':
return Gallery.cb.prev; return Gallery.cb.prev;
@ -9203,16 +9152,20 @@
next: function() { next: function() {
return Gallery.cb.open.call(Gallery.images[+Gallery.nodes.current.dataset.id + 1] || Gallery.images[0]); 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) { if (Gallery.nodes.current.paused) {
return Gallery.nodes.current.play(); return Gallery.nodes.current.play();
} else { } else {
return Gallery.cb.next(); return Gallery.cb.next();
} }
}, },
click: function() {
return Gallery.cb[Gallery.nodes.current.controls ? 'stop' : 'enterKey']();
},
toggle: function() { toggle: function() {
return (Gallery.nodes ? Gallery.cb.close : Gallery.build)(); return (Gallery.nodes ? Gallery.cb.close : Gallery.build)();
}, },
@ -9284,8 +9237,8 @@
}, },
menu: { menu: {
init: function() { init: function() {
var el, _ref; var el;
if (((_ref = g.VIEW) !== 'index' && _ref !== 'thread') || !Conf['Gallery']) { if (!Gallery.enabled) {
return; return;
} }
el = $.el('span', { el = $.el('span', {
@ -9439,13 +9392,32 @@
}); });
}; };
return $.on(video, 'mouseover', handler); 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 = { ImageExpand = {
init: function() { init: function() {
var _ref; 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; return;
} }
this.EAI = $.el('a', { this.EAI = $.el('a', {
@ -9457,12 +9429,6 @@
$.on(this.EAI, 'click', this.cb.toggleAll); $.on(this.EAI, 'click', this.cb.toggleAll);
Header.addShortcut(this.EAI, 3); Header.addShortcut(this.EAI, 3);
$.on(d, 'scroll visibilitychange', this.cb.playVideos); $.on(d, 'scroll visibilitychange', this.cb.playVideos);
this.videoControls = $.el('span', {
className: 'video-controls'
});
$.extend(this.videoControls, {
innerHTML: " <a href=\"javascript:;\" title=\"You can also contract the video by dragging it to the left.\">contract</a>"
});
return Post.callbacks.push({ return Post.callbacks.push({
name: 'Image Expansion', name: 'Image Expansion',
cb: this.node cb: this.node
@ -9479,7 +9445,6 @@
ImageExpand.contract(this); ImageExpand.contract(this);
return ImageExpand.expand(this); return ImageExpand.expand(this);
} else if (this.file.isExpanded && this.file.isVideo) { } 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); 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)) { } 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: { cb: {
toggle: function(e) { toggle: function(e) {
var file, post; var file, post, _ref;
if (e.shiftKey || e.altKey || e.ctrlKey || e.metaKey || e.button !== 0) { if (e.shiftKey || e.altKey || e.ctrlKey || e.metaKey || e.button !== 0) {
return; return;
} }
post = Get.postFromNode(this); post = Get.postFromNode(this);
file = post.file; file = post.file;
if (file.isExpanded && file.isVideo && file.fullImage.controls) { if (file.isExpanded && ImageCommon.onControls(e)) {
return; return;
} }
e.preventDefault(); 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() { toggleAll: function() {
var func, toggle; var func, toggle;
@ -9580,7 +9549,7 @@
} }
}, },
contract: function(post) { 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; file = post.file;
if (el = file.fullImage) { if (el = file.fullImage) {
top = Header.getTopOf(el); top = Header.getTopOf(el);
@ -9590,12 +9559,9 @@
} }
$.rmClass(post.nodes.root, 'expanded-image'); $.rmClass(post.nodes.root, 'expanded-image');
$.rmClass(file.thumb, 'expanding'); $.rmClass(file.thumb, 'expanding');
if (file.videoControls) {
$.rm(file.videoControls);
}
file.thumb.parentNode.href = file.URL; file.thumb.parentNode.href = file.URL;
file.thumb.parentNode.target = '_blank'; 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++) { for (_i = 0, _len = _ref.length; _i < _len; _i++) {
x = _ref[_i]; x = _ref[_i];
delete file[x]; delete file[x];
@ -9617,11 +9583,6 @@
ImageCommon.pushCache(el); ImageCommon.pushCache(el);
if (file.isVideo) { if (file.isVideo) {
el.pause(); el.pause();
_ref1 = ImageExpand.videoCB;
for (eventName in _ref1) {
cb = _ref1[eventName];
$.off(el, eventName, cb);
}
} }
if (Conf['Restart when Opened']) { if (Conf['Restart when Opened']) {
ImageCommon.rewind(file.thumb); ImageCommon.rewind(file.thumb);
@ -9665,14 +9626,9 @@
el.className = 'full-image'; el.className = 'full-image';
$.after(thumb, el); $.after(thumb, el);
if (isVideo) { 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('href');
thumb.parentNode.removeAttribute('target'); thumb.parentNode.removeAttribute('target');
el.loop = true; el.loop = true;
ImageExpand.setupVideoCB(post);
} }
if (!isVideo) { if (!isVideo) {
return $.asap((function() { return $.asap((function() {
@ -9740,49 +9696,6 @@
return ImageCommon.addControls(fullImage); 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() { error: function() {
var post; var post;
post = Get.postFromNode(this); post = Get.postFromNode(this);
@ -9808,8 +9721,8 @@
}, },
menu: { menu: {
init: function() { init: function() {
var conf, createSubEntry, el, name, subEntries, _ref, _ref1; var conf, createSubEntry, el, name, subEntries, _ref;
if (((_ref = g.VIEW) !== 'index' && _ref !== 'thread') || !Conf['Image Expansion']) { if (!ImageExpand.enabled) {
return; return;
} }
el = $.el('span', { el = $.el('span', {
@ -9818,9 +9731,9 @@
}); });
createSubEntry = ImageExpand.menu.createSubEntry; createSubEntry = ImageExpand.menu.createSubEntry;
subEntries = []; subEntries = [];
_ref1 = Config.imageExpansion; _ref = Config.imageExpansion;
for (name in _ref1) { for (name in _ref) {
conf = _ref1[name]; conf = _ref[name];
subEntries.push(createSubEntry(name, conf[1])); subEntries.push(createSubEntry(name, conf[1]));
} }
return Header.menu.addEntry({ return Header.menu.addEntry({
@ -9966,7 +9879,7 @@
ImageLoader = { ImageLoader = {
init: function() { init: function() {
var prefetch, _ref; var prefetch, _ref;
if ((_ref = g.VIEW) !== 'index' && _ref !== 'thread') { if (!(((_ref = g.VIEW) === 'index' || _ref === 'thread') && g.BOARD.ID !== 'f')) {
return; return;
} }
if (!(Conf['Image Prefetching'] || Conf['Replace JPG'] || Conf['Replace PNG'] || Conf['Replace GIF'] || Conf['Replace WEBM'])) { if (!(Conf['Image Prefetching'] || Conf['Replace JPG'] || Conf['Replace PNG'] || Conf['Replace GIF'] || Conf['Replace WEBM'])) {
@ -10433,23 +10346,20 @@
return; return;
} }
if ($.hasClass(this, "embedded")) { if ($.hasClass(this, "embedded")) {
if (!$.hasClass(this.previousElementSibling, 'linkify')) { $.rm(this.nextElementSibling);
$.rm(this.previousElementSibling);
}
this.previousElementSibling.hidden = false;
this.textContent = '(embed)'; this.textContent = '(embed)';
} else { } else {
this.previousElementSibling.hidden = true; $.after(this, Embedding.cb.embed(this));
$.before(this, Embedding.cb.embed(this));
this.textContent = '(unembed)'; this.textContent = '(unembed)';
} }
return $.toggleClass(this, 'embedded'); return $.toggleClass(this, 'embedded');
}, },
embed: function(a) { embed: function(a) {
var el, type; var container, el, type;
el = (type = Embedding.types[a.dataset.key]).el(a); container = $.el('div');
el.style.cssText = type.style != null ? type.style : "border: 0; width: 640px; height: 390px"; $.add(container, el = (type = Embedding.types[a.dataset.key]).el(a));
return el; el.style.cssText = type.style != null ? type.style : "border:0;width:640px;height:390px";
return container;
}, },
title: function(req, data) { title: function(req, data) {
var key, link, link2, options, post, post2, service, status, text, uid, _i, _j, _len, _len1, _ref, _ref1; var key, link, link2, options, post, post2, service, status, text, uid, _i, _j, _len, _len1, _ref, _ref1;
@ -11225,22 +11135,7 @@
className: 'download-link', className: 'download-link',
textContent: 'Download file' textContent: 'Download file'
}); });
$.on(a, 'click', function(e) { $.on(a, 'click', ImageCommon.download);
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));
});
return Menu.menu.addEntry({ return Menu.menu.addEntry({
el: a, el: a,
order: 100, order: 100,
@ -14100,7 +13995,7 @@
return Conf[hotkey] = key; return Conf[hotkey] = key;
}, },
keydown: function(e) { 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))) { if (!(key = Keybinds.keyCode(e))) {
return; return;
} }
@ -14127,10 +14022,13 @@
Header.toggleBarVisibility(); Header.toggleBarVisibility();
break; break;
case Conf['Open empty QR']: case Conf['Open empty QR']:
if (!QR.postingIsEnabled) {
return;
}
Keybinds.qr(); Keybinds.qr();
break; break;
case Conf['Open QR']: case Conf['Open QR']:
if (!threadRoot) { if (!(QR.postingIsEnabled && threadRoot)) {
return; return;
} }
Keybinds.qr(threadRoot); Keybinds.qr(threadRoot);
@ -14221,31 +14119,31 @@
ThreadWatcher.toggle(thread); ThreadWatcher.toggle(thread);
break; break;
case Conf['Expand image']: case Conf['Expand image']:
if (!threadRoot) { if (!(ImageExpand.enabled && threadRoot)) {
return; return;
} }
Keybinds.img(threadRoot); Keybinds.img(threadRoot);
break; break;
case Conf['Expand images']: case Conf['Expand images']:
if (!threadRoot) { if (!(ImageExpand.enabled && threadRoot)) {
return; return;
} }
Keybinds.img(threadRoot, true); Keybinds.img(threadRoot, true);
break; break;
case Conf['Open Gallery']: case Conf['Open Gallery']:
if ((_ref2 = g.VIEW) !== 'index' && _ref2 !== 'thread') { if (!Gallery.enabled) {
return; return;
} }
Gallery.cb.toggle(); Gallery.cb.toggle();
break; break;
case Conf['fappeTyme']: 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; return;
} }
FappeTyme.toggle('fappe'); FappeTyme.toggle('fappe');
break; break;
case Conf['werkTyme']: 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; return;
} }
FappeTyme.toggle('werk'); FappeTyme.toggle('werk');
@ -14265,7 +14163,7 @@
return; return;
} }
if (Conf['JSON Navigation']) { if (Conf['JSON Navigation']) {
if ((_ref5 = Conf['Index Mode']) !== 'paged' && _ref5 !== 'infinite') { if ((_ref4 = Conf['Index Mode']) !== 'paged' && _ref4 !== 'infinite') {
return; return;
} }
$('.next button', Index.pagelist).click(); $('.next button', Index.pagelist).click();
@ -14280,7 +14178,7 @@
return; return;
} }
if (Conf['JSON Navigation']) { if (Conf['JSON Navigation']) {
if ((_ref6 = Conf['Index Mode']) !== 'paged' && _ref6 !== 'infinite') { if ((_ref5 = Conf['Index Mode']) !== 'paged' && _ref5 !== 'infinite') {
return; return;
} }
$('.prev button', Index.pagelist).click(); $('.prev button', Index.pagelist).click();
@ -14424,17 +14322,11 @@
return key; return key;
}, },
qr: function(thread) { qr: function(thread) {
if (!(Conf['Quick Reply'] && QR.postingIsEnabled)) {
return;
}
QR.open(); QR.open();
if (thread != null) { if (thread != null) {
QR.quote.call($('input', $('.post.highlight', thread) || thread)); QR.quote.call($('input', $('.post.highlight', thread) || thread));
} }
QR.nodes.com.focus(); return QR.nodes.com.focus();
if (Conf['QR Shortcut']) {
return $.rmClass($('.qr-shortcut'), 'disabled');
}
}, },
tags: function(tag, ta) { tags: function(tag, ta) {
var range, selEnd, selStart, supported, value; var range, selEnd, selStart, supported, value;

Binary file not shown.

View File

@ -1,6 +1,6 @@
// ==UserScript== // ==UserScript==
// @name 4chan X // @name 4chan X
// @version 1.9.20.8 // @version 1.9.21.0
// @minGMVer 1.14 // @minGMVer 1.14
// @minFFVer 26 // @minFFVer 26
// @namespace 4chan-X // @namespace 4chan-X

View File

@ -1,7 +1,7 @@
// Generated by CoffeeScript // Generated by CoffeeScript
// ==UserScript== // ==UserScript==
// @name 4chan X // @name 4chan X
// @version 1.9.20.8 // @version 1.9.21.0
// @minGMVer 1.14 // @minGMVer 1.14
// @minFFVer 26 // @minFFVer 26
// @namespace 4chan-X // @namespace 4chan-X
@ -25,12 +25,12 @@
// ==/UserScript== // ==/UserScript==
/* /*
* 4chan X - Version 1.9.20.8 * 4chan X - Version 1.9.21.0
* *
* Licensed under the MIT license. * Licensed under the MIT license.
* https://github.com/ccd0/4chan-x/blob/master/LICENSE * https://github.com/ccd0/4chan-x/blob/master/LICENSE
* *
* Appchan X Copyright © 2013-2014 Zixaphir <zixaphirmoxphar@gmail.com> * Appchan X Copyright © 2013-2015 Zixaphir <zixaphirmoxphar@gmail.com>
* http://zixaphir.github.io/appchan-x/ * http://zixaphir.github.io/appchan-x/
* 4chan x Copyright © 2009-2011 James Campos <james.r.campos@gmail.com> * 4chan x Copyright © 2009-2011 James Campos <james.r.campos@gmail.com>
* https://github.com/aeosynth/4chan-x * https://github.com/aeosynth/4chan-x
@ -195,7 +195,7 @@
'Werk Tyme': [false, 'Hide all post images when header menu item is checked.'], 'Werk Tyme': [false, 'Hide all post images when header menu item is checked.'],
'Autoplay': [true, 'Videos begin playing immediately when opened.'], 'Autoplay': [true, 'Videos begin playing immediately when opened.'],
'Restart when Opened': [true, 'Restart GIFs and WebMs when you hover over or expand them.'], '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.'] 'Loop in New Tab': [true, 'Loop videos opened in their own tabs.']
}, },
'Menu': { 'Menu': {
@ -396,7 +396,7 @@
doc = d.documentElement; doc = d.documentElement;
g = { g = {
VERSION: '1.9.20.8', VERSION: '1.9.21.0',
NAMESPACE: '4chan X.', NAMESPACE: '4chan X.',
NAME: '4chan X', NAME: '4chan X',
FAQ: 'https://github.com/ccd0/4chan-x/wiki/Frequently-Asked-Questions', FAQ: 'https://github.com/ccd0/4chan-x/wiki/Frequently-Asked-Questions',
@ -1511,7 +1511,6 @@
this.file.text = file.firstElementChild; this.file.text = file.firstElementChild;
this.file.thumb = $('.fileThumb > [data-md5]', file); this.file.thumb = $('.fileThumb > [data-md5]', file);
this.file.fullImage = $('.full-image', file); this.file.fullImage = $('.full-image', file);
this.file.videoControls = $('.video-controls', this.file.text);
if (contractThumb) { if (contractThumb) {
ImageExpand.contract(this); ImageExpand.contract(this);
} }
@ -3749,8 +3748,6 @@
}; };
flag = !flagCode ? { flag = !flagCode ? {
innerHTML: "" innerHTML: ""
} : false ? {
innerHTML: " <img src=\"//s.4cdn.org/image/country/troll/" + E(flagCode.toLowerCase()) + ".gif\" alt=\"" + E(flagCode) + "\" title=\"" + E(flagName) + "\" class=\"countryFlag\">"
} : { } : {
innerHTML: " <span title=\"" + E(flagName) + "\" class=\"flag flag-" + E(flagCode.toLowerCase()) + "\"></span>" innerHTML: " <span title=\"" + E(flagName) + "\" class=\"flag flag-" + E(flagCode.toLowerCase()) + "\"></span>"
}; };
@ -6614,17 +6611,20 @@
mimeTypes: ['image/jpeg', 'image/png', 'image/gif', 'application/pdf', 'application/vnd.adobe.flash.movie', 'application/x-shockwave-flash', 'video/webm'], mimeTypes: ['image/jpeg', 'image/png', 'image/gif', 'application/pdf', 'application/vnd.adobe.flash.movie', 'application/x-shockwave-flash', 'video/webm'],
init: function() { init: function() {
var noscript, sc; var noscript, sc;
if (!Conf['Quick Reply'] || g.VIEW === 'archive') { if (!Conf['Quick Reply']) {
return; return;
} }
this.db = new DataBoard('yourPosts'); this.db = new DataBoard('yourPosts');
this.posts = []; this.posts = [];
if (g.VIEW === 'archive') {
return;
}
$.globalEval('document.documentElement.dataset.jsEnabled = true;'); $.globalEval('document.documentElement.dataset.jsEnabled = true;');
noscript = Conf['Force Noscript Captcha'] || !doc.dataset.jsEnabled; noscript = Conf['Force Noscript Captcha'] || !doc.dataset.jsEnabled;
this.captcha = Captcha[noscript ? 'noscript' : 'v2']; this.captcha = Captcha[noscript ? 'noscript' : 'v2'];
if (Conf['QR Shortcut']) { if (Conf['QR Shortcut']) {
sc = $.el('a', { sc = $.el('a', {
className: "qr-shortcut fa fa-comment-o " + (!Conf['Persistent QR'] ? 'disabled' : ''), className: 'qr-shortcut fa fa-comment-o disabled',
textContent: 'QR', textContent: 'QR',
title: 'Quick Reply', title: 'Quick Reply',
href: 'javascript:;' href: 'javascript:;'
@ -6635,11 +6635,9 @@
} }
if (Conf['Persistent QR'] || !QR.nodes || QR.nodes.el.hidden) { if (Conf['Persistent QR'] || !QR.nodes || QR.nodes.el.hidden) {
QR.open(); QR.open();
QR.nodes.com.focus(); return QR.nodes.com.focus();
return $.rmClass(this, 'disabled');
} else { } else {
QR.close(); return QR.close();
return $.addClass(this, 'disabled');
} }
}); });
Header.addShortcut(sc); Header.addShortcut(sc);
@ -6674,12 +6672,8 @@
}); });
QR.link = link.firstElementChild; QR.link = link.firstElementChild;
$.on(link.firstChild, 'click', function() { $.on(link.firstChild, 'click', function() {
$.event('CloseMenu');
QR.open(); QR.open();
QR.nodes.com.focus(); return QR.nodes.com.focus();
if (Conf['QR Shortcut']) {
return $.rmClass($('.qr-shortcut'), 'disabled');
}
}); });
if (Conf['Bottom QR Link'] && g.VIEW === 'thread') { if (Conf['Bottom QR Link'] && g.VIEW === 'thread') {
linkBot = $.el('div', { linkBot = $.el('div', {
@ -6689,12 +6683,8 @@
innerHTML: "<a href=\"javascript:;\" class=\"qr-link-bottom\">Reply to Thread</a>" innerHTML: "<a href=\"javascript:;\" class=\"qr-link-bottom\">Reply to Thread</a>"
}); });
$.on(linkBot.firstElementChild, 'click', function() { $.on(linkBot.firstElementChild, 'click', function() {
$.event('CloseMenu');
QR.open(); QR.open();
QR.nodes.com.focus(); return QR.nodes.com.focus();
if (Conf['QR Shortcut']) {
return $.rmClass($('.qr-shortcut'), 'disabled');
}
}); });
$.prepend($('.navLinksBot'), linkBot); $.prepend($('.navLinksBot'), linkBot);
} }
@ -6739,17 +6729,21 @@
} }
QR.nodes.el.hidden = false; QR.nodes.el.hidden = false;
QR.unhide(); 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 { if (Conf['QR Shortcut']) {
return QR.dialog(); return $.rmClass($('.qr-shortcut'), 'disabled');
} catch (_error) {
err = _error;
delete QR.nodes;
return Main.handleErrors({
message: 'Quick Reply dialog creation crashed.',
error: err
});
} }
}, },
close: function() { close: function() {
@ -6763,7 +6757,7 @@
d.activeElement.blur(); d.activeElement.blur();
$.rmClass(QR.nodes.el, 'dump'); $.rmClass(QR.nodes.el, 'dump');
if (Conf['QR Shortcut']) { if (Conf['QR Shortcut']) {
$.toggleClass($('.qr-shortcut'), 'disabled'); $.addClass($('.qr-shortcut'), 'disabled');
} }
new QR.post(true); new QR.post(true);
_ref = QR.posts.splice(0, QR.posts.length - 1); _ref = QR.posts.splice(0, QR.posts.length - 1);
@ -6957,10 +6951,7 @@
com.setSelectionRange(range, range); com.setSelectionRange(range, range);
com.focus(); com.focus();
QR.selected.save(com); QR.selected.save(com);
QR.selected.save(thread); return QR.selected.save(thread);
if (Conf['QR Shortcut']) {
return $.rmClass($('.qr-shortcut'), 'disabled');
}
}, },
characterCount: function() { characterCount: function() {
var count, counter; var count, counter;
@ -7281,7 +7272,6 @@
nodes.flashTag.dataset["default"] = '4'; nodes.flashTag.dataset["default"] = '4';
$.add(nodes.form, nodes.flashTag); $.add(nodes.form, nodes.flashTag);
} }
QR.flagsInput();
$.on(nodes.filename.parentNode, 'click keydown', QR.openFileInput); $.on(nodes.filename.parentNode, 'click keydown', QR.openFileInput);
$.on(nodes.autohide, 'change', QR.toggleHide); $.on(nodes.autohide, 'change', QR.toggleHide);
$.on(nodes.close, 'click', QR.close); $.on(nodes.close, 'click', QR.close);
@ -7303,7 +7293,7 @@
return QR.selected.nodes.spoiler.click(); return QR.selected.nodes.spoiler.click();
}); });
$.on(nodes.fileInput, 'change', QR.handleFiles); $.on(nodes.fileInput, 'change', QR.handleFiles);
items = ['thread', 'name', 'email', 'sub', 'com', 'filename', 'flag']; items = ['thread', 'name', 'email', 'sub', 'com', 'filename'];
i = 0; i = 0;
save = function() { save = function() {
return QR.selected.save(this); return QR.selected.save(this);
@ -7336,43 +7326,6 @@
QR.captcha.setup(); QR.captcha.setup();
return $.event('QRDialogCreation', null, dialog); 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) { submit: function(e) {
var captcha, cb, err, extra, filetag, formData, options, post, textOnly, thread, threadID; var captcha, cb, err, extra, filetag, formData, options, post, textOnly, thread, threadID;
if (e != null) { if (e != null) {
@ -7438,7 +7391,6 @@
upfile: post.file, upfile: post.file,
filetag: filetag, filetag: filetag,
spoiler: post.spoiler, spoiler: post.spoiler,
flag: post.flag,
textonly: textOnly, textonly: textOnly,
mode: 'regist', mode: 'regist',
pwd: QR.persona.pwd pwd: QR.persona.pwd
@ -8460,8 +8412,7 @@
persona = _arg['QR.persona']; persona = _arg['QR.persona'];
persona = { persona = {
name: post.name, name: post.name,
email: /^sage$/.test(post.email) ? persona.email : post.email, email: /^sage$/.test(post.email) ? persona.email : post.email
flag: post.flag
}; };
return $.set('QR.persona', persona); 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.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.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 : ''; _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) { if (QR.selected === _this) {
return _this.load(); return _this.load();
} }
@ -8567,7 +8515,7 @@
if (this !== QR.selected) { if (this !== QR.selected) {
return; 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++) { for (_i = 0, _len = _ref.length; _i < _len; _i++) {
name = _ref[_i]; name = _ref[_i];
if (node = QR.nodes[name]) { if (node = QR.nodes[name]) {
@ -8601,7 +8549,7 @@
_Class.prototype.load = function() { _Class.prototype.load = function() {
var name, node, _i, _len, _ref; 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++) { for (_i = 0, _len = _ref.length; _i < _len; _i++) {
name = _ref[_i]; name = _ref[_i];
if (!(node = QR.nodes[name])) { if (!(node = QR.nodes[name])) {
@ -8651,7 +8599,7 @@
if (this !== QR.selected) { if (this !== QR.selected) {
return; 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++) { for (_i = 0, _len = _ref.length; _i < _len; _i++) {
name = _ref[_i]; name = _ref[_i];
if (!(node = QR.nodes[name])) { if (!(node = QR.nodes[name])) {
@ -8826,7 +8774,7 @@
FappeTyme = { FappeTyme = {
init: function() { init: function() {
var el, lc, type, _i, _len, _ref, _ref1; 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; return;
} }
this.nodes = {}; this.nodes = {};
@ -8898,7 +8846,7 @@
Gallery = { Gallery = {
init: function() { init: function() {
var el, _ref; 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; return;
} }
this.delay = Conf['Slide Delay']; this.delay = Conf['Slide Delay'];
@ -8970,6 +8918,7 @@
cb = Gallery.cb; cb = Gallery.cb;
$.on(nodes.frame, 'click', cb.blank); $.on(nodes.frame, 'click', cb.blank);
$.on(nodes.next, 'click', cb.click); $.on(nodes.next, 'click', cb.click);
$.on(nodes.name, 'click', ImageCommon.download);
$.on($('.gal-prev', dialog), 'click', cb.prev); $.on($('.gal-prev', dialog), 'click', cb.prev);
$.on($('.gal-next', dialog), 'click', cb.next); $.on($('.gal-next', dialog), 'click', cb.next);
$.on($('.gal-start', dialog), 'click', cb.start); $.on($('.gal-start', dialog), 'click', cb.start);
@ -9168,7 +9117,7 @@
case 'Right': case 'Right':
return Gallery.cb.next; return Gallery.cb.next;
case 'Enter': case 'Enter':
return Gallery.cb.enterKey; return Gallery.cb.advance;
case 'Left': case 'Left':
case '': case '':
return Gallery.cb.prev; return Gallery.cb.prev;
@ -9204,16 +9153,20 @@
next: function() { next: function() {
return Gallery.cb.open.call(Gallery.images[+Gallery.nodes.current.dataset.id + 1] || Gallery.images[0]); 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) { if (Gallery.nodes.current.paused) {
return Gallery.nodes.current.play(); return Gallery.nodes.current.play();
} else { } else {
return Gallery.cb.next(); return Gallery.cb.next();
} }
}, },
click: function() {
return Gallery.cb[Gallery.nodes.current.controls ? 'stop' : 'enterKey']();
},
toggle: function() { toggle: function() {
return (Gallery.nodes ? Gallery.cb.close : Gallery.build)(); return (Gallery.nodes ? Gallery.cb.close : Gallery.build)();
}, },
@ -9285,8 +9238,8 @@
}, },
menu: { menu: {
init: function() { init: function() {
var el, _ref; var el;
if (((_ref = g.VIEW) !== 'index' && _ref !== 'thread') || !Conf['Gallery']) { if (!Gallery.enabled) {
return; return;
} }
el = $.el('span', { el = $.el('span', {
@ -9440,13 +9393,32 @@
}); });
}; };
return $.on(video, 'mouseover', handler); 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 = { ImageExpand = {
init: function() { init: function() {
var _ref; 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; return;
} }
this.EAI = $.el('a', { this.EAI = $.el('a', {
@ -9458,12 +9430,6 @@
$.on(this.EAI, 'click', this.cb.toggleAll); $.on(this.EAI, 'click', this.cb.toggleAll);
Header.addShortcut(this.EAI, 3); Header.addShortcut(this.EAI, 3);
$.on(d, 'scroll visibilitychange', this.cb.playVideos); $.on(d, 'scroll visibilitychange', this.cb.playVideos);
this.videoControls = $.el('span', {
className: 'video-controls'
});
$.extend(this.videoControls, {
innerHTML: " <a href=\"javascript:;\" title=\"You can also contract the video by dragging it to the left.\">contract</a>"
});
return Post.callbacks.push({ return Post.callbacks.push({
name: 'Image Expansion', name: 'Image Expansion',
cb: this.node cb: this.node
@ -9480,7 +9446,6 @@
ImageExpand.contract(this); ImageExpand.contract(this);
return ImageExpand.expand(this); return ImageExpand.expand(this);
} else if (this.file.isExpanded && this.file.isVideo) { } 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); 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)) { } 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: { cb: {
toggle: function(e) { toggle: function(e) {
var file, post; var file, post, _ref;
if (e.shiftKey || e.altKey || e.ctrlKey || e.metaKey || e.button !== 0) { if (e.shiftKey || e.altKey || e.ctrlKey || e.metaKey || e.button !== 0) {
return; return;
} }
post = Get.postFromNode(this); post = Get.postFromNode(this);
file = post.file; file = post.file;
if (file.isExpanded && file.isVideo && file.fullImage.controls) { if (file.isExpanded && ImageCommon.onControls(e)) {
return; return;
} }
e.preventDefault(); 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() { toggleAll: function() {
var func, toggle; var func, toggle;
@ -9581,7 +9550,7 @@
} }
}, },
contract: function(post) { 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; file = post.file;
if (el = file.fullImage) { if (el = file.fullImage) {
top = Header.getTopOf(el); top = Header.getTopOf(el);
@ -9591,12 +9560,9 @@
} }
$.rmClass(post.nodes.root, 'expanded-image'); $.rmClass(post.nodes.root, 'expanded-image');
$.rmClass(file.thumb, 'expanding'); $.rmClass(file.thumb, 'expanding');
if (file.videoControls) {
$.rm(file.videoControls);
}
file.thumb.parentNode.href = file.URL; file.thumb.parentNode.href = file.URL;
file.thumb.parentNode.target = '_blank'; 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++) { for (_i = 0, _len = _ref.length; _i < _len; _i++) {
x = _ref[_i]; x = _ref[_i];
delete file[x]; delete file[x];
@ -9618,11 +9584,6 @@
ImageCommon.pushCache(el); ImageCommon.pushCache(el);
if (file.isVideo) { if (file.isVideo) {
el.pause(); el.pause();
_ref1 = ImageExpand.videoCB;
for (eventName in _ref1) {
cb = _ref1[eventName];
$.off(el, eventName, cb);
}
} }
if (Conf['Restart when Opened']) { if (Conf['Restart when Opened']) {
ImageCommon.rewind(file.thumb); ImageCommon.rewind(file.thumb);
@ -9666,14 +9627,9 @@
el.className = 'full-image'; el.className = 'full-image';
$.after(thumb, el); $.after(thumb, el);
if (isVideo) { 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('href');
thumb.parentNode.removeAttribute('target'); thumb.parentNode.removeAttribute('target');
el.loop = true; el.loop = true;
ImageExpand.setupVideoCB(post);
} }
if (!isVideo) { if (!isVideo) {
return $.asap((function() { return $.asap((function() {
@ -9741,49 +9697,6 @@
return ImageCommon.addControls(fullImage); 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() { error: function() {
var post; var post;
post = Get.postFromNode(this); post = Get.postFromNode(this);
@ -9809,8 +9722,8 @@
}, },
menu: { menu: {
init: function() { init: function() {
var conf, createSubEntry, el, name, subEntries, _ref, _ref1; var conf, createSubEntry, el, name, subEntries, _ref;
if (((_ref = g.VIEW) !== 'index' && _ref !== 'thread') || !Conf['Image Expansion']) { if (!ImageExpand.enabled) {
return; return;
} }
el = $.el('span', { el = $.el('span', {
@ -9819,9 +9732,9 @@
}); });
createSubEntry = ImageExpand.menu.createSubEntry; createSubEntry = ImageExpand.menu.createSubEntry;
subEntries = []; subEntries = [];
_ref1 = Config.imageExpansion; _ref = Config.imageExpansion;
for (name in _ref1) { for (name in _ref) {
conf = _ref1[name]; conf = _ref[name];
subEntries.push(createSubEntry(name, conf[1])); subEntries.push(createSubEntry(name, conf[1]));
} }
return Header.menu.addEntry({ return Header.menu.addEntry({
@ -9967,7 +9880,7 @@
ImageLoader = { ImageLoader = {
init: function() { init: function() {
var prefetch, _ref; var prefetch, _ref;
if ((_ref = g.VIEW) !== 'index' && _ref !== 'thread') { if (!(((_ref = g.VIEW) === 'index' || _ref === 'thread') && g.BOARD.ID !== 'f')) {
return; return;
} }
if (!(Conf['Image Prefetching'] || Conf['Replace JPG'] || Conf['Replace PNG'] || Conf['Replace GIF'] || Conf['Replace WEBM'])) { if (!(Conf['Image Prefetching'] || Conf['Replace JPG'] || Conf['Replace PNG'] || Conf['Replace GIF'] || Conf['Replace WEBM'])) {
@ -10434,23 +10347,20 @@
return; return;
} }
if ($.hasClass(this, "embedded")) { if ($.hasClass(this, "embedded")) {
if (!$.hasClass(this.previousElementSibling, 'linkify')) { $.rm(this.nextElementSibling);
$.rm(this.previousElementSibling);
}
this.previousElementSibling.hidden = false;
this.textContent = '(embed)'; this.textContent = '(embed)';
} else { } else {
this.previousElementSibling.hidden = true; $.after(this, Embedding.cb.embed(this));
$.before(this, Embedding.cb.embed(this));
this.textContent = '(unembed)'; this.textContent = '(unembed)';
} }
return $.toggleClass(this, 'embedded'); return $.toggleClass(this, 'embedded');
}, },
embed: function(a) { embed: function(a) {
var el, type; var container, el, type;
el = (type = Embedding.types[a.dataset.key]).el(a); container = $.el('div');
el.style.cssText = type.style != null ? type.style : "border: 0; width: 640px; height: 390px"; $.add(container, el = (type = Embedding.types[a.dataset.key]).el(a));
return el; el.style.cssText = type.style != null ? type.style : "border:0;width:640px;height:390px";
return container;
}, },
title: function(req, data) { title: function(req, data) {
var key, link, link2, options, post, post2, service, status, text, uid, _i, _j, _len, _len1, _ref, _ref1; var key, link, link2, options, post, post2, service, status, text, uid, _i, _j, _len, _len1, _ref, _ref1;
@ -11226,22 +11136,7 @@
className: 'download-link', className: 'download-link',
textContent: 'Download file' textContent: 'Download file'
}); });
$.on(a, 'click', function(e) { $.on(a, 'click', ImageCommon.download);
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));
});
return Menu.menu.addEntry({ return Menu.menu.addEntry({
el: a, el: a,
order: 100, order: 100,
@ -14101,7 +13996,7 @@
return Conf[hotkey] = key; return Conf[hotkey] = key;
}, },
keydown: function(e) { 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))) { if (!(key = Keybinds.keyCode(e))) {
return; return;
} }
@ -14128,10 +14023,13 @@
Header.toggleBarVisibility(); Header.toggleBarVisibility();
break; break;
case Conf['Open empty QR']: case Conf['Open empty QR']:
if (!QR.postingIsEnabled) {
return;
}
Keybinds.qr(); Keybinds.qr();
break; break;
case Conf['Open QR']: case Conf['Open QR']:
if (!threadRoot) { if (!(QR.postingIsEnabled && threadRoot)) {
return; return;
} }
Keybinds.qr(threadRoot); Keybinds.qr(threadRoot);
@ -14222,31 +14120,31 @@
ThreadWatcher.toggle(thread); ThreadWatcher.toggle(thread);
break; break;
case Conf['Expand image']: case Conf['Expand image']:
if (!threadRoot) { if (!(ImageExpand.enabled && threadRoot)) {
return; return;
} }
Keybinds.img(threadRoot); Keybinds.img(threadRoot);
break; break;
case Conf['Expand images']: case Conf['Expand images']:
if (!threadRoot) { if (!(ImageExpand.enabled && threadRoot)) {
return; return;
} }
Keybinds.img(threadRoot, true); Keybinds.img(threadRoot, true);
break; break;
case Conf['Open Gallery']: case Conf['Open Gallery']:
if ((_ref2 = g.VIEW) !== 'index' && _ref2 !== 'thread') { if (!Gallery.enabled) {
return; return;
} }
Gallery.cb.toggle(); Gallery.cb.toggle();
break; break;
case Conf['fappeTyme']: 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; return;
} }
FappeTyme.toggle('fappe'); FappeTyme.toggle('fappe');
break; break;
case Conf['werkTyme']: 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; return;
} }
FappeTyme.toggle('werk'); FappeTyme.toggle('werk');
@ -14266,7 +14164,7 @@
return; return;
} }
if (Conf['JSON Navigation']) { if (Conf['JSON Navigation']) {
if ((_ref5 = Conf['Index Mode']) !== 'paged' && _ref5 !== 'infinite') { if ((_ref4 = Conf['Index Mode']) !== 'paged' && _ref4 !== 'infinite') {
return; return;
} }
$('.next button', Index.pagelist).click(); $('.next button', Index.pagelist).click();
@ -14281,7 +14179,7 @@
return; return;
} }
if (Conf['JSON Navigation']) { if (Conf['JSON Navigation']) {
if ((_ref6 = Conf['Index Mode']) !== 'paged' && _ref6 !== 'infinite') { if ((_ref5 = Conf['Index Mode']) !== 'paged' && _ref5 !== 'infinite') {
return; return;
} }
$('.prev button', Index.pagelist).click(); $('.prev button', Index.pagelist).click();
@ -14425,17 +14323,11 @@
return key; return key;
}, },
qr: function(thread) { qr: function(thread) {
if (!(Conf['Quick Reply'] && QR.postingIsEnabled)) {
return;
}
QR.open(); QR.open();
if (thread != null) { if (thread != null) {
QR.quote.call($('input', $('.post.highlight', thread) || thread)); QR.quote.call($('input', $('.post.highlight', thread) || thread));
} }
QR.nodes.com.focus(); return QR.nodes.com.focus();
if (Conf['QR Shortcut']) {
return $.rmClass($('.qr-shortcut'), 'disabled');
}
}, },
tags: function(tag, ta) { tags: function(tag, ta) {
var range, selEnd, selStart, supported, value; var range, selEnd, selStart, supported, value;

Binary file not shown.

View File

@ -1,7 +1,7 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<gupdate xmlns='http://www.google.com/update2/response' protocol='2.0'> <gupdate xmlns='http://www.google.com/update2/response' protocol='2.0'>
<app appid='lacclbnghgdicfifcamcmcnilckjamag'> <app appid='lacclbnghgdicfifcamcmcnilckjamag'>
<updatecheck codebase='https://ccd0.github.io/4chan-x/builds/4chan-X-beta.crx' version='1.9.20.8' /> <updatecheck codebase='https://ccd0.github.io/4chan-x/builds/4chan-X-beta.crx' version='1.9.21.0' />
</app> </app>
</gupdate> </gupdate>

View File

@ -1,7 +1,7 @@
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<gupdate xmlns='http://www.google.com/update2/response' protocol='2.0'> <gupdate xmlns='http://www.google.com/update2/response' protocol='2.0'>
<app appid='lacclbnghgdicfifcamcmcnilckjamag'> <app appid='lacclbnghgdicfifcamcmcnilckjamag'>
<updatecheck codebase='https://ccd0.github.io/4chan-x/builds/4chan-X.crx' version='1.9.20.8' /> <updatecheck codebase='https://ccd0.github.io/4chan-x/builds/4chan-X.crx' version='1.9.21.0' />
</app> </app>
</gupdate> </gupdate>

View File

@ -3,7 +3,7 @@
"description": "Cross-browser userscript for maximum lurking on 4chan.", "description": "Cross-browser userscript for maximum lurking on 4chan.",
"meta": { "meta": {
"name": "4chan X", "name": "4chan X",
"version": "1.9.20.8", "version": "1.9.21.0",
"repo": "https://github.com/ccd0/4chan-x/", "repo": "https://github.com/ccd0/4chan-x/",
"page": "https://github.com/ccd0/4chan-x", "page": "https://github.com/ccd0/4chan-x",
"downloads": "https://ccd0.github.io/4chan-x/builds/", "downloads": "https://ccd0.github.io/4chan-x/builds/",