Release 4chan X v1.7.31.
This commit is contained in:
parent
9a9c507414
commit
8d153b8ac4
@ -1,3 +1,6 @@
|
||||
### v1.7.31
|
||||
*2014-05-08*
|
||||
|
||||
**Zixaphir**
|
||||
- Refactoring, bug fixes.
|
||||
|
||||
|
||||
2
LICENSE
2
LICENSE
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* 4chan X - Version 1.7.30 - 2014-05-05
|
||||
* 4chan X - Version 1.7.31 - 2014-05-08
|
||||
*
|
||||
* Licensed under the MIT license.
|
||||
* https://github.com/ccd0/4chan-x/blob/master/LICENSE
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
// ==UserScript==
|
||||
// @name 4chan X
|
||||
// @version 1.7.30
|
||||
// @version 1.7.31
|
||||
// @minGMVer 1.14
|
||||
// @minFFVer 26
|
||||
// @namespace 4chan-X
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
// Generated by CoffeeScript
|
||||
// ==UserScript==
|
||||
// @name 4chan X
|
||||
// @version 1.7.30
|
||||
// @version 1.7.31
|
||||
// @minGMVer 1.14
|
||||
// @minFFVer 26
|
||||
// @namespace 4chan-X
|
||||
@ -24,7 +24,7 @@
|
||||
// ==/UserScript==
|
||||
|
||||
/*
|
||||
* 4chan X - Version 1.7.30 - 2014-05-05
|
||||
* 4chan X - Version 1.7.31 - 2014-05-08
|
||||
*
|
||||
* Licensed under the MIT license.
|
||||
* https://github.com/ccd0/4chan-x/blob/master/LICENSE
|
||||
@ -372,7 +372,7 @@
|
||||
doc = d.documentElement;
|
||||
|
||||
g = {
|
||||
VERSION: '1.7.30',
|
||||
VERSION: '1.7.31',
|
||||
NAMESPACE: '4chan X.',
|
||||
boards: {}
|
||||
};
|
||||
@ -3095,7 +3095,7 @@
|
||||
o.file = {
|
||||
name: data.filename + data.ext,
|
||||
timestamp: "" + data.tim + data.ext,
|
||||
url: boardID === 'f' ? "//i.4cdn.org/" + boardID + "/" + data.filename + data.ext : "//i.4cdn.org/" + boardID + "/" + data.tim + data.ext,
|
||||
url: boardID === 'f' ? ("//i.4cdn.org/" + boardID + "/" + data.filename + data.ext).replace(/'/g, ''') : "//i.4cdn.org/" + boardID + "/" + data.tim + data.ext,
|
||||
height: data.h,
|
||||
width: data.w,
|
||||
MD5: data.md5,
|
||||
@ -5682,7 +5682,7 @@
|
||||
return $.addClass(doc, 'hide-original-post-form');
|
||||
});
|
||||
}
|
||||
$.ready(this.initReady);
|
||||
$.on(d, '4chanXInitFinished', this.initReady);
|
||||
if (Conf['Persistent QR']) {
|
||||
if (!(g.BOARD.ID === 'f' && g.VIEW === 'index')) {
|
||||
$.on(d, '4chanXInitFinished', this.persist);
|
||||
@ -5697,6 +5697,7 @@
|
||||
},
|
||||
initReady: function() {
|
||||
var link;
|
||||
$.off(d, '4chanXInitFinished', this.initReady);
|
||||
QR.postingIsEnabled = !!$.id('postForm');
|
||||
if (!QR.postingIsEnabled) {
|
||||
return;
|
||||
@ -6051,9 +6052,10 @@
|
||||
}
|
||||
},
|
||||
handleFile: function(file, index, nfiles) {
|
||||
var isNewPost, max, post, _ref;
|
||||
var isNewPost, isSingle, max, post, _ref;
|
||||
isSingle = nfiles === 1;
|
||||
if (/^text\//.test(file.type)) {
|
||||
if (nfiles === 1) {
|
||||
if (isSingle) {
|
||||
post = QR.selected;
|
||||
} else if (index !== 0 || (post = QR.posts[QR.posts.length - 1]).com) {
|
||||
post = new QR.post();
|
||||
@ -6063,7 +6065,7 @@
|
||||
}
|
||||
if (_ref = file.type, __indexOf.call(QR.mimeTypes, _ref) < 0) {
|
||||
QR.error("" + file.name + ": Unsupported file type.");
|
||||
if (nfiles !== 1) {
|
||||
if (!isSingle) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -6073,22 +6075,25 @@
|
||||
}
|
||||
if (file.size > max) {
|
||||
QR.error("" + file.name + ": File too large (file: " + ($.bytesToString(file.size)) + ", max: " + ($.bytesToString(max)) + ").");
|
||||
if (nfiles !== 1) {
|
||||
if (!isSingle) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
isNewPost = false;
|
||||
if (nfiles === 1) {
|
||||
if (isSingle) {
|
||||
post = QR.selected;
|
||||
} else if (index !== 0 || (post = QR.posts[QR.posts.length - 1]).file) {
|
||||
isNewPost = true;
|
||||
post = new QR.post();
|
||||
}
|
||||
return QR.checkDimensions(file, function(pass) {
|
||||
if (pass || nfiles === 1) {
|
||||
return post.setFile(file);
|
||||
return QR.checkDimensions(file, function(pass, el) {
|
||||
if (pass || isSingle) {
|
||||
return post.setFile(file, el);
|
||||
} else if (isNewPost) {
|
||||
return post.rm();
|
||||
post.rm();
|
||||
if (el) {
|
||||
return URL.revokeObjectURL(el.src);
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
@ -6096,75 +6101,69 @@
|
||||
var img, video;
|
||||
if (/^image\//.test(file.type)) {
|
||||
img = new Image();
|
||||
img.onload = (function(_this) {
|
||||
return function() {
|
||||
var height, pass, width;
|
||||
height = img.height, width = img.width;
|
||||
pass = true;
|
||||
if (height > QR.max_height || width > QR.max_width) {
|
||||
QR.error("" + file.name + ": Image too large (image: " + height + "x" + width + "px, max: " + QR.max_height + "x" + QR.max_width + "px)");
|
||||
pass = false;
|
||||
}
|
||||
if (height < QR.min_height || width < QR.min_width) {
|
||||
QR.error("" + file.name + ": Image too small (image: " + height + "x" + width + "px, min: " + QR.min_height + "x" + QR.min_width + "px)");
|
||||
pass = false;
|
||||
}
|
||||
return cb(pass);
|
||||
};
|
||||
})(this);
|
||||
img.onload = function() {
|
||||
var height, pass, width;
|
||||
height = img.height, width = img.width;
|
||||
pass = true;
|
||||
if (height > QR.max_height || width > QR.max_width) {
|
||||
QR.error("" + file.name + ": Image too large (image: " + height + "x" + width + "px, max: " + QR.max_height + "x" + QR.max_width + "px)");
|
||||
pass = false;
|
||||
}
|
||||
if (height < QR.min_height || width < QR.min_width) {
|
||||
QR.error("" + file.name + ": Image too small (image: " + height + "x" + width + "px, min: " + QR.min_height + "x" + QR.min_width + "px)");
|
||||
pass = false;
|
||||
}
|
||||
return cb(pass, img);
|
||||
};
|
||||
return img.src = URL.createObjectURL(file);
|
||||
} else if (/^video\//.test(file.type)) {
|
||||
video = $.el('video');
|
||||
$.on(video, 'loadedmetadata', (function(_this) {
|
||||
return function() {
|
||||
var duration, max_height, max_width, pass, videoHeight, videoWidth;
|
||||
if (cb == null) {
|
||||
return;
|
||||
}
|
||||
videoHeight = video.videoHeight, videoWidth = video.videoWidth, duration = video.duration;
|
||||
max_height = Math.min(QR.max_height, QR.max_height_video);
|
||||
max_width = Math.min(QR.max_width, QR.max_width_video);
|
||||
pass = true;
|
||||
if (videoHeight > max_height || videoWidth > max_width) {
|
||||
QR.error("" + file.name + ": Video too large (video: " + videoHeight + "x" + videoWidth + "px, max: " + max_height + "x" + max_width + "px)");
|
||||
pass = false;
|
||||
}
|
||||
if (videoHeight < QR.min_height || videoWidth < QR.min_width) {
|
||||
QR.error("" + file.name + ": Video too small (video: " + videoHeight + "x" + videoWidth + "px, min: " + QR.min_height + "x" + QR.min_width + "px)");
|
||||
pass = false;
|
||||
}
|
||||
if (!isFinite(video.duration)) {
|
||||
QR.error("" + file.name + ": Video lacks duration metadata (try remuxing)");
|
||||
pass = false;
|
||||
}
|
||||
if (duration > QR.max_duration_video) {
|
||||
QR.error("" + file.name + ": Video too long (video: " + duration + "s, max: " + QR.max_duration_video + "s)");
|
||||
pass = false;
|
||||
}
|
||||
if (video.mozHasAudio) {
|
||||
QR.error("" + file.name + ": Audio not allowed");
|
||||
pass = false;
|
||||
}
|
||||
cb(pass);
|
||||
return cb = null;
|
||||
};
|
||||
})(this));
|
||||
$.on(video, 'error', (function(_this) {
|
||||
return function() {
|
||||
var _ref;
|
||||
if (cb == null) {
|
||||
return;
|
||||
}
|
||||
if (_ref = file.type, __indexOf.call(QR.mimeTypes, _ref) >= 0) {
|
||||
QR.error("" + file.name + ": Video appears corrupt");
|
||||
}
|
||||
cb(false);
|
||||
return cb = null;
|
||||
};
|
||||
})(this));
|
||||
$.on(video, 'loadedmetadata', function() {
|
||||
var duration, max_height, max_width, pass, videoHeight, videoWidth;
|
||||
if (!cb) {
|
||||
return;
|
||||
}
|
||||
videoHeight = video.videoHeight, videoWidth = video.videoWidth, duration = video.duration;
|
||||
max_height = Math.min(QR.max_height, QR.max_height_video);
|
||||
max_width = Math.min(QR.max_width, QR.max_width_video);
|
||||
pass = true;
|
||||
if (videoHeight > max_height || videoWidth > max_width) {
|
||||
QR.error("" + file.name + ": Video too large (video: " + videoHeight + "x" + videoWidth + "px, max: " + max_height + "x" + max_width + "px)");
|
||||
pass = false;
|
||||
}
|
||||
if (videoHeight < QR.min_height || videoWidth < QR.min_width) {
|
||||
QR.error("" + file.name + ": Video too small (video: " + videoHeight + "x" + videoWidth + "px, min: " + QR.min_height + "x" + QR.min_width + "px)");
|
||||
pass = false;
|
||||
}
|
||||
if (!isFinite(duration)) {
|
||||
QR.error("" + file.name + ": Video lacks duration metadata (try remuxing)");
|
||||
pass = false;
|
||||
} else if (duration > QR.max_duration_video) {
|
||||
QR.error("" + file.name + ": Video too long (video: " + duration + "s, max: " + QR.max_duration_video + "s)");
|
||||
pass = false;
|
||||
}
|
||||
if (video.mozHasAudio) {
|
||||
QR.error("" + file.name + ": Audio not allowed");
|
||||
pass = false;
|
||||
}
|
||||
cb(pass, video);
|
||||
return cb = null;
|
||||
});
|
||||
$.on(video, 'error', function() {
|
||||
var _ref;
|
||||
if (!cb) {
|
||||
return;
|
||||
}
|
||||
if (_ref = file.type, __indexOf.call(QR.mimeTypes, _ref) >= 0) {
|
||||
QR.error("" + file.name + ": Video appears corrupt");
|
||||
}
|
||||
URL.revokeObjectURL(file);
|
||||
cb(false, null);
|
||||
return cb = null;
|
||||
});
|
||||
return video.src = URL.createObjectURL(file);
|
||||
} else {
|
||||
return cb(true);
|
||||
return cb(true, null);
|
||||
}
|
||||
},
|
||||
openFileInput: function(e) {
|
||||
@ -6211,49 +6210,46 @@
|
||||
return list.value = g.VIEW === 'thread' ? g.THREADID : 'new';
|
||||
},
|
||||
dialog: function() {
|
||||
var dialog, elm, event, i, items, key, name, node, nodes, prop, rules, save, value, _, _i, _len, _ref, _ref1, _ref2, _ref3;
|
||||
var dialog, elm, event, i, items, name, node, nodes, prop, rules, save, setNode, _, _i, _len, _ref, _ref1, _ref2;
|
||||
QR.nodes = nodes = {
|
||||
el: dialog = UI.dialog('qr', 'top:0;right:0;', "<div class=move><label><input type=checkbox id=autohide title=Auto-hide>Quick Reply</label><a href=javascript:; class=close title=Close>×</a><select data-name=thread title='Create a new thread / Reply'><option value=new>New thread</option></select></div><form><div class=persona><input name=name data-name=name list=\"list-name\" placeholder=Name class=field size=1 tabindex=10><input name=email data-name=email list=\"list-email\" placeholder=E-mail class=field size=1 tabindex=20><input name=sub data-name=sub list=\"list-sub\" placeholder=Subject class=field size=1 tabindex=30> </div><div class=textarea><textarea data-name=com placeholder=Comment class=field tabindex=40></textarea><span id=char-count></span></div><div id=dump-list-container><div id=dump-list></div><a id=add-post href=javascript:; title=\"Add a post\" tabindex=50>+</a></div><div id=file-n-submit><span id=qr-filename-container class=field tabindex=60><span id=qr-no-file>No selected file</span><input id=\"qr-filename\" data-name=\"filename\" spellcheck=\"false\"><span id=qr-extras-container><a id=qr-filerm href=javascript:; title='Remove file'><i class=\"fa fa-times-circle\"></i></a><a id=url-button title='Post from url'><i class=\"fa fa-link\"></i></a><a id=dump-button title='Dump list'><i class=\"fa fa-plus-square\"></i></a></span></span><label id=qr-spoiler-label><input type=checkbox id=qr-file-spoiler title='Spoiler image' tabindex=70></label><input type=submit tabindex=80></div><input type=file multiple></form><datalist id=\"list-name\"></datalist><datalist id=\"list-email\"></datalist><datalist id=\"list-sub\"></datalist> ")
|
||||
};
|
||||
_ref = {
|
||||
move: '.move',
|
||||
autohide: '#autohide',
|
||||
thread: 'select',
|
||||
threadPar: '#qr-thread-select',
|
||||
close: '.close',
|
||||
form: 'form',
|
||||
dumpButton: '#dump-button',
|
||||
urlButton: '#url-button',
|
||||
name: '[data-name=name]',
|
||||
email: '[data-name=email]',
|
||||
sub: '[data-name=sub]',
|
||||
com: '[data-name=com]',
|
||||
dumpList: '#dump-list',
|
||||
addPost: '#add-post',
|
||||
charCount: '#char-count',
|
||||
fileSubmit: '#file-n-submit',
|
||||
filename: '#qr-filename',
|
||||
fileContainer: '#qr-filename-container',
|
||||
fileRM: '#qr-filerm',
|
||||
fileExtras: '#qr-extras-container',
|
||||
spoiler: '#qr-file-spoiler',
|
||||
spoilerPar: '#qr-spoiler-label',
|
||||
status: '[type=submit]',
|
||||
fileInput: '[type=file]'
|
||||
setNode = function(name, query) {
|
||||
return nodes[name] = $(query, dialog);
|
||||
};
|
||||
for (key in _ref) {
|
||||
value = _ref[key];
|
||||
nodes[key] = $(value, dialog);
|
||||
}
|
||||
setNode('move', '.move');
|
||||
setNode('autohide', '#autohide');
|
||||
setNode('thread', 'select');
|
||||
setNode('threadPar', '#qr-thread-select');
|
||||
setNode('close', '.close');
|
||||
setNode('form', 'form');
|
||||
setNode('dumpButton', '#dump-button');
|
||||
setNode('urlButton', '#url-button');
|
||||
setNode('name', '[data-name=name]');
|
||||
setNode('email', '[data-name=email]');
|
||||
setNode('sub', '[data-name=sub]');
|
||||
setNode('com', '[data-name=com]');
|
||||
setNode('dumpList', '#dump-list');
|
||||
setNode('addPost', '#add-post');
|
||||
setNode('charCount', '#char-count');
|
||||
setNode('fileSubmit', '#file-n-submit');
|
||||
setNode('filename', '#qr-filename');
|
||||
setNode('fileContainer', '#qr-filename-container');
|
||||
setNode('fileRM', '#qr-filerm');
|
||||
setNode('fileExtras', '#qr-extras-container');
|
||||
setNode('spoiler', '#qr-file-spoiler');
|
||||
setNode('spoilerPar', '#qr-spoiler-label');
|
||||
setNode('status', '[type=submit]');
|
||||
setNode('fileInput', '[type=file]');
|
||||
rules = $('ul.rules').textContent.trim();
|
||||
QR.min_width = QR.min_height = 1;
|
||||
QR.max_width = QR.max_height = 10000;
|
||||
try {
|
||||
_ref1 = rules.match(/.+smaller than (\d+)x(\d+).+/), _ = _ref1[0], QR.min_width = _ref1[1], QR.min_height = _ref1[2];
|
||||
_ref2 = rules.match(/.+greater than (\d+)x(\d+).+/), _ = _ref2[0], QR.max_width = _ref2[1], QR.max_height = _ref2[2];
|
||||
_ref3 = ['min_width', 'min_height', 'max_width', 'max_height'];
|
||||
for (_i = 0, _len = _ref3.length; _i < _len; _i++) {
|
||||
prop = _ref3[_i];
|
||||
_ref = rules.match(/.+smaller than (\d+)x(\d+).+/), _ = _ref[0], QR.min_width = _ref[1], QR.min_height = _ref[2];
|
||||
_ref1 = rules.match(/.+greater than (\d+)x(\d+).+/), _ = _ref1[0], QR.max_width = _ref1[1], QR.max_height = _ref1[2];
|
||||
_ref2 = ['min_width', 'min_height', 'max_width', 'max_height'];
|
||||
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
|
||||
prop = _ref2[_i];
|
||||
QR[prop] = parseInt(QR[prop], 10);
|
||||
}
|
||||
} catch (_error) {
|
||||
@ -6339,20 +6335,20 @@
|
||||
},
|
||||
flags: function() {
|
||||
var flag, fn, select, _i, _len, _ref;
|
||||
fn = function(val) {
|
||||
return $.el('option', {
|
||||
value: val[0],
|
||||
textContent: val[1]
|
||||
});
|
||||
};
|
||||
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];
|
||||
$.add(select, fn(flag));
|
||||
fn(flag);
|
||||
}
|
||||
return select;
|
||||
},
|
||||
@ -6459,14 +6455,11 @@
|
||||
responseType: 'document',
|
||||
withCredentials: true,
|
||||
onload: QR.response,
|
||||
onerror: function(err, url, line) {
|
||||
onerror: function() {
|
||||
delete QR.req;
|
||||
post.unlock();
|
||||
QR.cooldown.auto = false;
|
||||
QR.status();
|
||||
console.log(err);
|
||||
console.log(url);
|
||||
console.log(line);
|
||||
return QR.error($.el('span', {
|
||||
innerHTML: "4chan X encountered an error while posting. \n[<a href=\"//4chan.org/banned\" target=_blank>Banned?</a>] [<a href=\"https://github.com/ccd0/4chan-x/wiki/Frequently-Asked-Questions#what-does-4chan-x-encountered-an-error-while-posting-please-try-again-mean\" target=_blank>More info</a>]"
|
||||
}));
|
||||
@ -7250,7 +7243,7 @@
|
||||
}
|
||||
};
|
||||
|
||||
_Class.prototype.setFile = function(file) {
|
||||
_Class.prototype.setFile = function(file, el) {
|
||||
this.file = file;
|
||||
this.filename = file.name;
|
||||
this.filesize = $.bytesToString(file.size);
|
||||
@ -7261,55 +7254,49 @@
|
||||
if (this === QR.selected) {
|
||||
this.showFileData();
|
||||
}
|
||||
if (!/^(image|video)\//.test(file.type)) {
|
||||
this.nodes.el.style.backgroundImage = null;
|
||||
return;
|
||||
if (el) {
|
||||
return this.setThumbnail(el);
|
||||
} else {
|
||||
return this.nodes.el.style.backgroundImage = null;
|
||||
}
|
||||
return this.setThumbnail();
|
||||
};
|
||||
|
||||
_Class.prototype.setThumbnail = function() {
|
||||
var fileURL, img, isVideo;
|
||||
isVideo = /^video\//.test(this.file.type);
|
||||
img = $.el((isVideo ? 'video' : 'img'));
|
||||
$.on(img, (isVideo ? 'loadeddata' : 'load'), (function(_this) {
|
||||
return function() {
|
||||
var cv, height, s, width;
|
||||
s = 90 * 2 * window.devicePixelRatio;
|
||||
if (_this.file.type === 'image/gif') {
|
||||
s *= 3;
|
||||
}
|
||||
if (isVideo) {
|
||||
height = img.videoHeight;
|
||||
width = img.videoWidth;
|
||||
} else {
|
||||
height = img.height, width = img.width;
|
||||
if (height < s || width < s) {
|
||||
_this.URL = fileURL;
|
||||
_this.nodes.el.style.backgroundImage = "url(" + _this.URL + ")";
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (height <= width) {
|
||||
width = s / height * width;
|
||||
height = s;
|
||||
} else {
|
||||
height = s / width * height;
|
||||
width = s;
|
||||
}
|
||||
cv = $.el('canvas');
|
||||
cv.height = img.height = height;
|
||||
cv.width = img.width = width;
|
||||
cv.getContext('2d').drawImage(img, 0, 0, width, height);
|
||||
URL.revokeObjectURL(fileURL);
|
||||
return cv.toBlob(function(blob) {
|
||||
_this.URL = URL.createObjectURL(blob);
|
||||
return _this.nodes.el.style.backgroundImage = "url(" + _this.URL + ")";
|
||||
});
|
||||
_Class.prototype.setThumbnail = function(el) {
|
||||
var cv, height, isVideo, s, width;
|
||||
isVideo = el.tagName === 'VIDEO';
|
||||
s = 90 * 2 * window.devicePixelRatio;
|
||||
if (this.file.type === 'image/gif') {
|
||||
s *= 3;
|
||||
}
|
||||
if (isVideo) {
|
||||
height = el.videoHeight;
|
||||
width = el.videoWidth;
|
||||
} else {
|
||||
height = el.height, width = el.width;
|
||||
if (height < s || width < s) {
|
||||
this.URL = el.src;
|
||||
this.nodes.el.style.backgroundImage = "url(" + this.URL + ")";
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (height <= width) {
|
||||
width = s / height * width;
|
||||
height = s;
|
||||
} else {
|
||||
height = s / width * height;
|
||||
width = s;
|
||||
}
|
||||
cv = $.el('canvas');
|
||||
cv.height = height;
|
||||
cv.width = width;
|
||||
cv.getContext('2d').drawImage(el, 0, 0, width, height);
|
||||
URL.revokeObjectURL(el.src);
|
||||
return cv.toBlob((function(_this) {
|
||||
return function(blob) {
|
||||
_this.URL = URL.createObjectURL(blob);
|
||||
return _this.nodes.el.style.backgroundImage = "url(" + _this.URL + ")";
|
||||
};
|
||||
})(this));
|
||||
fileURL = URL.createObjectURL(this.file);
|
||||
return img.src = fileURL;
|
||||
};
|
||||
|
||||
_Class.prototype.rmFile = function() {
|
||||
@ -8746,9 +8733,13 @@
|
||||
rel: 'nofollow noreferrer',
|
||||
target: 'blank',
|
||||
className: 'linkify',
|
||||
href: a.dataset.href,
|
||||
innerHTML: a.dataset.title || a.dataset.nodedata
|
||||
href: a.dataset.href
|
||||
});
|
||||
if (a.dataset.title) {
|
||||
el.textContent = a.dataset.title;
|
||||
} else {
|
||||
el.innerHTML = a.dataset.nodedata;
|
||||
}
|
||||
$.addClass(el, a.dataset.key);
|
||||
return el;
|
||||
},
|
||||
@ -8818,9 +8809,18 @@
|
||||
regExp: /(http|www).*\.(gif|png|jpg|jpeg|bmp)$/,
|
||||
style: 'border: 0; width: auto; height: auto;',
|
||||
el: function(a) {
|
||||
return $.el('div', {
|
||||
innerHTML: "<a target=_blank href='" + a.dataset.href + "'><img src='" + a.dataset.href + "'></a>"
|
||||
var div, img, link;
|
||||
img = $.el('img', {
|
||||
src: a.dataset.href
|
||||
});
|
||||
link = $.el('a', {
|
||||
target: '_blank',
|
||||
href: a.dataset.href
|
||||
});
|
||||
div = $.el('div');
|
||||
$.add(link, img);
|
||||
$.add(div, link);
|
||||
return div;
|
||||
}
|
||||
}, {
|
||||
key: 'InstallGentoo',
|
||||
@ -8854,7 +8854,7 @@
|
||||
}
|
||||
}, {
|
||||
key: 'MediaCrush',
|
||||
regExp: /.*(?:mediacru.sh\/)([0-9a-z_]+)/i,
|
||||
regExp: /.*(?:mediacru.sh\/)([0-9a-z_-]+)/i,
|
||||
style: 'border: 0;',
|
||||
el: function(a) {
|
||||
var el;
|
||||
@ -8863,7 +8863,7 @@
|
||||
var embed, file, files, status, type, _i, _j, _len, _len1, _ref;
|
||||
status = this.status;
|
||||
if (status !== 200 && status !== 304) {
|
||||
return div.innerHTML = "ERROR " + status;
|
||||
return el.textContent = "ERROR " + status;
|
||||
}
|
||||
files = this.response.files;
|
||||
_ref = ['video/mp4', 'video/ogv', 'image/svg+xml', 'image/png', 'image/gif', 'image/jpeg', 'image/svg', 'audio/mpeg'];
|
||||
@ -8881,26 +8881,27 @@
|
||||
}
|
||||
}
|
||||
if (!embed) {
|
||||
return div.innerHTML = "ERROR: Not a valid filetype";
|
||||
return div.textContent = "ERROR: Not a valid filetype";
|
||||
}
|
||||
switch (embed.type) {
|
||||
case 'video/mp4':
|
||||
case 'video/ogv':
|
||||
return el.innerHTML = "<video autoplay loop>\n <source src=\"https://mediacru.sh/" + a.dataset.uid + ".mp4\" type=\"video/mp4;\">\n <source src=\"https://mediacru.sh/" + a.dataset.uid + ".ogv\" type=\"video/ogg; codecs='theora, vorbis'\">\n</video>";
|
||||
case 'image/png':
|
||||
case 'image/gif':
|
||||
case 'image/jpeg':
|
||||
case 'image/svg':
|
||||
case 'image/svg+xml':
|
||||
return $.add(el, $.el('a', {
|
||||
target: '_blank',
|
||||
href: a.dataset.href,
|
||||
innerHTML: "<img src='https://mediacru.sh/" + file.file + "'>"
|
||||
}));
|
||||
case 'audio/mpeg':
|
||||
return el.innerHTML = "<audio controls><source src='https://mediacru.sh/" + file.file + "'></audio>";
|
||||
default:
|
||||
return el.textContent = "ERROR: No valid filetype.";
|
||||
}
|
||||
return el.innerHTML = (function() {
|
||||
switch (embed.type) {
|
||||
case 'video/mp4':
|
||||
case 'video/ogv':
|
||||
return "<video autoplay loop>\n <source src=\"https://mediacru.sh/" + a.dataset.uid + ".mp4\" type=\"video/mp4;\">\n <source src=\"https://mediacru.sh/" + a.dataset.uid + ".ogv\" type=\"video/ogg; codecs='theora, vorbis'\">\n</video>";
|
||||
case 'image/png':
|
||||
case 'image/gif':
|
||||
case 'image/jpeg':
|
||||
return "<a target=_blank href='" + a.dataset.href + "'><img src='https://mediacru.sh/" + file.file + "'></a>";
|
||||
case 'image/svg':
|
||||
case 'image/svg+xml':
|
||||
return "<embed src='https://mediacru.sh/" + file.file + "' type='image/svg+xml' />";
|
||||
case 'audio/mpeg':
|
||||
return "<audio controls><source src='https://mediacru.sh/" + file.file + "'></audio>";
|
||||
default:
|
||||
return "ERROR: No valid filetype.";
|
||||
}
|
||||
})();
|
||||
});
|
||||
return el;
|
||||
}
|
||||
|
||||
BIN
builds/crx.crx
BIN
builds/crx.crx
Binary file not shown.
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "4chan X",
|
||||
"version": "1.7.30",
|
||||
"version": "1.7.31",
|
||||
"manifest_version": 2,
|
||||
"description": "Cross-browser userscript for maximum lurking on 4chan.",
|
||||
"icons": {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
// Generated by CoffeeScript
|
||||
/*
|
||||
* 4chan X - Version 1.7.30 - 2014-05-05
|
||||
* 4chan X - Version 1.7.31 - 2014-05-08
|
||||
*
|
||||
* Licensed under the MIT license.
|
||||
* https://github.com/ccd0/4chan-x/blob/master/LICENSE
|
||||
@ -348,7 +348,7 @@
|
||||
doc = d.documentElement;
|
||||
|
||||
g = {
|
||||
VERSION: '1.7.30',
|
||||
VERSION: '1.7.31',
|
||||
NAMESPACE: '4chan X.',
|
||||
boards: {}
|
||||
};
|
||||
@ -3136,7 +3136,7 @@
|
||||
o.file = {
|
||||
name: data.filename + data.ext,
|
||||
timestamp: "" + data.tim + data.ext,
|
||||
url: boardID === 'f' ? "//i.4cdn.org/" + boardID + "/" + data.filename + data.ext : "//i.4cdn.org/" + boardID + "/" + data.tim + data.ext,
|
||||
url: boardID === 'f' ? ("//i.4cdn.org/" + boardID + "/" + data.filename + data.ext).replace(/'/g, ''') : "//i.4cdn.org/" + boardID + "/" + data.tim + data.ext,
|
||||
height: data.h,
|
||||
width: data.w,
|
||||
MD5: data.md5,
|
||||
@ -5716,7 +5716,7 @@
|
||||
return $.addClass(doc, 'hide-original-post-form');
|
||||
});
|
||||
}
|
||||
$.ready(this.initReady);
|
||||
$.on(d, '4chanXInitFinished', this.initReady);
|
||||
if (Conf['Persistent QR']) {
|
||||
if (!(g.BOARD.ID === 'f' && g.VIEW === 'index')) {
|
||||
$.on(d, '4chanXInitFinished', this.persist);
|
||||
@ -5731,6 +5731,7 @@
|
||||
},
|
||||
initReady: function() {
|
||||
var link;
|
||||
$.off(d, '4chanXInitFinished', this.initReady);
|
||||
QR.postingIsEnabled = !!$.id('postForm');
|
||||
if (!QR.postingIsEnabled) {
|
||||
return;
|
||||
@ -6091,9 +6092,10 @@
|
||||
}
|
||||
},
|
||||
handleFile: function(file, index, nfiles) {
|
||||
var isNewPost, max, post, _ref;
|
||||
var isNewPost, isSingle, max, post, _ref;
|
||||
isSingle = nfiles === 1;
|
||||
if (/^text\//.test(file.type)) {
|
||||
if (nfiles === 1) {
|
||||
if (isSingle) {
|
||||
post = QR.selected;
|
||||
} else if (index !== 0 || (post = QR.posts[QR.posts.length - 1]).com) {
|
||||
post = new QR.post();
|
||||
@ -6103,7 +6105,7 @@
|
||||
}
|
||||
if (_ref = file.type, __indexOf.call(QR.mimeTypes, _ref) < 0) {
|
||||
QR.error("" + file.name + ": Unsupported file type.");
|
||||
if (nfiles !== 1) {
|
||||
if (!isSingle) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -6113,22 +6115,25 @@
|
||||
}
|
||||
if (file.size > max) {
|
||||
QR.error("" + file.name + ": File too large (file: " + ($.bytesToString(file.size)) + ", max: " + ($.bytesToString(max)) + ").");
|
||||
if (nfiles !== 1) {
|
||||
if (!isSingle) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
isNewPost = false;
|
||||
if (nfiles === 1) {
|
||||
if (isSingle) {
|
||||
post = QR.selected;
|
||||
} else if (index !== 0 || (post = QR.posts[QR.posts.length - 1]).file) {
|
||||
isNewPost = true;
|
||||
post = new QR.post();
|
||||
}
|
||||
return QR.checkDimensions(file, function(pass) {
|
||||
if (pass || nfiles === 1) {
|
||||
return post.setFile(file);
|
||||
return QR.checkDimensions(file, function(pass, el) {
|
||||
if (pass || isSingle) {
|
||||
return post.setFile(file, el);
|
||||
} else if (isNewPost) {
|
||||
return post.rm();
|
||||
post.rm();
|
||||
if (el) {
|
||||
return URL.revokeObjectURL(el.src);
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
@ -6136,71 +6141,65 @@
|
||||
var img, video;
|
||||
if (/^image\//.test(file.type)) {
|
||||
img = new Image();
|
||||
img.onload = (function(_this) {
|
||||
return function() {
|
||||
var height, pass, width;
|
||||
height = img.height, width = img.width;
|
||||
pass = true;
|
||||
if (height > QR.max_height || width > QR.max_width) {
|
||||
QR.error("" + file.name + ": Image too large (image: " + height + "x" + width + "px, max: " + QR.max_height + "x" + QR.max_width + "px)");
|
||||
pass = false;
|
||||
}
|
||||
if (height < QR.min_height || width < QR.min_width) {
|
||||
QR.error("" + file.name + ": Image too small (image: " + height + "x" + width + "px, min: " + QR.min_height + "x" + QR.min_width + "px)");
|
||||
pass = false;
|
||||
}
|
||||
return cb(pass);
|
||||
};
|
||||
})(this);
|
||||
img.onload = function() {
|
||||
var height, pass, width;
|
||||
height = img.height, width = img.width;
|
||||
pass = true;
|
||||
if (height > QR.max_height || width > QR.max_width) {
|
||||
QR.error("" + file.name + ": Image too large (image: " + height + "x" + width + "px, max: " + QR.max_height + "x" + QR.max_width + "px)");
|
||||
pass = false;
|
||||
}
|
||||
if (height < QR.min_height || width < QR.min_width) {
|
||||
QR.error("" + file.name + ": Image too small (image: " + height + "x" + width + "px, min: " + QR.min_height + "x" + QR.min_width + "px)");
|
||||
pass = false;
|
||||
}
|
||||
return cb(pass, img);
|
||||
};
|
||||
return img.src = URL.createObjectURL(file);
|
||||
} else if (/^video\//.test(file.type)) {
|
||||
video = $.el('video');
|
||||
$.on(video, 'loadedmetadata', (function(_this) {
|
||||
return function() {
|
||||
var duration, max_height, max_width, pass, videoHeight, videoWidth;
|
||||
if (cb == null) {
|
||||
return;
|
||||
}
|
||||
videoHeight = video.videoHeight, videoWidth = video.videoWidth, duration = video.duration;
|
||||
max_height = Math.min(QR.max_height, QR.max_height_video);
|
||||
max_width = Math.min(QR.max_width, QR.max_width_video);
|
||||
pass = true;
|
||||
if (videoHeight > max_height || videoWidth > max_width) {
|
||||
QR.error("" + file.name + ": Video too large (video: " + videoHeight + "x" + videoWidth + "px, max: " + max_height + "x" + max_width + "px)");
|
||||
pass = false;
|
||||
}
|
||||
if (videoHeight < QR.min_height || videoWidth < QR.min_width) {
|
||||
QR.error("" + file.name + ": Video too small (video: " + videoHeight + "x" + videoWidth + "px, min: " + QR.min_height + "x" + QR.min_width + "px)");
|
||||
pass = false;
|
||||
}
|
||||
if (!isFinite(video.duration)) {
|
||||
QR.error("" + file.name + ": Video lacks duration metadata (try remuxing)");
|
||||
pass = false;
|
||||
}
|
||||
if (duration > QR.max_duration_video) {
|
||||
QR.error("" + file.name + ": Video too long (video: " + duration + "s, max: " + QR.max_duration_video + "s)");
|
||||
pass = false;
|
||||
}
|
||||
cb(pass);
|
||||
return cb = null;
|
||||
};
|
||||
})(this));
|
||||
$.on(video, 'error', (function(_this) {
|
||||
return function() {
|
||||
var _ref;
|
||||
if (cb == null) {
|
||||
return;
|
||||
}
|
||||
if (_ref = file.type, __indexOf.call(QR.mimeTypes, _ref) >= 0) {
|
||||
QR.error("" + file.name + ": Video appears corrupt");
|
||||
}
|
||||
cb(false);
|
||||
return cb = null;
|
||||
};
|
||||
})(this));
|
||||
$.on(video, 'loadedmetadata', function() {
|
||||
var duration, max_height, max_width, pass, videoHeight, videoWidth;
|
||||
if (!cb) {
|
||||
return;
|
||||
}
|
||||
videoHeight = video.videoHeight, videoWidth = video.videoWidth, duration = video.duration;
|
||||
max_height = Math.min(QR.max_height, QR.max_height_video);
|
||||
max_width = Math.min(QR.max_width, QR.max_width_video);
|
||||
pass = true;
|
||||
if (videoHeight > max_height || videoWidth > max_width) {
|
||||
QR.error("" + file.name + ": Video too large (video: " + videoHeight + "x" + videoWidth + "px, max: " + max_height + "x" + max_width + "px)");
|
||||
pass = false;
|
||||
}
|
||||
if (videoHeight < QR.min_height || videoWidth < QR.min_width) {
|
||||
QR.error("" + file.name + ": Video too small (video: " + videoHeight + "x" + videoWidth + "px, min: " + QR.min_height + "x" + QR.min_width + "px)");
|
||||
pass = false;
|
||||
}
|
||||
if (!isFinite(duration)) {
|
||||
QR.error("" + file.name + ": Video lacks duration metadata (try remuxing)");
|
||||
pass = false;
|
||||
} else if (duration > QR.max_duration_video) {
|
||||
QR.error("" + file.name + ": Video too long (video: " + duration + "s, max: " + QR.max_duration_video + "s)");
|
||||
pass = false;
|
||||
}
|
||||
cb(pass, video);
|
||||
return cb = null;
|
||||
});
|
||||
$.on(video, 'error', function() {
|
||||
var _ref;
|
||||
if (!cb) {
|
||||
return;
|
||||
}
|
||||
if (_ref = file.type, __indexOf.call(QR.mimeTypes, _ref) >= 0) {
|
||||
QR.error("" + file.name + ": Video appears corrupt");
|
||||
}
|
||||
URL.revokeObjectURL(file);
|
||||
cb(false, null);
|
||||
return cb = null;
|
||||
});
|
||||
return video.src = URL.createObjectURL(file);
|
||||
} else {
|
||||
return cb(true);
|
||||
return cb(true, null);
|
||||
}
|
||||
},
|
||||
openFileInput: function(e) {
|
||||
@ -6247,49 +6246,46 @@
|
||||
return list.value = g.VIEW === 'thread' ? g.THREADID : 'new';
|
||||
},
|
||||
dialog: function() {
|
||||
var dialog, elm, event, i, items, key, name, node, nodes, prop, rules, save, value, _, _i, _len, _ref, _ref1, _ref2, _ref3;
|
||||
var dialog, elm, event, i, items, name, node, nodes, prop, rules, save, setNode, _, _i, _len, _ref, _ref1, _ref2;
|
||||
QR.nodes = nodes = {
|
||||
el: dialog = UI.dialog('qr', 'top:0;right:0;', "<div class=move><label><input type=checkbox id=autohide title=Auto-hide>Quick Reply</label><a href=javascript:; class=close title=Close>×</a><select data-name=thread title='Create a new thread / Reply'><option value=new>New thread</option></select></div><form><div class=persona><input name=name data-name=name list=\"list-name\" placeholder=Name class=field size=1 tabindex=10><input name=email data-name=email list=\"list-email\" placeholder=E-mail class=field size=1 tabindex=20><input name=sub data-name=sub list=\"list-sub\" placeholder=Subject class=field size=1 tabindex=30> </div><div class=textarea><textarea data-name=com placeholder=Comment class=field tabindex=40></textarea><span id=char-count></span></div><div id=dump-list-container><div id=dump-list></div><a id=add-post href=javascript:; title=\"Add a post\" tabindex=50>+</a></div><div id=file-n-submit><span id=qr-filename-container class=field tabindex=60><span id=qr-no-file>No selected file</span><input id=\"qr-filename\" data-name=\"filename\" spellcheck=\"false\"><span id=qr-extras-container><a id=qr-filerm href=javascript:; title='Remove file'><i class=\"fa fa-times-circle\"></i></a><a id=url-button title='Post from url'><i class=\"fa fa-link\"></i></a><a id=dump-button title='Dump list'><i class=\"fa fa-plus-square\"></i></a></span></span><label id=qr-spoiler-label><input type=checkbox id=qr-file-spoiler title='Spoiler image' tabindex=70></label><input type=submit tabindex=80></div><input type=file multiple></form><datalist id=\"list-name\"></datalist><datalist id=\"list-email\"></datalist><datalist id=\"list-sub\"></datalist> ")
|
||||
};
|
||||
_ref = {
|
||||
move: '.move',
|
||||
autohide: '#autohide',
|
||||
thread: 'select',
|
||||
threadPar: '#qr-thread-select',
|
||||
close: '.close',
|
||||
form: 'form',
|
||||
dumpButton: '#dump-button',
|
||||
urlButton: '#url-button',
|
||||
name: '[data-name=name]',
|
||||
email: '[data-name=email]',
|
||||
sub: '[data-name=sub]',
|
||||
com: '[data-name=com]',
|
||||
dumpList: '#dump-list',
|
||||
addPost: '#add-post',
|
||||
charCount: '#char-count',
|
||||
fileSubmit: '#file-n-submit',
|
||||
filename: '#qr-filename',
|
||||
fileContainer: '#qr-filename-container',
|
||||
fileRM: '#qr-filerm',
|
||||
fileExtras: '#qr-extras-container',
|
||||
spoiler: '#qr-file-spoiler',
|
||||
spoilerPar: '#qr-spoiler-label',
|
||||
status: '[type=submit]',
|
||||
fileInput: '[type=file]'
|
||||
setNode = function(name, query) {
|
||||
return nodes[name] = $(query, dialog);
|
||||
};
|
||||
for (key in _ref) {
|
||||
value = _ref[key];
|
||||
nodes[key] = $(value, dialog);
|
||||
}
|
||||
setNode('move', '.move');
|
||||
setNode('autohide', '#autohide');
|
||||
setNode('thread', 'select');
|
||||
setNode('threadPar', '#qr-thread-select');
|
||||
setNode('close', '.close');
|
||||
setNode('form', 'form');
|
||||
setNode('dumpButton', '#dump-button');
|
||||
setNode('urlButton', '#url-button');
|
||||
setNode('name', '[data-name=name]');
|
||||
setNode('email', '[data-name=email]');
|
||||
setNode('sub', '[data-name=sub]');
|
||||
setNode('com', '[data-name=com]');
|
||||
setNode('dumpList', '#dump-list');
|
||||
setNode('addPost', '#add-post');
|
||||
setNode('charCount', '#char-count');
|
||||
setNode('fileSubmit', '#file-n-submit');
|
||||
setNode('filename', '#qr-filename');
|
||||
setNode('fileContainer', '#qr-filename-container');
|
||||
setNode('fileRM', '#qr-filerm');
|
||||
setNode('fileExtras', '#qr-extras-container');
|
||||
setNode('spoiler', '#qr-file-spoiler');
|
||||
setNode('spoilerPar', '#qr-spoiler-label');
|
||||
setNode('status', '[type=submit]');
|
||||
setNode('fileInput', '[type=file]');
|
||||
rules = $('ul.rules').textContent.trim();
|
||||
QR.min_width = QR.min_height = 1;
|
||||
QR.max_width = QR.max_height = 10000;
|
||||
try {
|
||||
_ref1 = rules.match(/.+smaller than (\d+)x(\d+).+/), _ = _ref1[0], QR.min_width = _ref1[1], QR.min_height = _ref1[2];
|
||||
_ref2 = rules.match(/.+greater than (\d+)x(\d+).+/), _ = _ref2[0], QR.max_width = _ref2[1], QR.max_height = _ref2[2];
|
||||
_ref3 = ['min_width', 'min_height', 'max_width', 'max_height'];
|
||||
for (_i = 0, _len = _ref3.length; _i < _len; _i++) {
|
||||
prop = _ref3[_i];
|
||||
_ref = rules.match(/.+smaller than (\d+)x(\d+).+/), _ = _ref[0], QR.min_width = _ref[1], QR.min_height = _ref[2];
|
||||
_ref1 = rules.match(/.+greater than (\d+)x(\d+).+/), _ = _ref1[0], QR.max_width = _ref1[1], QR.max_height = _ref1[2];
|
||||
_ref2 = ['min_width', 'min_height', 'max_width', 'max_height'];
|
||||
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
|
||||
prop = _ref2[_i];
|
||||
QR[prop] = parseInt(QR[prop], 10);
|
||||
}
|
||||
} catch (_error) {
|
||||
@ -6364,20 +6360,20 @@
|
||||
},
|
||||
flags: function() {
|
||||
var flag, fn, select, _i, _len, _ref;
|
||||
fn = function(val) {
|
||||
return $.el('option', {
|
||||
value: val[0],
|
||||
textContent: val[1]
|
||||
});
|
||||
};
|
||||
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];
|
||||
$.add(select, fn(flag));
|
||||
fn(flag);
|
||||
}
|
||||
return select;
|
||||
},
|
||||
@ -6484,14 +6480,11 @@
|
||||
responseType: 'document',
|
||||
withCredentials: true,
|
||||
onload: QR.response,
|
||||
onerror: function(err, url, line) {
|
||||
onerror: function() {
|
||||
delete QR.req;
|
||||
post.unlock();
|
||||
QR.cooldown.auto = false;
|
||||
QR.status();
|
||||
console.log(err);
|
||||
console.log(url);
|
||||
console.log(line);
|
||||
return QR.error($.el('span', {
|
||||
innerHTML: "4chan X encountered an error while posting. \n[<a href=\"//4chan.org/banned\" target=_blank>Banned?</a>] [<a href=\"https://github.com/ccd0/4chan-x/wiki/Frequently-Asked-Questions#what-does-4chan-x-encountered-an-error-while-posting-please-try-again-mean\" target=_blank>More info</a>]"
|
||||
}));
|
||||
@ -7269,7 +7262,7 @@
|
||||
}
|
||||
};
|
||||
|
||||
_Class.prototype.setFile = function(file) {
|
||||
_Class.prototype.setFile = function(file, el) {
|
||||
this.file = file;
|
||||
this.filename = file.name;
|
||||
this.filesize = $.bytesToString(file.size);
|
||||
@ -7280,55 +7273,49 @@
|
||||
if (this === QR.selected) {
|
||||
this.showFileData();
|
||||
}
|
||||
if (!/^(image|video)\//.test(file.type)) {
|
||||
this.nodes.el.style.backgroundImage = null;
|
||||
return;
|
||||
if (el) {
|
||||
return this.setThumbnail(el);
|
||||
} else {
|
||||
return this.nodes.el.style.backgroundImage = null;
|
||||
}
|
||||
return this.setThumbnail();
|
||||
};
|
||||
|
||||
_Class.prototype.setThumbnail = function() {
|
||||
var fileURL, img, isVideo;
|
||||
isVideo = /^video\//.test(this.file.type);
|
||||
img = $.el((isVideo ? 'video' : 'img'));
|
||||
$.on(img, (isVideo ? 'loadeddata' : 'load'), (function(_this) {
|
||||
return function() {
|
||||
var cv, height, s, width;
|
||||
s = 90 * 2 * window.devicePixelRatio;
|
||||
if (_this.file.type === 'image/gif') {
|
||||
s *= 3;
|
||||
}
|
||||
if (isVideo) {
|
||||
height = img.videoHeight;
|
||||
width = img.videoWidth;
|
||||
} else {
|
||||
height = img.height, width = img.width;
|
||||
if (height < s || width < s) {
|
||||
_this.URL = fileURL;
|
||||
_this.nodes.el.style.backgroundImage = "url(" + _this.URL + ")";
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (height <= width) {
|
||||
width = s / height * width;
|
||||
height = s;
|
||||
} else {
|
||||
height = s / width * height;
|
||||
width = s;
|
||||
}
|
||||
cv = $.el('canvas');
|
||||
cv.height = img.height = height;
|
||||
cv.width = img.width = width;
|
||||
cv.getContext('2d').drawImage(img, 0, 0, width, height);
|
||||
URL.revokeObjectURL(fileURL);
|
||||
return cv.toBlob(function(blob) {
|
||||
_this.URL = URL.createObjectURL(blob);
|
||||
return _this.nodes.el.style.backgroundImage = "url(" + _this.URL + ")";
|
||||
});
|
||||
_Class.prototype.setThumbnail = function(el) {
|
||||
var cv, height, isVideo, s, width;
|
||||
isVideo = el.tagName === 'VIDEO';
|
||||
s = 90 * 2 * window.devicePixelRatio;
|
||||
if (this.file.type === 'image/gif') {
|
||||
s *= 3;
|
||||
}
|
||||
if (isVideo) {
|
||||
height = el.videoHeight;
|
||||
width = el.videoWidth;
|
||||
} else {
|
||||
height = el.height, width = el.width;
|
||||
if (height < s || width < s) {
|
||||
this.URL = el.src;
|
||||
this.nodes.el.style.backgroundImage = "url(" + this.URL + ")";
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (height <= width) {
|
||||
width = s / height * width;
|
||||
height = s;
|
||||
} else {
|
||||
height = s / width * height;
|
||||
width = s;
|
||||
}
|
||||
cv = $.el('canvas');
|
||||
cv.height = height;
|
||||
cv.width = width;
|
||||
cv.getContext('2d').drawImage(el, 0, 0, width, height);
|
||||
URL.revokeObjectURL(el.src);
|
||||
return cv.toBlob((function(_this) {
|
||||
return function(blob) {
|
||||
_this.URL = URL.createObjectURL(blob);
|
||||
return _this.nodes.el.style.backgroundImage = "url(" + _this.URL + ")";
|
||||
};
|
||||
})(this));
|
||||
fileURL = URL.createObjectURL(this.file);
|
||||
return img.src = fileURL;
|
||||
};
|
||||
|
||||
_Class.prototype.rmFile = function() {
|
||||
@ -8743,9 +8730,13 @@
|
||||
rel: 'nofollow noreferrer',
|
||||
target: 'blank',
|
||||
className: 'linkify',
|
||||
href: a.dataset.href,
|
||||
innerHTML: a.dataset.title || a.dataset.nodedata
|
||||
href: a.dataset.href
|
||||
});
|
||||
if (a.dataset.title) {
|
||||
el.textContent = a.dataset.title;
|
||||
} else {
|
||||
el.innerHTML = a.dataset.nodedata;
|
||||
}
|
||||
$.addClass(el, a.dataset.key);
|
||||
return el;
|
||||
},
|
||||
@ -8815,9 +8806,18 @@
|
||||
regExp: /(http|www).*\.(gif|png|jpg|jpeg|bmp)$/,
|
||||
style: 'border: 0; width: auto; height: auto;',
|
||||
el: function(a) {
|
||||
return $.el('div', {
|
||||
innerHTML: "<a target=_blank href='" + a.dataset.href + "'><img src='" + a.dataset.href + "'></a>"
|
||||
var div, img, link;
|
||||
img = $.el('img', {
|
||||
src: a.dataset.href
|
||||
});
|
||||
link = $.el('a', {
|
||||
target: '_blank',
|
||||
href: a.dataset.href
|
||||
});
|
||||
div = $.el('div');
|
||||
$.add(link, img);
|
||||
$.add(div, link);
|
||||
return div;
|
||||
}
|
||||
}, {
|
||||
key: 'InstallGentoo',
|
||||
@ -8851,7 +8851,7 @@
|
||||
}
|
||||
}, {
|
||||
key: 'MediaCrush',
|
||||
regExp: /.*(?:mediacru.sh\/)([0-9a-z_]+)/i,
|
||||
regExp: /.*(?:mediacru.sh\/)([0-9a-z_-]+)/i,
|
||||
style: 'border: 0;',
|
||||
el: function(a) {
|
||||
var el;
|
||||
@ -8860,7 +8860,7 @@
|
||||
var embed, file, files, status, type, _i, _j, _len, _len1, _ref;
|
||||
status = this.status;
|
||||
if (status !== 200 && status !== 304) {
|
||||
return div.innerHTML = "ERROR " + status;
|
||||
return el.textContent = "ERROR " + status;
|
||||
}
|
||||
files = this.response.files;
|
||||
_ref = ['video/mp4', 'video/ogv', 'image/svg+xml', 'image/png', 'image/gif', 'image/jpeg', 'image/svg', 'audio/mpeg'];
|
||||
@ -8878,26 +8878,27 @@
|
||||
}
|
||||
}
|
||||
if (!embed) {
|
||||
return div.innerHTML = "ERROR: Not a valid filetype";
|
||||
return div.textContent = "ERROR: Not a valid filetype";
|
||||
}
|
||||
switch (embed.type) {
|
||||
case 'video/mp4':
|
||||
case 'video/ogv':
|
||||
return el.innerHTML = "<video autoplay loop>\n <source src=\"https://mediacru.sh/" + a.dataset.uid + ".mp4\" type=\"video/mp4;\">\n <source src=\"https://mediacru.sh/" + a.dataset.uid + ".ogv\" type=\"video/ogg; codecs='theora, vorbis'\">\n</video>";
|
||||
case 'image/png':
|
||||
case 'image/gif':
|
||||
case 'image/jpeg':
|
||||
case 'image/svg':
|
||||
case 'image/svg+xml':
|
||||
return $.add(el, $.el('a', {
|
||||
target: '_blank',
|
||||
href: a.dataset.href,
|
||||
innerHTML: "<img src='https://mediacru.sh/" + file.file + "'>"
|
||||
}));
|
||||
case 'audio/mpeg':
|
||||
return el.innerHTML = "<audio controls><source src='https://mediacru.sh/" + file.file + "'></audio>";
|
||||
default:
|
||||
return el.textContent = "ERROR: No valid filetype.";
|
||||
}
|
||||
return el.innerHTML = (function() {
|
||||
switch (embed.type) {
|
||||
case 'video/mp4':
|
||||
case 'video/ogv':
|
||||
return "<video autoplay loop>\n <source src=\"https://mediacru.sh/" + a.dataset.uid + ".mp4\" type=\"video/mp4;\">\n <source src=\"https://mediacru.sh/" + a.dataset.uid + ".ogv\" type=\"video/ogg; codecs='theora, vorbis'\">\n</video>";
|
||||
case 'image/png':
|
||||
case 'image/gif':
|
||||
case 'image/jpeg':
|
||||
return "<a target=_blank href='" + a.dataset.href + "'><img src='https://mediacru.sh/" + file.file + "'></a>";
|
||||
case 'image/svg':
|
||||
case 'image/svg+xml':
|
||||
return "<embed src='https://mediacru.sh/" + file.file + "' type='image/svg+xml' />";
|
||||
case 'audio/mpeg':
|
||||
return "<audio controls><source src='https://mediacru.sh/" + file.file + "'></audio>";
|
||||
default:
|
||||
return "ERROR: No valid filetype.";
|
||||
}
|
||||
})();
|
||||
});
|
||||
return el;
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<gupdate xmlns='http://www.google.com/update2/response' protocol='2.0'>
|
||||
<app appid='lacclbnghgdicfifcamcmcnilckjamag'>
|
||||
<updatecheck codebase='https://ccd0.github.io/4chan-x/builds/crx.crx' version='1.7.30' />
|
||||
<updatecheck codebase='https://ccd0.github.io/4chan-x/builds/crx.crx' version='1.7.31' />
|
||||
</app>
|
||||
</gupdate>
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "4chan-X",
|
||||
"version": "1.7.30",
|
||||
"version": "1.7.31",
|
||||
"description": "Cross-browser userscript for maximum lurking on 4chan.",
|
||||
"meta": {
|
||||
"name": "4chan X",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user