Merge branch 'v3'
Conflicts: LICENSE builds/crx/script.js src/General/Main.coffee src/Posting/QuickReply.coffee
This commit is contained in:
commit
1a4871a01e
2
LICENSE
2
LICENSE
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* appchan x - Version 2.2.2 - 2013-08-07
|
* appchan x - Version 2.2.2 - 2013-08-08
|
||||||
*
|
*
|
||||||
* Licensed under the MIT license.
|
* Licensed under the MIT license.
|
||||||
* https://github.com/zixaphir/appchan-x/blob/master/LICENSE
|
* https://github.com/zixaphir/appchan-x/blob/master/LICENSE
|
||||||
|
|||||||
@ -19,7 +19,7 @@
|
|||||||
// @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAgMAAAAqbBEUAAAACVBMVEUAAGcAAABmzDNZt9VtAAAAAXRSTlMAQObYZgAAAHFJREFUKFOt0LENACEIBdBv4Qju4wgWanEj3D6OcIVMKaitYHEU/jwTCQj8W75kiVCSBvdQ5/AvfVHBin11BgdRq3ysBgfwBDRrj3MCIA+oAQaku/Q1cNctrAmyDl577tOThYt/Y1RBM4DgOHzM0HFTAyLukH/cmRnqAAAAAElFTkSuQmCC
|
// @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAgMAAAAqbBEUAAAACVBMVEUAAGcAAABmzDNZt9VtAAAAAXRSTlMAQObYZgAAAHFJREFUKFOt0LENACEIBdBv4Qju4wgWanEj3D6OcIVMKaitYHEU/jwTCQj8W75kiVCSBvdQ5/AvfVHBin11BgdRq3ysBgfwBDRrj3MCIA+oAQaku/Q1cNctrAmyDl577tOThYt/Y1RBM4DgOHzM0HFTAyLukH/cmRnqAAAAAElFTkSuQmCC
|
||||||
// ==/UserScript==
|
// ==/UserScript==
|
||||||
/*
|
/*
|
||||||
* 4chan X - Version 1.2.25 - 2013-08-07
|
* 4chan X - Version 1.2.25 - 2013-08-08
|
||||||
*
|
*
|
||||||
* Licensed under the MIT license.
|
* Licensed under the MIT license.
|
||||||
* https://github.com/seaweedchan/4chan-x/blob/master/LICENSE
|
* https://github.com/seaweedchan/4chan-x/blob/master/LICENSE
|
||||||
@ -336,15 +336,6 @@
|
|||||||
return this.indexOf(string) > -1;
|
return this.indexOf(string) > -1;
|
||||||
};
|
};
|
||||||
|
|
||||||
Array.prototype.add = function(object, position) {
|
|
||||||
var keep;
|
|
||||||
|
|
||||||
keep = this.slice(position);
|
|
||||||
this.length = position;
|
|
||||||
this.push(object);
|
|
||||||
return this.pushArrays(keep);
|
|
||||||
};
|
|
||||||
|
|
||||||
Array.prototype.contains = function(object) {
|
Array.prototype.contains = function(object) {
|
||||||
return this.indexOf(object) > -1;
|
return this.indexOf(object) > -1;
|
||||||
};
|
};
|
||||||
@ -361,27 +352,6 @@
|
|||||||
return i;
|
return i;
|
||||||
};
|
};
|
||||||
|
|
||||||
Array.prototype.pushArrays = function() {
|
|
||||||
var arg, args, _i, _len;
|
|
||||||
|
|
||||||
args = arguments;
|
|
||||||
for (_i = 0, _len = args.length; _i < _len; _i++) {
|
|
||||||
arg = args[_i];
|
|
||||||
this.push.apply(this, arg);
|
|
||||||
}
|
|
||||||
return this;
|
|
||||||
};
|
|
||||||
|
|
||||||
Array.prototype.remove = function(object) {
|
|
||||||
var index;
|
|
||||||
|
|
||||||
if ((index = this.indexOf(object)) > -1) {
|
|
||||||
return this.splice(index, 1);
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
$ = function(selector, root) {
|
$ = function(selector, root) {
|
||||||
if (root == null) {
|
if (root == null) {
|
||||||
root = d.body;
|
root = d.body;
|
||||||
@ -441,13 +411,22 @@
|
|||||||
return fd;
|
return fd;
|
||||||
};
|
};
|
||||||
|
|
||||||
$.ajax = function(url, callbacks, opts) {
|
$.extend = function(object, properties) {
|
||||||
var cred, err, form, headers, key, r, sync, type, upCallbacks, val;
|
var key, val;
|
||||||
|
|
||||||
if (opts == null) {
|
for (key in properties) {
|
||||||
opts = {};
|
val = properties[key];
|
||||||
|
object[key] = val;
|
||||||
}
|
}
|
||||||
type = opts.type, cred = opts.cred, headers = opts.headers, upCallbacks = opts.upCallbacks, form = opts.form, sync = opts.sync;
|
};
|
||||||
|
|
||||||
|
$.ajax = function(url, options, extra) {
|
||||||
|
var form, headers, key, r, sync, type, upCallbacks, val;
|
||||||
|
|
||||||
|
if (extra == null) {
|
||||||
|
extra = {};
|
||||||
|
}
|
||||||
|
type = extra.type, headers = extra.headers, upCallbacks = extra.upCallbacks, form = extra.form, sync = extra.sync;
|
||||||
r = new XMLHttpRequest();
|
r = new XMLHttpRequest();
|
||||||
r.overrideMimeType('text/html');
|
r.overrideMimeType('text/html');
|
||||||
type || (type = form && 'post' || 'get');
|
type || (type = form && 'post' || 'get');
|
||||||
@ -456,13 +435,8 @@
|
|||||||
val = headers[key];
|
val = headers[key];
|
||||||
r.setRequestHeader(key, val);
|
r.setRequestHeader(key, val);
|
||||||
}
|
}
|
||||||
$.extend(r, callbacks);
|
$.extend(r, options);
|
||||||
$.extend(r.upload, upCallbacks);
|
$.extend(r.upload, upCallbacks);
|
||||||
try {
|
|
||||||
r.withCredentials = cred;
|
|
||||||
} catch (_error) {
|
|
||||||
err = _error;
|
|
||||||
}
|
|
||||||
r.send(form);
|
r.send(form);
|
||||||
return r;
|
return r;
|
||||||
};
|
};
|
||||||
@ -1642,7 +1616,11 @@
|
|||||||
a.dataset.only = m[1];
|
a.dataset.only = m[1];
|
||||||
a.href = "//boards.4chan.org/" + board + "/";
|
a.href = "//boards.4chan.org/" + board + "/";
|
||||||
if (m[1] === 'catalog') {
|
if (m[1] === 'catalog') {
|
||||||
a.href += 'catalog';
|
if (Conf['External Catalog']) {
|
||||||
|
a.href = CatalogLinks.external(board);
|
||||||
|
} else {
|
||||||
|
a.href += 'catalog';
|
||||||
|
}
|
||||||
$.addClass(a, 'catalog');
|
$.addClass(a, 'catalog');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3679,7 +3657,7 @@
|
|||||||
if (Conf['Quote Inlining']) {
|
if (Conf['Quote Inlining']) {
|
||||||
$.on(link, 'click', QuoteInline.toggle);
|
$.on(link, 'click', QuoteInline.toggle);
|
||||||
if (Conf['Quote Hash Navigation']) {
|
if (Conf['Quote Hash Navigation']) {
|
||||||
frag.pushArrays(QuoteInline.qiQuote(link, $.hasClass(link, 'filtered')));
|
frag.push.apply(frag, QuoteInline.qiQuote(link, $.hasClass(link, 'filtered')));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$.add(container, frag);
|
$.add(container, frag);
|
||||||
@ -3755,9 +3733,6 @@
|
|||||||
if (g.VIEW === 'catalog' || !Conf['Quote Inlining']) {
|
if (g.VIEW === 'catalog' || !Conf['Quote Inlining']) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Conf['Comment Expansion']) {
|
|
||||||
ExpandComment.callbacks.push(this.node);
|
|
||||||
}
|
|
||||||
if (Conf['Quote Hash Navigation']) {
|
if (Conf['Quote Hash Navigation']) {
|
||||||
this.node = function() {
|
this.node = function() {
|
||||||
var link, _i, _len, _ref;
|
var link, _i, _len, _ref;
|
||||||
@ -3782,6 +3757,9 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
if (Conf['Comment Expansion']) {
|
||||||
|
ExpandComment.callbacks.push(this.node);
|
||||||
|
}
|
||||||
return Post.prototype.callbacks.push({
|
return Post.prototype.callbacks.push({
|
||||||
name: 'Quote Inlining',
|
name: 'Quote Inlining',
|
||||||
cb: this.node
|
cb: this.node
|
||||||
@ -5968,7 +5946,7 @@
|
|||||||
},
|
},
|
||||||
preSubmitHooks: [],
|
preSubmitHooks: [],
|
||||||
submit: function(e) {
|
submit: function(e) {
|
||||||
var callbacks, challenge, err, filetag, hook, opts, post, postData, response, textOnly, thread, threadID, _i, _len, _ref, _ref1;
|
var challenge, err, extra, filetag, hook, options, post, postData, response, textOnly, thread, threadID, _i, _len, _ref, _ref1;
|
||||||
|
|
||||||
if (e != null) {
|
if (e != null) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
@ -6047,7 +6025,9 @@
|
|||||||
recaptcha_challenge_field: challenge,
|
recaptcha_challenge_field: challenge,
|
||||||
recaptcha_response_field: response
|
recaptcha_response_field: response
|
||||||
};
|
};
|
||||||
callbacks = {
|
options = {
|
||||||
|
responseType: 'document',
|
||||||
|
withCredentials: true,
|
||||||
onload: QR.response,
|
onload: QR.response,
|
||||||
onerror: function() {
|
onerror: function() {
|
||||||
delete QR.req;
|
delete QR.req;
|
||||||
@ -6055,12 +6035,11 @@
|
|||||||
QR.cooldown.auto = false;
|
QR.cooldown.auto = false;
|
||||||
QR.status();
|
QR.status();
|
||||||
return QR.error($.el('span', {
|
return QR.error($.el('span', {
|
||||||
innerHTML: "4chan X encountered an error while posting. Please try again. \n[<a href=\"https://github.com/seaweedchan/4chan-x/wiki/Frequently-Asked-Questions#what-does-4chan-x-encountered-an-error-while-posting-please-try-again-mean\" target=_blank>?</a>]"
|
innerHTML: "4chan X encountered an error while posting. Please try again.\n[<a href=\"https://github.com/seaweedchan/4chan-x/wiki/Frequently-Asked-Questions#what-does-4chan-x-encountered-an-error-while-posting-please-try-again-mean\" target=_blank>?</a>]"
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
opts = {
|
extra = {
|
||||||
cred: true,
|
|
||||||
form: $.formData(postData),
|
form: $.formData(postData),
|
||||||
upCallbacks: {
|
upCallbacks: {
|
||||||
onload: function() {
|
onload: function() {
|
||||||
@ -6075,30 +6054,29 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
QR.req = $.ajax($.id('postForm').parentNode.action, callbacks, opts);
|
QR.req = $.ajax($.id('postForm').parentNode.action, options, extra);
|
||||||
QR.req.uploadStartTime = Date.now();
|
QR.req.uploadStartTime = Date.now();
|
||||||
QR.req.progress = '...';
|
QR.req.progress = '...';
|
||||||
return QR.status();
|
return QR.status();
|
||||||
},
|
},
|
||||||
response: function() {
|
response: function() {
|
||||||
var URL, ban, board, err, h1, isReply, m, post, postID, req, threadID, tmpDoc, _, _ref, _ref1;
|
var URL, ban, board, err, h1, isReply, m, post, postID, req, resDoc, threadID, _, _ref, _ref1;
|
||||||
|
|
||||||
req = QR.req;
|
req = QR.req;
|
||||||
delete QR.req;
|
delete QR.req;
|
||||||
post = QR.posts[0];
|
post = QR.posts[0];
|
||||||
post.unlock();
|
post.unlock();
|
||||||
tmpDoc = d.implementation.createHTMLDocument('');
|
resDoc = req.response;
|
||||||
tmpDoc.documentElement.innerHTML = req.response;
|
if (ban = $('.banType', resDoc)) {
|
||||||
if (ban = $('.banType', tmpDoc)) {
|
board = $('.board', resDoc).innerHTML;
|
||||||
board = $('.board', tmpDoc).innerHTML;
|
|
||||||
err = $.el('span', {
|
err = $.el('span', {
|
||||||
innerHTML: ban.textContent.toLowerCase() === 'banned' ? ("You are banned on " + board + "! ;_;<br>") + "Click <a href=//www.4chan.org/banned target=_blank>here</a> to see the reason." : ("You were issued a warning on " + board + " as " + ($('.nameBlock', tmpDoc).innerHTML) + ".<br>") + ("Reason: " + ($('.reason', tmpDoc).innerHTML))
|
innerHTML: ban.textContent.toLowerCase() === 'banned' ? "You are banned on " + board + "! ;_;<br>\nClick <a href=//www.4chan.org/banned target=_blank>here</a> to see the reason." : "You were issued a warning on " + board + " as " + ($('.nameBlock', resDoc).innerHTML) + ".<br>\nReason: " + ($('.reason', resDoc).innerHTML)
|
||||||
});
|
});
|
||||||
} else if (err = tmpDoc.getElementById('errmsg')) {
|
} else if (err = resDoc.getElementById('errmsg')) {
|
||||||
if ((_ref = $('a', err)) != null) {
|
if ((_ref = $('a', err)) != null) {
|
||||||
_ref.target = '_blank';
|
_ref.target = '_blank';
|
||||||
}
|
}
|
||||||
} else if (tmpDoc.title !== 'Post successful!') {
|
} else if (resDoc.title !== 'Post successful!') {
|
||||||
err = 'Connection error with sys.4chan.org.';
|
err = 'Connection error with sys.4chan.org.';
|
||||||
} else if (req.status !== 200) {
|
} else if (req.status !== 200) {
|
||||||
err = "Error " + req.statusText + " (" + req.status + ")";
|
err = "Error " + req.statusText + " (" + req.status + ")";
|
||||||
@ -6124,8 +6102,8 @@
|
|||||||
QR.error(err);
|
QR.error(err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
h1 = $('h1', resDoc);
|
||||||
QR.cleanNotifications();
|
QR.cleanNotifications();
|
||||||
h1 = $('h1', tmpDoc);
|
|
||||||
if (Conf['Posting Success Notifications']) {
|
if (Conf['Posting Success Notifications']) {
|
||||||
QR.notifications.push(new Notification('success', h1.textContent, 5));
|
QR.notifications.push(new Notification('success', h1.textContent, 5));
|
||||||
}
|
}
|
||||||
@ -6879,6 +6857,8 @@
|
|||||||
form[post.ID] = 'delete';
|
form[post.ID] = 'delete';
|
||||||
link = this;
|
link = this;
|
||||||
return $.ajax($.id('delform').action.replace("/" + g.BOARD + "/", "/" + post.board + "/"), {
|
return $.ajax($.id('delform').action.replace("/" + g.BOARD + "/", "/" + post.board + "/"), {
|
||||||
|
responseType: 'document',
|
||||||
|
withCredentials: true,
|
||||||
onload: function() {
|
onload: function() {
|
||||||
return DeleteLink.load(link, post, fileOnly, this.response);
|
return DeleteLink.load(link, post, fileOnly, this.response);
|
||||||
},
|
},
|
||||||
@ -6886,22 +6866,19 @@
|
|||||||
return DeleteLink.error(link);
|
return DeleteLink.error(link);
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
cred: true,
|
|
||||||
form: $.formData(form)
|
form: $.formData(form)
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
load: function(link, post, fileOnly, html) {
|
load: function(link, post, fileOnly, resDoc) {
|
||||||
var msg, s, tmpDoc;
|
var msg, s;
|
||||||
|
|
||||||
tmpDoc = d.implementation.createHTMLDocument('');
|
if (resDoc.title === '4chan - Banned') {
|
||||||
tmpDoc.documentElement.innerHTML = html;
|
|
||||||
if (tmpDoc.title === '4chan - Banned') {
|
|
||||||
s = 'Banned!';
|
s = 'Banned!';
|
||||||
} else if (msg = tmpDoc.getElementById('errmsg')) {
|
} else if (msg = resDoc.getElementById('errmsg')) {
|
||||||
s = msg.textContent;
|
s = msg.textContent;
|
||||||
$.on(link, 'click', DeleteLink["delete"]);
|
$.on(link, 'click', DeleteLink["delete"]);
|
||||||
} else {
|
} else {
|
||||||
if (tmpDoc.title === 'Updating index...') {
|
if (resDoc.title === 'Updating index...') {
|
||||||
(post.origin || post).kill(fileOnly);
|
(post.origin || post).kill(fileOnly);
|
||||||
}
|
}
|
||||||
s = 'Deleted';
|
s = 'Deleted';
|
||||||
@ -7930,8 +7907,7 @@
|
|||||||
if (Conf['Unread Line']) {
|
if (Conf['Unread Line']) {
|
||||||
Unread.setLine(posts.contains(Unread.posts[0]));
|
Unread.setLine(posts.contains(Unread.posts[0]));
|
||||||
}
|
}
|
||||||
Unread.read();
|
return Unread.read();
|
||||||
return Unread.update();
|
|
||||||
},
|
},
|
||||||
addPostQuotingYou: function(post) {
|
addPostQuotingYou: function(post) {
|
||||||
var quotelink, _i, _len, _ref;
|
var quotelink, _i, _len, _ref;
|
||||||
@ -7981,32 +7957,40 @@
|
|||||||
}
|
}
|
||||||
return arr.splice(0, i);
|
return arr.splice(0, i);
|
||||||
},
|
},
|
||||||
read: $.debounce(50, function(e) {
|
read: $.debounce(50, function() {
|
||||||
var ID, bottom, height, i, post, posts, read;
|
var ID, bottom, height, i, post, posts;
|
||||||
|
|
||||||
if (d.hidden || !Unread.posts.length) {
|
if (d.hidden || !Unread.posts.length) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
height = doc.clientHeight;
|
height = doc.clientHeight;
|
||||||
posts = Unread.posts;
|
posts = Unread.posts;
|
||||||
read = [];
|
i = 0;
|
||||||
i = posts.length;
|
while (post = posts[i]) {
|
||||||
while (post = posts[--i]) {
|
|
||||||
bottom = post.nodes.root.getBoundingClientRect().bottom;
|
bottom = post.nodes.root.getBoundingClientRect().bottom;
|
||||||
if (bottom < height) {
|
if (bottom > height) {
|
||||||
ID = post.ID;
|
i++;
|
||||||
posts.remove(post);
|
continue;
|
||||||
}
|
}
|
||||||
|
ID = post.ID;
|
||||||
|
if (Conf['Quote Threading']) {
|
||||||
|
posts.splice(i, 1);
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
posts.splice(0, i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
if (!ID) {
|
if (!ID) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Unread.lastReadPost = ID;
|
if (Unread.lastReadPost < ID || !Unread.lastReadPost) {
|
||||||
|
Unread.lastReadPost = ID;
|
||||||
|
}
|
||||||
Unread.saveLastReadPost();
|
Unread.saveLastReadPost();
|
||||||
Unread.readArray(Unread.postsQuotingYou);
|
Unread.readArray(Unread.postsQuotingYou);
|
||||||
if (e) {
|
return Unread.update();
|
||||||
return Unread.update();
|
|
||||||
}
|
|
||||||
}),
|
}),
|
||||||
saveLastReadPost: $.debounce(2 * $.SECOND, function() {
|
saveLastReadPost: $.debounce(2 * $.SECOND, function() {
|
||||||
if (Unread.thread.isDead) {
|
if (Unread.thread.isDead) {
|
||||||
@ -8375,20 +8359,19 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
return Post.prototype.callbacks.push({
|
return Post.prototype.callbacks.push({
|
||||||
name: 'Reveal Spoilers',
|
name: 'Color User IDs',
|
||||||
cb: this.node
|
cb: this.node
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
node: function(post) {
|
node: function() {
|
||||||
var str, uid;
|
var str, uid;
|
||||||
|
|
||||||
if (!(uid = $('.hand', this.nodes.uniqueID))) {
|
str = this.info.uniqueID;
|
||||||
|
uid = $('.hand', this.nodes.uniqueID);
|
||||||
|
if (!(str && uid && uid.nodeName === 'SPAN')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
str = this.info.uniqueID;
|
return uid.style.cssText = IDColor.css(IDColor.ids[str] || IDColor.compute(str));
|
||||||
if (uid.nodeName === 'SPAN') {
|
|
||||||
return uid.style.cssText = IDColor.apply.call(str);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
ids: {},
|
ids: {},
|
||||||
compute: function(str) {
|
compute: function(str) {
|
||||||
@ -8400,11 +8383,8 @@
|
|||||||
this.ids[str] = rgb;
|
this.ids[str] = rgb;
|
||||||
return rgb;
|
return rgb;
|
||||||
},
|
},
|
||||||
apply: function() {
|
css: function(rgb) {
|
||||||
var rgb;
|
return "background-color: rgb(" + rgb[0] + "," + rgb[1] + "," + rgb[2] + "); color: " + (rgb[3] ? "black;" : "white;") + " border-radius: 3px; padding: 0px 2px;";
|
||||||
|
|
||||||
rgb = IDColor.ids[this] || IDColor.compute(this);
|
|
||||||
return ("background-color: rgb(" + rgb[0] + "," + rgb[1] + "," + rgb[2] + "); color: ") + (rgb[3] ? "black; border-radius: 3px; padding: 0px 2px;" : "white; border-radius: 3px; padding: 0px 2px;");
|
|
||||||
},
|
},
|
||||||
hash: function(str) {
|
hash: function(str) {
|
||||||
var i, j, msg;
|
var i, j, msg;
|
||||||
@ -10367,7 +10347,7 @@
|
|||||||
'Fourchan thingies': Fourchan,
|
'Fourchan thingies': Fourchan,
|
||||||
'Emoji': Emoji,
|
'Emoji': Emoji,
|
||||||
'Color User IDs': IDColor,
|
'Color User IDs': IDColor,
|
||||||
'Remove Spoilers': RemoveSpoilers,
|
'Reveal Spoilers': RemoveSpoilers,
|
||||||
'Custom CSS': CustomCSS,
|
'Custom CSS': CustomCSS,
|
||||||
'Linkify': Linkify,
|
'Linkify': Linkify,
|
||||||
'Resurrect Quotes': Quotify,
|
'Resurrect Quotes': Quotify,
|
||||||
@ -10399,7 +10379,7 @@
|
|||||||
'Sauce': Sauce,
|
'Sauce': Sauce,
|
||||||
'Image Expansion': ImageExpand,
|
'Image Expansion': ImageExpand,
|
||||||
'Image Expansion (Menu)': ImageExpand.menu,
|
'Image Expansion (Menu)': ImageExpand.menu,
|
||||||
'Reveal Spoilers': RevealSpoilers,
|
'Reveal Spoiler Thumbnails': RevealSpoilers,
|
||||||
'Image Loading': ImageLoader,
|
'Image Loading': ImageLoader,
|
||||||
'Image Hover': ImageHover,
|
'Image Hover': ImageHover,
|
||||||
'Comment Expansion': ExpandComment,
|
'Comment Expansion': ExpandComment,
|
||||||
|
|||||||
@ -18,7 +18,7 @@
|
|||||||
// ==/UserScript==
|
// ==/UserScript==
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* appchan x - Version 2.2.2 - 2013-08-07
|
* appchan x - Version 2.2.2 - 2013-08-08
|
||||||
*
|
*
|
||||||
* Licensed under the MIT license.
|
* Licensed under the MIT license.
|
||||||
* https://github.com/zixaphir/appchan-x/blob/master/LICENSE
|
* https://github.com/zixaphir/appchan-x/blob/master/LICENSE
|
||||||
@ -2693,15 +2693,6 @@
|
|||||||
return this.indexOf(string) > -1;
|
return this.indexOf(string) > -1;
|
||||||
};
|
};
|
||||||
|
|
||||||
Array.prototype.add = function(object, position) {
|
|
||||||
var keep;
|
|
||||||
|
|
||||||
keep = this.slice(position);
|
|
||||||
this.length = position;
|
|
||||||
this.push(object);
|
|
||||||
return this.pushArrays(keep);
|
|
||||||
};
|
|
||||||
|
|
||||||
Array.prototype.contains = function(object) {
|
Array.prototype.contains = function(object) {
|
||||||
return this.indexOf(object) > -1;
|
return this.indexOf(object) > -1;
|
||||||
};
|
};
|
||||||
@ -2718,27 +2709,6 @@
|
|||||||
return i;
|
return i;
|
||||||
};
|
};
|
||||||
|
|
||||||
Array.prototype.pushArrays = function() {
|
|
||||||
var arg, args, _i, _len;
|
|
||||||
|
|
||||||
args = arguments;
|
|
||||||
for (_i = 0, _len = args.length; _i < _len; _i++) {
|
|
||||||
arg = args[_i];
|
|
||||||
this.push.apply(this, arg);
|
|
||||||
}
|
|
||||||
return this;
|
|
||||||
};
|
|
||||||
|
|
||||||
Array.prototype.remove = function(object) {
|
|
||||||
var index;
|
|
||||||
|
|
||||||
if ((index = this.indexOf(object)) > -1) {
|
|
||||||
return this.splice(index, 1);
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
$ = function(selector, root) {
|
$ = function(selector, root) {
|
||||||
if (root == null) {
|
if (root == null) {
|
||||||
root = d.body;
|
root = d.body;
|
||||||
@ -2798,13 +2768,22 @@
|
|||||||
return fd;
|
return fd;
|
||||||
};
|
};
|
||||||
|
|
||||||
$.ajax = function(url, callbacks, opts) {
|
$.extend = function(object, properties) {
|
||||||
var cred, err, form, headers, key, r, sync, type, upCallbacks, val;
|
var key, val;
|
||||||
|
|
||||||
if (opts == null) {
|
for (key in properties) {
|
||||||
opts = {};
|
val = properties[key];
|
||||||
|
object[key] = val;
|
||||||
}
|
}
|
||||||
type = opts.type, cred = opts.cred, headers = opts.headers, upCallbacks = opts.upCallbacks, form = opts.form, sync = opts.sync;
|
};
|
||||||
|
|
||||||
|
$.ajax = function(url, options, extra) {
|
||||||
|
var form, headers, key, r, sync, type, upCallbacks, val;
|
||||||
|
|
||||||
|
if (extra == null) {
|
||||||
|
extra = {};
|
||||||
|
}
|
||||||
|
type = extra.type, headers = extra.headers, upCallbacks = extra.upCallbacks, form = extra.form, sync = extra.sync;
|
||||||
r = new XMLHttpRequest();
|
r = new XMLHttpRequest();
|
||||||
r.overrideMimeType('text/html');
|
r.overrideMimeType('text/html');
|
||||||
type || (type = form && 'post' || 'get');
|
type || (type = form && 'post' || 'get');
|
||||||
@ -2813,13 +2792,8 @@
|
|||||||
val = headers[key];
|
val = headers[key];
|
||||||
r.setRequestHeader(key, val);
|
r.setRequestHeader(key, val);
|
||||||
}
|
}
|
||||||
$.extend(r, callbacks);
|
$.extend(r, options);
|
||||||
$.extend(r.upload, upCallbacks);
|
$.extend(r.upload, upCallbacks);
|
||||||
try {
|
|
||||||
r.withCredentials = cred;
|
|
||||||
} catch (_error) {
|
|
||||||
err = _error;
|
|
||||||
}
|
|
||||||
r.send(form);
|
r.send(form);
|
||||||
return r;
|
return r;
|
||||||
};
|
};
|
||||||
@ -3966,7 +3940,11 @@
|
|||||||
a.dataset.only = m[1];
|
a.dataset.only = m[1];
|
||||||
a.href = "//boards.4chan.org/" + board + "/";
|
a.href = "//boards.4chan.org/" + board + "/";
|
||||||
if (m[1] === 'catalog') {
|
if (m[1] === 'catalog') {
|
||||||
a.href += 'catalog';
|
if (Conf['External Catalog']) {
|
||||||
|
a.href = CatalogLinks.external(board);
|
||||||
|
} else {
|
||||||
|
a.href += 'catalog';
|
||||||
|
}
|
||||||
$.addClass(a, 'catalog');
|
$.addClass(a, 'catalog');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5968,7 +5946,7 @@
|
|||||||
if (Conf['Quote Inlining']) {
|
if (Conf['Quote Inlining']) {
|
||||||
$.on(link, 'click', QuoteInline.toggle);
|
$.on(link, 'click', QuoteInline.toggle);
|
||||||
if (Conf['Quote Hash Navigation']) {
|
if (Conf['Quote Hash Navigation']) {
|
||||||
frag.pushArrays(QuoteInline.qiQuote(link, $.hasClass(link, 'filtered')));
|
frag.push.apply(frag, QuoteInline.qiQuote(link, $.hasClass(link, 'filtered')));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$.add(container, frag);
|
$.add(container, frag);
|
||||||
@ -6047,9 +6025,6 @@
|
|||||||
if (g.VIEW === 'catalog' || !Conf['Quote Inlining']) {
|
if (g.VIEW === 'catalog' || !Conf['Quote Inlining']) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Conf['Comment Expansion']) {
|
|
||||||
ExpandComment.callbacks.push(this.node);
|
|
||||||
}
|
|
||||||
if (Conf['Quote Hash Navigation']) {
|
if (Conf['Quote Hash Navigation']) {
|
||||||
this.node = function() {
|
this.node = function() {
|
||||||
var link, _i, _len, _ref;
|
var link, _i, _len, _ref;
|
||||||
@ -6074,6 +6049,9 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
if (Conf['Comment Expansion']) {
|
||||||
|
ExpandComment.callbacks.push(this.node);
|
||||||
|
}
|
||||||
return Post.prototype.callbacks.push({
|
return Post.prototype.callbacks.push({
|
||||||
name: 'Quote Inlining',
|
name: 'Quote Inlining',
|
||||||
cb: this.node
|
cb: this.node
|
||||||
@ -8274,7 +8252,7 @@
|
|||||||
},
|
},
|
||||||
preSubmitHooks: [],
|
preSubmitHooks: [],
|
||||||
submit: function(e) {
|
submit: function(e) {
|
||||||
var callbacks, challenge, err, filetag, hook, opts, post, postData, response, textOnly, thread, threadID, _i, _len, _ref, _ref1;
|
var challenge, err, extra, filetag, hook, options, post, postData, response, textOnly, thread, threadID, _i, _len, _ref, _ref1;
|
||||||
|
|
||||||
if (e != null) {
|
if (e != null) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
@ -8353,7 +8331,9 @@
|
|||||||
recaptcha_challenge_field: challenge,
|
recaptcha_challenge_field: challenge,
|
||||||
recaptcha_response_field: response
|
recaptcha_response_field: response
|
||||||
};
|
};
|
||||||
callbacks = {
|
options = {
|
||||||
|
responseType: 'document',
|
||||||
|
withCredentials: true,
|
||||||
onload: QR.response,
|
onload: QR.response,
|
||||||
onerror: function() {
|
onerror: function() {
|
||||||
delete QR.req;
|
delete QR.req;
|
||||||
@ -8361,12 +8341,11 @@
|
|||||||
QR.cooldown.auto = false;
|
QR.cooldown.auto = false;
|
||||||
QR.status();
|
QR.status();
|
||||||
return QR.error($.el('span', {
|
return QR.error($.el('span', {
|
||||||
innerHTML: "Connection error. You may have been <a href=//www.4chan.org/banned target=_blank>banned</a>.\n[<a href='https://github.com/seaweedchan/4chan-x/wiki/Frequently-Asked-Questions#what-does-4chan-x-encountered-an-error-while-posting-please-try-again-mean' target=_blank>?</a>]"
|
innerHTML: "Connection error. You may have been <a href=//www.4chan.org/banned target=_blank>banned</a>.\n[<a href=\"https://github.com/seaweedchan/4chan-x/wiki/Frequently-Asked-Questions#what-does-4chan-x-encountered-an-error-while-posting-please-try-again-mean\" target=_blank>?</a>]"
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
opts = {
|
extra = {
|
||||||
cred: true,
|
|
||||||
form: $.formData(postData),
|
form: $.formData(postData),
|
||||||
upCallbacks: {
|
upCallbacks: {
|
||||||
onload: function() {
|
onload: function() {
|
||||||
@ -8381,30 +8360,29 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
QR.req = $.ajax($.id('postForm').parentNode.action, callbacks, opts);
|
QR.req = $.ajax($.id('postForm').parentNode.action, options, extra);
|
||||||
QR.req.uploadStartTime = Date.now();
|
QR.req.uploadStartTime = Date.now();
|
||||||
QR.req.progress = '...';
|
QR.req.progress = '...';
|
||||||
return QR.status();
|
return QR.status();
|
||||||
},
|
},
|
||||||
response: function() {
|
response: function() {
|
||||||
var URL, ban, board, err, h1, isReply, m, post, postID, req, threadID, tmpDoc, _, _ref, _ref1;
|
var URL, ban, board, err, h1, isReply, m, post, postID, req, resDoc, threadID, _, _ref, _ref1;
|
||||||
|
|
||||||
req = QR.req;
|
req = QR.req;
|
||||||
delete QR.req;
|
delete QR.req;
|
||||||
post = QR.posts[0];
|
post = QR.posts[0];
|
||||||
post.unlock();
|
post.unlock();
|
||||||
tmpDoc = d.implementation.createHTMLDocument('');
|
resDoc = req.response;
|
||||||
tmpDoc.documentElement.innerHTML = req.response;
|
if (ban = $('.banType', resDoc)) {
|
||||||
if (ban = $('.banType', tmpDoc)) {
|
board = $('.board', resDoc).innerHTML;
|
||||||
board = $('.board', tmpDoc).innerHTML;
|
|
||||||
err = $.el('span', {
|
err = $.el('span', {
|
||||||
innerHTML: ban.textContent.toLowerCase() === 'banned' ? ("You are banned on " + board + "! ;_;<br>") + "Click <a href=//www.4chan.org/banned target=_blank>here</a> to see the reason." : ("You were issued a warning on " + board + " as " + ($('.nameBlock', tmpDoc).innerHTML) + ".<br>") + ("Reason: " + ($('.reason', tmpDoc).innerHTML))
|
innerHTML: ban.textContent.toLowerCase() === 'banned' ? "You are banned on " + board + "! ;_;<br>\nClick <a href=//www.4chan.org/banned target=_blank>here</a> to see the reason." : "You were issued a warning on " + board + " as " + ($('.nameBlock', resDoc).innerHTML) + ".<br>\nReason: " + ($('.reason', resDoc).innerHTML)
|
||||||
});
|
});
|
||||||
} else if (err = tmpDoc.getElementById('errmsg')) {
|
} else if (err = resDoc.getElementById('errmsg')) {
|
||||||
if ((_ref = $('a', err)) != null) {
|
if ((_ref = $('a', err)) != null) {
|
||||||
_ref.target = '_blank';
|
_ref.target = '_blank';
|
||||||
}
|
}
|
||||||
} else if (tmpDoc.title !== 'Post successful!') {
|
} else if (resDoc.title !== 'Post successful!') {
|
||||||
err = 'Connection error with sys.4chan.org.';
|
err = 'Connection error with sys.4chan.org.';
|
||||||
} else if (req.status !== 200) {
|
} else if (req.status !== 200) {
|
||||||
err = "Error " + req.statusText + " (" + req.status + ")";
|
err = "Error " + req.statusText + " (" + req.status + ")";
|
||||||
@ -8430,8 +8408,8 @@
|
|||||||
QR.error(err);
|
QR.error(err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
h1 = $('h1', resDoc);
|
||||||
QR.cleanNotifications();
|
QR.cleanNotifications();
|
||||||
h1 = $('h1', tmpDoc);
|
|
||||||
if (Conf['Posting Success Notifications']) {
|
if (Conf['Posting Success Notifications']) {
|
||||||
QR.notifications.push(new Notification('success', h1.textContent, 5));
|
QR.notifications.push(new Notification('success', h1.textContent, 5));
|
||||||
}
|
}
|
||||||
@ -9212,6 +9190,8 @@
|
|||||||
form[post.ID] = 'delete';
|
form[post.ID] = 'delete';
|
||||||
link = this;
|
link = this;
|
||||||
return $.ajax($.id('delform').action.replace("/" + g.BOARD + "/", "/" + post.board + "/"), {
|
return $.ajax($.id('delform').action.replace("/" + g.BOARD + "/", "/" + post.board + "/"), {
|
||||||
|
responseType: 'document',
|
||||||
|
withCredentials: true,
|
||||||
onload: function() {
|
onload: function() {
|
||||||
return DeleteLink.load(link, post, fileOnly, this.response);
|
return DeleteLink.load(link, post, fileOnly, this.response);
|
||||||
},
|
},
|
||||||
@ -9219,22 +9199,19 @@
|
|||||||
return DeleteLink.error(link);
|
return DeleteLink.error(link);
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
cred: true,
|
|
||||||
form: $.formData(form)
|
form: $.formData(form)
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
load: function(link, post, fileOnly, html) {
|
load: function(link, post, fileOnly, resDoc) {
|
||||||
var msg, s, tmpDoc;
|
var msg, s;
|
||||||
|
|
||||||
tmpDoc = d.implementation.createHTMLDocument('');
|
if (resDoc.title === '4chan - Banned') {
|
||||||
tmpDoc.documentElement.innerHTML = html;
|
|
||||||
if (tmpDoc.title === '4chan - Banned') {
|
|
||||||
s = 'Banned!';
|
s = 'Banned!';
|
||||||
} else if (msg = tmpDoc.getElementById('errmsg')) {
|
} else if (msg = resDoc.getElementById('errmsg')) {
|
||||||
s = msg.textContent;
|
s = msg.textContent;
|
||||||
$.on(link, 'click', DeleteLink["delete"]);
|
$.on(link, 'click', DeleteLink["delete"]);
|
||||||
} else {
|
} else {
|
||||||
if (tmpDoc.title === 'Updating index...') {
|
if (resDoc.title === 'Updating index...') {
|
||||||
(post.origin || post).kill(fileOnly);
|
(post.origin || post).kill(fileOnly);
|
||||||
}
|
}
|
||||||
s = 'Deleted';
|
s = 'Deleted';
|
||||||
@ -10254,8 +10231,7 @@
|
|||||||
if (Conf['Unread Line']) {
|
if (Conf['Unread Line']) {
|
||||||
Unread.setLine(posts.contains(Unread.posts[0]));
|
Unread.setLine(posts.contains(Unread.posts[0]));
|
||||||
}
|
}
|
||||||
Unread.read();
|
return Unread.read();
|
||||||
return Unread.update();
|
|
||||||
},
|
},
|
||||||
addPostQuotingYou: function(post) {
|
addPostQuotingYou: function(post) {
|
||||||
var quotelink, _i, _len, _ref;
|
var quotelink, _i, _len, _ref;
|
||||||
@ -10305,32 +10281,40 @@
|
|||||||
}
|
}
|
||||||
return arr.splice(0, i);
|
return arr.splice(0, i);
|
||||||
},
|
},
|
||||||
read: $.debounce(50, function(e) {
|
read: $.debounce(50, function() {
|
||||||
var ID, bottom, height, i, post, posts, read;
|
var ID, bottom, height, i, post, posts;
|
||||||
|
|
||||||
if (d.hidden || !Unread.posts.length) {
|
if (d.hidden || !Unread.posts.length) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
height = doc.clientHeight;
|
height = doc.clientHeight;
|
||||||
posts = Unread.posts;
|
posts = Unread.posts;
|
||||||
read = [];
|
i = 0;
|
||||||
i = posts.length;
|
while (post = posts[i]) {
|
||||||
while (post = posts[--i]) {
|
|
||||||
bottom = post.nodes.root.getBoundingClientRect().bottom;
|
bottom = post.nodes.root.getBoundingClientRect().bottom;
|
||||||
if (bottom < height) {
|
if (bottom > height) {
|
||||||
ID = post.ID;
|
i++;
|
||||||
posts.remove(post);
|
continue;
|
||||||
}
|
}
|
||||||
|
ID = post.ID;
|
||||||
|
if (Conf['Quote Threading']) {
|
||||||
|
posts.splice(i, 1);
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
posts.splice(0, i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
if (!ID) {
|
if (!ID) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Unread.lastReadPost = ID;
|
if (Unread.lastReadPost < ID || !Unread.lastReadPost) {
|
||||||
|
Unread.lastReadPost = ID;
|
||||||
|
}
|
||||||
Unread.saveLastReadPost();
|
Unread.saveLastReadPost();
|
||||||
Unread.readArray(Unread.postsQuotingYou);
|
Unread.readArray(Unread.postsQuotingYou);
|
||||||
if (e) {
|
return Unread.update();
|
||||||
return Unread.update();
|
|
||||||
}
|
|
||||||
}),
|
}),
|
||||||
saveLastReadPost: $.debounce(2 * $.SECOND, function() {
|
saveLastReadPost: $.debounce(2 * $.SECOND, function() {
|
||||||
if (Unread.thread.isDead) {
|
if (Unread.thread.isDead) {
|
||||||
@ -12261,20 +12245,19 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
return Post.prototype.callbacks.push({
|
return Post.prototype.callbacks.push({
|
||||||
name: 'Reveal Spoilers',
|
name: 'Color User IDs',
|
||||||
cb: this.node
|
cb: this.node
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
node: function(post) {
|
node: function() {
|
||||||
var str, uid;
|
var str, uid;
|
||||||
|
|
||||||
if (!(uid = $('.hand', this.nodes.uniqueID))) {
|
str = this.info.uniqueID;
|
||||||
|
uid = $('.hand', this.nodes.uniqueID);
|
||||||
|
if (!(str && uid && uid.nodeName === 'SPAN')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
str = this.info.uniqueID;
|
return uid.style.cssText = IDColor.css(IDColor.ids[str] || IDColor.compute(str));
|
||||||
if (uid.nodeName === 'SPAN') {
|
|
||||||
return uid.style.cssText = IDColor.apply.call(str);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
ids: {},
|
ids: {},
|
||||||
compute: function(str) {
|
compute: function(str) {
|
||||||
@ -12286,11 +12269,8 @@
|
|||||||
this.ids[str] = rgb;
|
this.ids[str] = rgb;
|
||||||
return rgb;
|
return rgb;
|
||||||
},
|
},
|
||||||
apply: function() {
|
css: function(rgb) {
|
||||||
var rgb;
|
return "background-color: rgb(" + rgb[0] + "," + rgb[1] + "," + rgb[2] + "); color: " + (rgb[3] ? "black;" : "white;") + " border-radius: 3px; padding: 0px 2px;";
|
||||||
|
|
||||||
rgb = IDColor.ids[this] || IDColor.compute(this);
|
|
||||||
return ("background-color: rgb(" + rgb[0] + "," + rgb[1] + "," + rgb[2] + "); color: ") + (rgb[3] ? "black; border-radius: 3px; padding: 0px 2px;" : "white; border-radius: 3px; padding: 0px 2px;");
|
|
||||||
},
|
},
|
||||||
hash: function(str) {
|
hash: function(str) {
|
||||||
var i, j, msg;
|
var i, j, msg;
|
||||||
@ -14724,7 +14704,7 @@
|
|||||||
'Announcement Hiding': PSAHiding,
|
'Announcement Hiding': PSAHiding,
|
||||||
'Fourchan thingies': Fourchan,
|
'Fourchan thingies': Fourchan,
|
||||||
'Color User IDs': IDColor,
|
'Color User IDs': IDColor,
|
||||||
'Remove Spoilers': RemoveSpoilers,
|
'Reveal Spoilers': RemoveSpoilers,
|
||||||
'Custom CSS': CustomCSS,
|
'Custom CSS': CustomCSS,
|
||||||
'Linkify': Linkify,
|
'Linkify': Linkify,
|
||||||
'Resurrect Quotes': Quotify,
|
'Resurrect Quotes': Quotify,
|
||||||
@ -14756,7 +14736,7 @@
|
|||||||
'Sauce': Sauce,
|
'Sauce': Sauce,
|
||||||
'Image Expansion': ImageExpand,
|
'Image Expansion': ImageExpand,
|
||||||
'Image Expansion (Menu)': ImageExpand.menu,
|
'Image Expansion (Menu)': ImageExpand.menu,
|
||||||
'Reveal Spoilers': RevealSpoilers,
|
'Reveal Spoiler Thumbnails': RevealSpoilers,
|
||||||
'Image Loading': ImageLoader,
|
'Image Loading': ImageLoader,
|
||||||
'Image Hover': ImageHover,
|
'Image Hover': ImageHover,
|
||||||
'Comment Expansion': ExpandComment,
|
'Comment Expansion': ExpandComment,
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
// Generated by CoffeeScript
|
// Generated by CoffeeScript
|
||||||
/*
|
/*
|
||||||
* appchan x - Version 2.2.2 - 2013-08-07
|
* appchan x - Version 2.2.2 - 2013-08-08
|
||||||
*
|
*
|
||||||
* Licensed under the MIT license.
|
* Licensed under the MIT license.
|
||||||
* https://github.com/zixaphir/appchan-x/blob/master/LICENSE
|
* https://github.com/zixaphir/appchan-x/blob/master/LICENSE
|
||||||
@ -2676,15 +2676,6 @@
|
|||||||
return this.indexOf(string) > -1;
|
return this.indexOf(string) > -1;
|
||||||
};
|
};
|
||||||
|
|
||||||
Array.prototype.add = function(object, position) {
|
|
||||||
var keep;
|
|
||||||
|
|
||||||
keep = this.slice(position);
|
|
||||||
this.length = position;
|
|
||||||
this.push(object);
|
|
||||||
return this.pushArrays(keep);
|
|
||||||
};
|
|
||||||
|
|
||||||
Array.prototype.contains = function(object) {
|
Array.prototype.contains = function(object) {
|
||||||
return this.indexOf(object) > -1;
|
return this.indexOf(object) > -1;
|
||||||
};
|
};
|
||||||
@ -2701,27 +2692,6 @@
|
|||||||
return i;
|
return i;
|
||||||
};
|
};
|
||||||
|
|
||||||
Array.prototype.pushArrays = function() {
|
|
||||||
var arg, args, _i, _len;
|
|
||||||
|
|
||||||
args = arguments;
|
|
||||||
for (_i = 0, _len = args.length; _i < _len; _i++) {
|
|
||||||
arg = args[_i];
|
|
||||||
this.push.apply(this, arg);
|
|
||||||
}
|
|
||||||
return this;
|
|
||||||
};
|
|
||||||
|
|
||||||
Array.prototype.remove = function(object) {
|
|
||||||
var index;
|
|
||||||
|
|
||||||
if ((index = this.indexOf(object)) > -1) {
|
|
||||||
return this.splice(index, 1);
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
$ = function(selector, root) {
|
$ = function(selector, root) {
|
||||||
if (root == null) {
|
if (root == null) {
|
||||||
root = d.body;
|
root = d.body;
|
||||||
@ -2781,13 +2751,22 @@
|
|||||||
return fd;
|
return fd;
|
||||||
};
|
};
|
||||||
|
|
||||||
$.ajax = function(url, callbacks, opts) {
|
$.extend = function(object, properties) {
|
||||||
var cred, err, form, headers, key, r, sync, type, upCallbacks, val;
|
var key, val;
|
||||||
|
|
||||||
if (opts == null) {
|
for (key in properties) {
|
||||||
opts = {};
|
val = properties[key];
|
||||||
|
object[key] = val;
|
||||||
}
|
}
|
||||||
type = opts.type, cred = opts.cred, headers = opts.headers, upCallbacks = opts.upCallbacks, form = opts.form, sync = opts.sync;
|
};
|
||||||
|
|
||||||
|
$.ajax = function(url, options, extra) {
|
||||||
|
var form, headers, key, r, sync, type, upCallbacks, val;
|
||||||
|
|
||||||
|
if (extra == null) {
|
||||||
|
extra = {};
|
||||||
|
}
|
||||||
|
type = extra.type, headers = extra.headers, upCallbacks = extra.upCallbacks, form = extra.form, sync = extra.sync;
|
||||||
r = new XMLHttpRequest();
|
r = new XMLHttpRequest();
|
||||||
r.overrideMimeType('text/html');
|
r.overrideMimeType('text/html');
|
||||||
type || (type = form && 'post' || 'get');
|
type || (type = form && 'post' || 'get');
|
||||||
@ -2796,13 +2775,8 @@
|
|||||||
val = headers[key];
|
val = headers[key];
|
||||||
r.setRequestHeader(key, val);
|
r.setRequestHeader(key, val);
|
||||||
}
|
}
|
||||||
$.extend(r, callbacks);
|
$.extend(r, options);
|
||||||
$.extend(r.upload, upCallbacks);
|
$.extend(r.upload, upCallbacks);
|
||||||
try {
|
|
||||||
r.withCredentials = cred;
|
|
||||||
} catch (_error) {
|
|
||||||
err = _error;
|
|
||||||
}
|
|
||||||
r.send(form);
|
r.send(form);
|
||||||
return r;
|
return r;
|
||||||
};
|
};
|
||||||
@ -3980,7 +3954,11 @@
|
|||||||
a.dataset.only = m[1];
|
a.dataset.only = m[1];
|
||||||
a.href = "//boards.4chan.org/" + board + "/";
|
a.href = "//boards.4chan.org/" + board + "/";
|
||||||
if (m[1] === 'catalog') {
|
if (m[1] === 'catalog') {
|
||||||
a.href += 'catalog';
|
if (Conf['External Catalog']) {
|
||||||
|
a.href = CatalogLinks.external(board);
|
||||||
|
} else {
|
||||||
|
a.href += 'catalog';
|
||||||
|
}
|
||||||
$.addClass(a, 'catalog');
|
$.addClass(a, 'catalog');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5975,7 +5953,7 @@
|
|||||||
if (Conf['Quote Inlining']) {
|
if (Conf['Quote Inlining']) {
|
||||||
$.on(link, 'click', QuoteInline.toggle);
|
$.on(link, 'click', QuoteInline.toggle);
|
||||||
if (Conf['Quote Hash Navigation']) {
|
if (Conf['Quote Hash Navigation']) {
|
||||||
frag.pushArrays(QuoteInline.qiQuote(link, $.hasClass(link, 'filtered')));
|
frag.push.apply(frag, QuoteInline.qiQuote(link, $.hasClass(link, 'filtered')));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$.add(container, frag);
|
$.add(container, frag);
|
||||||
@ -6054,9 +6032,6 @@
|
|||||||
if (g.VIEW === 'catalog' || !Conf['Quote Inlining']) {
|
if (g.VIEW === 'catalog' || !Conf['Quote Inlining']) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Conf['Comment Expansion']) {
|
|
||||||
ExpandComment.callbacks.push(this.node);
|
|
||||||
}
|
|
||||||
if (Conf['Quote Hash Navigation']) {
|
if (Conf['Quote Hash Navigation']) {
|
||||||
this.node = function() {
|
this.node = function() {
|
||||||
var link, _i, _len, _ref;
|
var link, _i, _len, _ref;
|
||||||
@ -6081,6 +6056,9 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
if (Conf['Comment Expansion']) {
|
||||||
|
ExpandComment.callbacks.push(this.node);
|
||||||
|
}
|
||||||
return Post.prototype.callbacks.push({
|
return Post.prototype.callbacks.push({
|
||||||
name: 'Quote Inlining',
|
name: 'Quote Inlining',
|
||||||
cb: this.node
|
cb: this.node
|
||||||
@ -8257,7 +8235,7 @@
|
|||||||
},
|
},
|
||||||
preSubmitHooks: [],
|
preSubmitHooks: [],
|
||||||
submit: function(e) {
|
submit: function(e) {
|
||||||
var callbacks, challenge, err, filetag, hook, opts, post, postData, response, textOnly, thread, threadID, _i, _len, _ref, _ref1;
|
var challenge, err, extra, filetag, hook, options, post, postData, response, textOnly, thread, threadID, _i, _len, _ref, _ref1;
|
||||||
|
|
||||||
if (e != null) {
|
if (e != null) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
@ -8336,7 +8314,9 @@
|
|||||||
recaptcha_challenge_field: challenge,
|
recaptcha_challenge_field: challenge,
|
||||||
recaptcha_response_field: response
|
recaptcha_response_field: response
|
||||||
};
|
};
|
||||||
callbacks = {
|
options = {
|
||||||
|
responseType: 'document',
|
||||||
|
withCredentials: true,
|
||||||
onload: QR.response,
|
onload: QR.response,
|
||||||
onerror: function() {
|
onerror: function() {
|
||||||
delete QR.req;
|
delete QR.req;
|
||||||
@ -8344,12 +8324,11 @@
|
|||||||
QR.cooldown.auto = false;
|
QR.cooldown.auto = false;
|
||||||
QR.status();
|
QR.status();
|
||||||
return QR.error($.el('span', {
|
return QR.error($.el('span', {
|
||||||
innerHTML: "Connection error. You may have been <a href=//www.4chan.org/banned target=_blank>banned</a>.\n[<a href='https://github.com/seaweedchan/4chan-x/wiki/Frequently-Asked-Questions#what-does-4chan-x-encountered-an-error-while-posting-please-try-again-mean' target=_blank>?</a>]"
|
innerHTML: "Connection error. You may have been <a href=//www.4chan.org/banned target=_blank>banned</a>.\n[<a href=\"https://github.com/seaweedchan/4chan-x/wiki/Frequently-Asked-Questions#what-does-4chan-x-encountered-an-error-while-posting-please-try-again-mean\" target=_blank>?</a>]"
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
opts = {
|
extra = {
|
||||||
cred: true,
|
|
||||||
form: $.formData(postData),
|
form: $.formData(postData),
|
||||||
upCallbacks: {
|
upCallbacks: {
|
||||||
onload: function() {
|
onload: function() {
|
||||||
@ -8364,30 +8343,29 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
QR.req = $.ajax($.id('postForm').parentNode.action, callbacks, opts);
|
QR.req = $.ajax($.id('postForm').parentNode.action, options, extra);
|
||||||
QR.req.uploadStartTime = Date.now();
|
QR.req.uploadStartTime = Date.now();
|
||||||
QR.req.progress = '...';
|
QR.req.progress = '...';
|
||||||
return QR.status();
|
return QR.status();
|
||||||
},
|
},
|
||||||
response: function() {
|
response: function() {
|
||||||
var URL, ban, board, err, h1, isReply, m, post, postID, req, threadID, tmpDoc, _, _ref, _ref1;
|
var URL, ban, board, err, h1, isReply, m, post, postID, req, resDoc, threadID, _, _ref, _ref1;
|
||||||
|
|
||||||
req = QR.req;
|
req = QR.req;
|
||||||
delete QR.req;
|
delete QR.req;
|
||||||
post = QR.posts[0];
|
post = QR.posts[0];
|
||||||
post.unlock();
|
post.unlock();
|
||||||
tmpDoc = d.implementation.createHTMLDocument('');
|
resDoc = req.response;
|
||||||
tmpDoc.documentElement.innerHTML = req.response;
|
if (ban = $('.banType', resDoc)) {
|
||||||
if (ban = $('.banType', tmpDoc)) {
|
board = $('.board', resDoc).innerHTML;
|
||||||
board = $('.board', tmpDoc).innerHTML;
|
|
||||||
err = $.el('span', {
|
err = $.el('span', {
|
||||||
innerHTML: ban.textContent.toLowerCase() === 'banned' ? ("You are banned on " + board + "! ;_;<br>") + "Click <a href=//www.4chan.org/banned target=_blank>here</a> to see the reason." : ("You were issued a warning on " + board + " as " + ($('.nameBlock', tmpDoc).innerHTML) + ".<br>") + ("Reason: " + ($('.reason', tmpDoc).innerHTML))
|
innerHTML: ban.textContent.toLowerCase() === 'banned' ? "You are banned on " + board + "! ;_;<br>\nClick <a href=//www.4chan.org/banned target=_blank>here</a> to see the reason." : "You were issued a warning on " + board + " as " + ($('.nameBlock', resDoc).innerHTML) + ".<br>\nReason: " + ($('.reason', resDoc).innerHTML)
|
||||||
});
|
});
|
||||||
} else if (err = tmpDoc.getElementById('errmsg')) {
|
} else if (err = resDoc.getElementById('errmsg')) {
|
||||||
if ((_ref = $('a', err)) != null) {
|
if ((_ref = $('a', err)) != null) {
|
||||||
_ref.target = '_blank';
|
_ref.target = '_blank';
|
||||||
}
|
}
|
||||||
} else if (tmpDoc.title !== 'Post successful!') {
|
} else if (resDoc.title !== 'Post successful!') {
|
||||||
err = 'Connection error with sys.4chan.org.';
|
err = 'Connection error with sys.4chan.org.';
|
||||||
} else if (req.status !== 200) {
|
} else if (req.status !== 200) {
|
||||||
err = "Error " + req.statusText + " (" + req.status + ")";
|
err = "Error " + req.statusText + " (" + req.status + ")";
|
||||||
@ -8413,8 +8391,8 @@
|
|||||||
QR.error(err);
|
QR.error(err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
h1 = $('h1', resDoc);
|
||||||
QR.cleanNotifications();
|
QR.cleanNotifications();
|
||||||
h1 = $('h1', tmpDoc);
|
|
||||||
if (Conf['Posting Success Notifications']) {
|
if (Conf['Posting Success Notifications']) {
|
||||||
QR.notifications.push(new Notification('success', h1.textContent, 5));
|
QR.notifications.push(new Notification('success', h1.textContent, 5));
|
||||||
}
|
}
|
||||||
@ -9195,6 +9173,8 @@
|
|||||||
form[post.ID] = 'delete';
|
form[post.ID] = 'delete';
|
||||||
link = this;
|
link = this;
|
||||||
return $.ajax($.id('delform').action.replace("/" + g.BOARD + "/", "/" + post.board + "/"), {
|
return $.ajax($.id('delform').action.replace("/" + g.BOARD + "/", "/" + post.board + "/"), {
|
||||||
|
responseType: 'document',
|
||||||
|
withCredentials: true,
|
||||||
onload: function() {
|
onload: function() {
|
||||||
return DeleteLink.load(link, post, fileOnly, this.response);
|
return DeleteLink.load(link, post, fileOnly, this.response);
|
||||||
},
|
},
|
||||||
@ -9202,22 +9182,19 @@
|
|||||||
return DeleteLink.error(link);
|
return DeleteLink.error(link);
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
cred: true,
|
|
||||||
form: $.formData(form)
|
form: $.formData(form)
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
load: function(link, post, fileOnly, html) {
|
load: function(link, post, fileOnly, resDoc) {
|
||||||
var msg, s, tmpDoc;
|
var msg, s;
|
||||||
|
|
||||||
tmpDoc = d.implementation.createHTMLDocument('');
|
if (resDoc.title === '4chan - Banned') {
|
||||||
tmpDoc.documentElement.innerHTML = html;
|
|
||||||
if (tmpDoc.title === '4chan - Banned') {
|
|
||||||
s = 'Banned!';
|
s = 'Banned!';
|
||||||
} else if (msg = tmpDoc.getElementById('errmsg')) {
|
} else if (msg = resDoc.getElementById('errmsg')) {
|
||||||
s = msg.textContent;
|
s = msg.textContent;
|
||||||
$.on(link, 'click', DeleteLink["delete"]);
|
$.on(link, 'click', DeleteLink["delete"]);
|
||||||
} else {
|
} else {
|
||||||
if (tmpDoc.title === 'Updating index...') {
|
if (resDoc.title === 'Updating index...') {
|
||||||
(post.origin || post).kill(fileOnly);
|
(post.origin || post).kill(fileOnly);
|
||||||
}
|
}
|
||||||
s = 'Deleted';
|
s = 'Deleted';
|
||||||
@ -10237,8 +10214,7 @@
|
|||||||
if (Conf['Unread Line']) {
|
if (Conf['Unread Line']) {
|
||||||
Unread.setLine(posts.contains(Unread.posts[0]));
|
Unread.setLine(posts.contains(Unread.posts[0]));
|
||||||
}
|
}
|
||||||
Unread.read();
|
return Unread.read();
|
||||||
return Unread.update();
|
|
||||||
},
|
},
|
||||||
addPostQuotingYou: function(post) {
|
addPostQuotingYou: function(post) {
|
||||||
var quotelink, _i, _len, _ref;
|
var quotelink, _i, _len, _ref;
|
||||||
@ -10288,32 +10264,40 @@
|
|||||||
}
|
}
|
||||||
return arr.splice(0, i);
|
return arr.splice(0, i);
|
||||||
},
|
},
|
||||||
read: $.debounce(50, function(e) {
|
read: $.debounce(50, function() {
|
||||||
var ID, bottom, height, i, post, posts, read;
|
var ID, bottom, height, i, post, posts;
|
||||||
|
|
||||||
if (d.hidden || !Unread.posts.length) {
|
if (d.hidden || !Unread.posts.length) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
height = doc.clientHeight;
|
height = doc.clientHeight;
|
||||||
posts = Unread.posts;
|
posts = Unread.posts;
|
||||||
read = [];
|
i = 0;
|
||||||
i = posts.length;
|
while (post = posts[i]) {
|
||||||
while (post = posts[--i]) {
|
|
||||||
bottom = post.nodes.root.getBoundingClientRect().bottom;
|
bottom = post.nodes.root.getBoundingClientRect().bottom;
|
||||||
if (bottom < height) {
|
if (bottom > height) {
|
||||||
ID = post.ID;
|
i++;
|
||||||
posts.remove(post);
|
continue;
|
||||||
}
|
}
|
||||||
|
ID = post.ID;
|
||||||
|
if (Conf['Quote Threading']) {
|
||||||
|
posts.splice(i, 1);
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
posts.splice(0, i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
if (!ID) {
|
if (!ID) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Unread.lastReadPost = ID;
|
if (Unread.lastReadPost < ID || !Unread.lastReadPost) {
|
||||||
|
Unread.lastReadPost = ID;
|
||||||
|
}
|
||||||
Unread.saveLastReadPost();
|
Unread.saveLastReadPost();
|
||||||
Unread.readArray(Unread.postsQuotingYou);
|
Unread.readArray(Unread.postsQuotingYou);
|
||||||
if (e) {
|
return Unread.update();
|
||||||
return Unread.update();
|
|
||||||
}
|
|
||||||
}),
|
}),
|
||||||
saveLastReadPost: $.debounce(2 * $.SECOND, function() {
|
saveLastReadPost: $.debounce(2 * $.SECOND, function() {
|
||||||
if (Unread.thread.isDead) {
|
if (Unread.thread.isDead) {
|
||||||
@ -12249,20 +12233,19 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
return Post.prototype.callbacks.push({
|
return Post.prototype.callbacks.push({
|
||||||
name: 'Reveal Spoilers',
|
name: 'Color User IDs',
|
||||||
cb: this.node
|
cb: this.node
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
node: function(post) {
|
node: function() {
|
||||||
var str, uid;
|
var str, uid;
|
||||||
|
|
||||||
if (!(uid = $('.hand', this.nodes.uniqueID))) {
|
str = this.info.uniqueID;
|
||||||
|
uid = $('.hand', this.nodes.uniqueID);
|
||||||
|
if (!(str && uid && uid.nodeName === 'SPAN')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
str = this.info.uniqueID;
|
return uid.style.cssText = IDColor.css(IDColor.ids[str] || IDColor.compute(str));
|
||||||
if (uid.nodeName === 'SPAN') {
|
|
||||||
return uid.style.cssText = IDColor.apply.call(str);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
ids: {},
|
ids: {},
|
||||||
compute: function(str) {
|
compute: function(str) {
|
||||||
@ -12274,11 +12257,8 @@
|
|||||||
this.ids[str] = rgb;
|
this.ids[str] = rgb;
|
||||||
return rgb;
|
return rgb;
|
||||||
},
|
},
|
||||||
apply: function() {
|
css: function(rgb) {
|
||||||
var rgb;
|
return "background-color: rgb(" + rgb[0] + "," + rgb[1] + "," + rgb[2] + "); color: " + (rgb[3] ? "black;" : "white;") + " border-radius: 3px; padding: 0px 2px;";
|
||||||
|
|
||||||
rgb = IDColor.ids[this] || IDColor.compute(this);
|
|
||||||
return ("background-color: rgb(" + rgb[0] + "," + rgb[1] + "," + rgb[2] + "); color: ") + (rgb[3] ? "black; border-radius: 3px; padding: 0px 2px;" : "white; border-radius: 3px; padding: 0px 2px;");
|
|
||||||
},
|
},
|
||||||
hash: function(str) {
|
hash: function(str) {
|
||||||
var i, j, msg;
|
var i, j, msg;
|
||||||
@ -14704,7 +14684,7 @@
|
|||||||
'Announcement Hiding': PSAHiding,
|
'Announcement Hiding': PSAHiding,
|
||||||
'Fourchan thingies': Fourchan,
|
'Fourchan thingies': Fourchan,
|
||||||
'Color User IDs': IDColor,
|
'Color User IDs': IDColor,
|
||||||
'Remove Spoilers': RemoveSpoilers,
|
'Reveal Spoilers': RemoveSpoilers,
|
||||||
'Custom CSS': CustomCSS,
|
'Custom CSS': CustomCSS,
|
||||||
'Linkify': Linkify,
|
'Linkify': Linkify,
|
||||||
'Resurrect Quotes': Quotify,
|
'Resurrect Quotes': Quotify,
|
||||||
@ -14736,7 +14716,7 @@
|
|||||||
'Sauce': Sauce,
|
'Sauce': Sauce,
|
||||||
'Image Expansion': ImageExpand,
|
'Image Expansion': ImageExpand,
|
||||||
'Image Expansion (Menu)': ImageExpand.menu,
|
'Image Expansion (Menu)': ImageExpand.menu,
|
||||||
'Reveal Spoilers': RevealSpoilers,
|
'Reveal Spoiler Thumbnails': RevealSpoilers,
|
||||||
'Image Loading': ImageLoader,
|
'Image Loading': ImageLoader,
|
||||||
'Image Hover': ImageHover,
|
'Image Hover': ImageHover,
|
||||||
'Comment Expansion': ExpandComment,
|
'Comment Expansion': ExpandComment,
|
||||||
|
|||||||
@ -144,7 +144,10 @@ Header =
|
|||||||
a.dataset.only = m[1]
|
a.dataset.only = m[1]
|
||||||
a.href = "//boards.4chan.org/#{board}/"
|
a.href = "//boards.4chan.org/#{board}/"
|
||||||
if m[1] is 'catalog'
|
if m[1] is 'catalog'
|
||||||
a.href += 'catalog'
|
if Conf['External Catalog']
|
||||||
|
a.href = CatalogLinks.external board
|
||||||
|
else
|
||||||
|
a.href += 'catalog'
|
||||||
$.addClass a, 'catalog'
|
$.addClass a, 'catalog'
|
||||||
|
|
||||||
$.addClass a, 'navSmall' if board is '@'
|
$.addClass a, 'navSmall' if board is '@'
|
||||||
|
|||||||
@ -105,66 +105,66 @@ Main =
|
|||||||
# c.time 'All initializations'
|
# c.time 'All initializations'
|
||||||
|
|
||||||
init
|
init
|
||||||
'Polyfill': Polyfill
|
'Polyfill': Polyfill
|
||||||
'Emoji': Emoji
|
'Emoji': Emoji
|
||||||
'Style': Style
|
'Style': Style
|
||||||
'Mascots': MascotTools
|
'Mascots': MascotTools
|
||||||
'Rice': Rice
|
'Rice': Rice
|
||||||
'Banner': Banner
|
'Banner': Banner
|
||||||
'Announcements': GlobalMessage
|
'Announcements': GlobalMessage
|
||||||
'Archive Redirection': Redirect
|
'Archive Redirection': Redirect
|
||||||
'Header': Header
|
'Header': Header
|
||||||
'Catalog Links': CatalogLinks
|
'Catalog Links': CatalogLinks
|
||||||
'Settings': Settings
|
'Settings': Settings
|
||||||
'Announcement Hiding': PSAHiding
|
'Announcement Hiding': PSAHiding
|
||||||
'Fourchan thingies': Fourchan
|
'Fourchan thingies': Fourchan
|
||||||
'Color User IDs': IDColor
|
'Color User IDs': IDColor
|
||||||
'Remove Spoilers': RemoveSpoilers
|
'Reveal Spoilers': RemoveSpoilers
|
||||||
'Custom CSS': CustomCSS
|
'Custom CSS': CustomCSS
|
||||||
'Linkify': Linkify
|
'Linkify': Linkify
|
||||||
'Resurrect Quotes': Quotify
|
'Resurrect Quotes': Quotify
|
||||||
'Filter': Filter
|
'Filter': Filter
|
||||||
'Thread Hiding Buttons': ThreadHiding
|
'Thread Hiding Buttons': ThreadHiding
|
||||||
'Reply Hiding Buttons': PostHiding
|
'Reply Hiding Buttons': PostHiding
|
||||||
'Recursive': Recursive
|
'Recursive': Recursive
|
||||||
'Strike-through Quotes': QuoteStrikeThrough
|
'Strike-through Quotes': QuoteStrikeThrough
|
||||||
'Quick Reply': QR
|
'Quick Reply': QR
|
||||||
'Menu': Menu
|
'Menu': Menu
|
||||||
'Report Link': ReportLink
|
'Report Link': ReportLink
|
||||||
'Thread Hiding (Menu)': ThreadHiding.menu
|
'Thread Hiding (Menu)': ThreadHiding.menu
|
||||||
'Reply Hiding (Menu)': PostHiding.menu
|
'Reply Hiding (Menu)': PostHiding.menu
|
||||||
'Delete Link': DeleteLink
|
'Delete Link': DeleteLink
|
||||||
'Filter (Menu)': Filter.menu
|
'Filter (Menu)': Filter.menu
|
||||||
'Download Link': DownloadLink
|
'Download Link': DownloadLink
|
||||||
'Archive Link': ArchiveLink
|
'Archive Link': ArchiveLink
|
||||||
'Quote Inlining': QuoteInline
|
'Quote Inlining': QuoteInline
|
||||||
'Quote Previewing': QuotePreview
|
'Quote Previewing': QuotePreview
|
||||||
'Quote Backlinks': QuoteBacklink
|
'Quote Backlinks': QuoteBacklink
|
||||||
'Mark Quotes of You': QuoteYou
|
'Mark Quotes of You': QuoteYou
|
||||||
'Mark OP Quotes': QuoteOP
|
'Mark OP Quotes': QuoteOP
|
||||||
'Mark Cross-thread Quotes': QuoteCT
|
'Mark Cross-thread Quotes': QuoteCT
|
||||||
'Anonymize': Anonymize
|
'Anonymize': Anonymize
|
||||||
'Time Formatting': Time
|
'Time Formatting': Time
|
||||||
'Relative Post Dates': RelativeDates
|
'Relative Post Dates': RelativeDates
|
||||||
'File Info Formatting': FileInfo
|
'File Info Formatting': FileInfo
|
||||||
'Fappe Tyme': FappeTyme
|
'Fappe Tyme': FappeTyme
|
||||||
'Sauce': Sauce
|
'Sauce': Sauce
|
||||||
'Image Expansion': ImageExpand
|
'Image Expansion': ImageExpand
|
||||||
'Image Expansion (Menu)': ImageExpand.menu
|
'Image Expansion (Menu)': ImageExpand.menu
|
||||||
'Reveal Spoilers': RevealSpoilers
|
'Reveal Spoiler Thumbnails': RevealSpoilers
|
||||||
'Image Loading': ImageLoader
|
'Image Loading': ImageLoader
|
||||||
'Image Hover': ImageHover
|
'Image Hover': ImageHover
|
||||||
'Comment Expansion': ExpandComment
|
'Comment Expansion': ExpandComment
|
||||||
'Thread Expansion': ExpandThread
|
'Thread Expansion': ExpandThread
|
||||||
'Thread Excerpt': ThreadExcerpt
|
'Thread Excerpt': ThreadExcerpt
|
||||||
'Favicon': Favicon
|
'Favicon': Favicon
|
||||||
'Unread': Unread
|
'Unread': Unread
|
||||||
'Quote Threading': QuoteThreading
|
'Quote Threading': QuoteThreading
|
||||||
'Thread Updater': ThreadUpdater
|
'Thread Updater': ThreadUpdater
|
||||||
'Thread Stats': ThreadStats
|
'Thread Stats': ThreadStats
|
||||||
'Thread Watcher': ThreadWatcher
|
'Thread Watcher': ThreadWatcher
|
||||||
'Index Navigation': Nav
|
'Index Navigation': Nav
|
||||||
'Keybinds': Keybinds
|
'Keybinds': Keybinds
|
||||||
|
|
||||||
# c.timeEnd 'All initializations'
|
# c.timeEnd 'All initializations'
|
||||||
|
|
||||||
|
|||||||
@ -4,12 +4,6 @@ String::capitalize = ->
|
|||||||
String::contains = (string) ->
|
String::contains = (string) ->
|
||||||
@indexOf(string) > -1
|
@indexOf(string) > -1
|
||||||
|
|
||||||
Array::add = (object, position) ->
|
|
||||||
keep = @slice position
|
|
||||||
@length = position
|
|
||||||
@push object
|
|
||||||
@pushArrays keep
|
|
||||||
|
|
||||||
Array::contains = (object) ->
|
Array::contains = (object) ->
|
||||||
@indexOf(object) > -1
|
@indexOf(object) > -1
|
||||||
|
|
||||||
@ -19,18 +13,6 @@ Array::indexOf = (object) ->
|
|||||||
return i if @[i] is object
|
return i if @[i] is object
|
||||||
return i
|
return i
|
||||||
|
|
||||||
Array::pushArrays = ->
|
|
||||||
args = arguments
|
|
||||||
for arg in args
|
|
||||||
@push.apply @, arg
|
|
||||||
return @
|
|
||||||
|
|
||||||
Array::remove = (object) ->
|
|
||||||
if (index = @indexOf object) > -1
|
|
||||||
@splice index, 1
|
|
||||||
else
|
|
||||||
false
|
|
||||||
|
|
||||||
# loosely follows the jquery api:
|
# loosely follows the jquery api:
|
||||||
# http://api.jquery.com/
|
# http://api.jquery.com/
|
||||||
# not chainable
|
# not chainable
|
||||||
@ -70,24 +52,21 @@ $.formData = (form) ->
|
|||||||
fd.append key, val
|
fd.append key, val
|
||||||
fd
|
fd
|
||||||
|
|
||||||
$.ajax = (url, callbacks, opts={}) ->
|
$.extend = (object, properties) ->
|
||||||
{type, cred, headers, upCallbacks, form, sync} = opts
|
for key, val of properties
|
||||||
|
object[key] = val
|
||||||
|
return
|
||||||
|
|
||||||
|
$.ajax = (url, options, extra={}) ->
|
||||||
|
{type, headers, upCallbacks, form, sync} = extra
|
||||||
r = new XMLHttpRequest()
|
r = new XMLHttpRequest()
|
||||||
r.overrideMimeType 'text/html'
|
r.overrideMimeType 'text/html'
|
||||||
type or= form and 'post' or 'get'
|
type or= form and 'post' or 'get'
|
||||||
r.open type, url, !sync
|
r.open type, url, !sync
|
||||||
for key, val of headers
|
for key, val of headers
|
||||||
r.setRequestHeader key, val
|
r.setRequestHeader key, val
|
||||||
$.extend r, callbacks
|
$.extend r, options
|
||||||
$.extend r.upload, upCallbacks
|
$.extend r.upload, upCallbacks
|
||||||
try
|
|
||||||
# Firefox throws an error if you try
|
|
||||||
# to set this on a synchronous XHR.
|
|
||||||
# Only cookies from the remote domain
|
|
||||||
# are used in a request withCredentials.
|
|
||||||
r.withCredentials = cred
|
|
||||||
catch err
|
|
||||||
# do nothing
|
|
||||||
r.send form
|
r.send form
|
||||||
r
|
r
|
||||||
|
|
||||||
|
|||||||
@ -55,21 +55,20 @@ DeleteLink =
|
|||||||
|
|
||||||
link = @
|
link = @
|
||||||
$.ajax $.id('delform').action.replace("/#{g.BOARD}/", "/#{post.board}/"),
|
$.ajax $.id('delform').action.replace("/#{g.BOARD}/", "/#{post.board}/"),
|
||||||
|
responseType: 'document'
|
||||||
|
withCredentials: true
|
||||||
onload: -> DeleteLink.load link, post, fileOnly, @response
|
onload: -> DeleteLink.load link, post, fileOnly, @response
|
||||||
onerror: -> DeleteLink.error link
|
onerror: -> DeleteLink.error link
|
||||||
,
|
,
|
||||||
cred: true
|
|
||||||
form: $.formData form
|
form: $.formData form
|
||||||
load: (link, post, fileOnly, html) ->
|
load: (link, post, fileOnly, resDoc) ->
|
||||||
tmpDoc = d.implementation.createHTMLDocument ''
|
if resDoc.title is '4chan - Banned' # Ban/warn check
|
||||||
tmpDoc.documentElement.innerHTML = html
|
|
||||||
if tmpDoc.title is '4chan - Banned' # Ban/warn check
|
|
||||||
s = 'Banned!'
|
s = 'Banned!'
|
||||||
else if msg = tmpDoc.getElementById 'errmsg' # error!
|
else if msg = resDoc.getElementById 'errmsg' # error!
|
||||||
s = msg.textContent
|
s = msg.textContent
|
||||||
$.on link, 'click', DeleteLink.delete
|
$.on link, 'click', DeleteLink.delete
|
||||||
else
|
else
|
||||||
if tmpDoc.title is 'Updating index...'
|
if resDoc.title is 'Updating index...'
|
||||||
# We're 100% sure.
|
# We're 100% sure.
|
||||||
(post.origin or post).kill fileOnly
|
(post.origin or post).kill fileOnly
|
||||||
s = 'Deleted'
|
s = 'Deleted'
|
||||||
|
|||||||
@ -36,7 +36,7 @@ CatalogLinks =
|
|||||||
continue if ['f', 'status', '4chan'].contains(board) or !board
|
continue if ['f', 'status', '4chan'].contains(board) or !board
|
||||||
if Conf['External Catalog']
|
if Conf['External Catalog']
|
||||||
a.href = if useCatalog
|
a.href = if useCatalog
|
||||||
CatalogLinks.external(board)
|
CatalogLinks.external board
|
||||||
else
|
else
|
||||||
"//boards.4chan.org/#{board}/"
|
"//boards.4chan.org/#{board}/"
|
||||||
else
|
else
|
||||||
|
|||||||
@ -3,14 +3,14 @@ IDColor =
|
|||||||
return unless Conf['Color User IDs']
|
return unless Conf['Color User IDs']
|
||||||
|
|
||||||
Post::callbacks.push
|
Post::callbacks.push
|
||||||
name: 'Reveal Spoilers'
|
name: 'Color User IDs'
|
||||||
cb: @node
|
cb: @node
|
||||||
|
|
||||||
node: (post) ->
|
node: ->
|
||||||
return unless uid = $ '.hand', @nodes.uniqueID
|
|
||||||
str = @info.uniqueID
|
str = @info.uniqueID
|
||||||
if uid.nodeName is 'SPAN'
|
uid = $ '.hand', @nodes.uniqueID
|
||||||
uid.style.cssText = IDColor.apply.call str
|
return unless str and uid and uid.nodeName is 'SPAN'
|
||||||
|
uid.style.cssText = IDColor.css IDColor.ids[str] or IDColor.compute str
|
||||||
|
|
||||||
ids: {}
|
ids: {}
|
||||||
|
|
||||||
@ -22,14 +22,13 @@ IDColor =
|
|||||||
(hash >> 16) & 0xFF
|
(hash >> 16) & 0xFF
|
||||||
(hash >> 8) & 0xFF
|
(hash >> 8) & 0xFF
|
||||||
]
|
]
|
||||||
|
|
||||||
rgb[3] = ((rgb[0] * 0.299) + (rgb[1] * 0.587) + (rgb[2] * 0.114)) > 125
|
rgb[3] = ((rgb[0] * 0.299) + (rgb[1] * 0.587) + (rgb[2] * 0.114)) > 125
|
||||||
|
|
||||||
@ids[str] = rgb
|
@ids[str] = rgb
|
||||||
rgb
|
rgb
|
||||||
|
|
||||||
apply: ->
|
css: (rgb) -> "background-color: rgb(#{rgb[0]},#{rgb[1]},#{rgb[2]}); color: #{if rgb[3] then "black;" else "white;"} border-radius: 3px; padding: 0px 2px;"
|
||||||
rgb = IDColor.ids[@] or IDColor.compute @
|
|
||||||
"background-color: rgb(#{rgb[0]},#{rgb[1]},#{rgb[2]}); color: " + if rgb[3] then "black; border-radius: 3px; padding: 0px 2px;" else "white; border-radius: 3px; padding: 0px 2px;"
|
|
||||||
|
|
||||||
hash: (str) ->
|
hash: (str) ->
|
||||||
msg = 0
|
msg = 0
|
||||||
|
|||||||
@ -86,7 +86,6 @@ Unread =
|
|||||||
# Force line on visible threads if there were no unread posts previously.
|
# Force line on visible threads if there were no unread posts previously.
|
||||||
Unread.setLine posts.contains Unread.posts[0]
|
Unread.setLine posts.contains Unread.posts[0]
|
||||||
Unread.read()
|
Unread.read()
|
||||||
Unread.update()
|
|
||||||
|
|
||||||
addPostQuotingYou: (post) ->
|
addPostQuotingYou: (post) ->
|
||||||
return unless QR.db
|
return unless QR.db
|
||||||
@ -116,24 +115,32 @@ Unread =
|
|||||||
break if post.ID > Unread.lastReadPost
|
break if post.ID > Unread.lastReadPost
|
||||||
arr.splice 0, i
|
arr.splice 0, i
|
||||||
|
|
||||||
read: $.debounce 50, (e) ->
|
read: $.debounce 50, ->
|
||||||
return if d.hidden or !Unread.posts.length
|
return if d.hidden or !Unread.posts.length
|
||||||
height = doc.clientHeight
|
height = doc.clientHeight
|
||||||
{posts} = Unread
|
{posts} = Unread
|
||||||
read = []
|
i = 0
|
||||||
i = posts.length
|
|
||||||
|
|
||||||
while post = posts[--i]
|
while post = posts[i]
|
||||||
{bottom} = post.nodes.root.getBoundingClientRect()
|
{bottom} = post.nodes.root.getBoundingClientRect()
|
||||||
if (bottom < height) # post is completely read
|
if bottom > height # post isnt completely read
|
||||||
ID = post.ID
|
i++
|
||||||
posts.remove post
|
continue
|
||||||
|
|
||||||
|
{ID} = post
|
||||||
|
if Conf['Quote Threading']
|
||||||
|
posts.splice i, 1
|
||||||
|
continue
|
||||||
|
else
|
||||||
|
posts.splice 0, i
|
||||||
|
break
|
||||||
|
i++
|
||||||
return unless ID
|
return unless ID
|
||||||
|
|
||||||
Unread.lastReadPost = ID
|
Unread.lastReadPost = ID if Unread.lastReadPost < ID or !Unread.lastReadPost
|
||||||
Unread.saveLastReadPost()
|
Unread.saveLastReadPost()
|
||||||
Unread.readArray Unread.postsQuotingYou
|
Unread.readArray Unread.postsQuotingYou
|
||||||
Unread.update() if e
|
Unread.update()
|
||||||
|
|
||||||
saveLastReadPost: $.debounce 2 * $.SECOND, ->
|
saveLastReadPost: $.debounce 2 * $.SECOND, ->
|
||||||
return if Unread.thread.isDead
|
return if Unread.thread.isDead
|
||||||
|
|||||||
@ -1069,7 +1069,9 @@ QR =
|
|||||||
recaptcha_challenge_field: challenge
|
recaptcha_challenge_field: challenge
|
||||||
recaptcha_response_field: response
|
recaptcha_response_field: response
|
||||||
|
|
||||||
callbacks =
|
options =
|
||||||
|
responseType: 'document'
|
||||||
|
withCredentials: true
|
||||||
onload: QR.response
|
onload: QR.response
|
||||||
onerror: ->
|
onerror: ->
|
||||||
# Connection error, or
|
# Connection error, or
|
||||||
@ -1079,9 +1081,11 @@ QR =
|
|||||||
QR.cooldown.auto = false
|
QR.cooldown.auto = false
|
||||||
QR.status()
|
QR.status()
|
||||||
QR.error $.el 'span',
|
QR.error $.el 'span',
|
||||||
innerHTML: "Connection error. You may have been <a href=//www.4chan.org/banned target=_blank>banned</a>.\n[<a href='https://github.com/seaweedchan/4chan-x/wiki/Frequently-Asked-Questions#what-does-4chan-x-encountered-an-error-while-posting-please-try-again-mean' target=_blank>?</a>]"
|
innerHTML: """
|
||||||
opts =
|
Connection error. You may have been <a href=//www.4chan.org/banned target=_blank>banned</a>.
|
||||||
cred: true
|
[<a href="https://github.com/seaweedchan/4chan-x/wiki/Frequently-Asked-Questions#what-does-4chan-x-encountered-an-error-while-posting-please-try-again-mean" target=_blank>?</a>]
|
||||||
|
"""
|
||||||
|
extra =
|
||||||
form: $.formData postData
|
form: $.formData postData
|
||||||
upCallbacks:
|
upCallbacks:
|
||||||
onload: ->
|
onload: ->
|
||||||
@ -1095,7 +1099,7 @@ QR =
|
|||||||
QR.req.progress = "#{Math.round e.loaded / e.total * 100}%"
|
QR.req.progress = "#{Math.round e.loaded / e.total * 100}%"
|
||||||
QR.status()
|
QR.status()
|
||||||
|
|
||||||
QR.req = $.ajax $.id('postForm').parentNode.action, callbacks, opts
|
QR.req = $.ajax $.id('postForm').parentNode.action, options, extra
|
||||||
# Starting to upload might take some time.
|
# Starting to upload might take some time.
|
||||||
# Provide some feedback that we're starting to submit.
|
# Provide some feedback that we're starting to submit.
|
||||||
QR.req.uploadStartTime = Date.now()
|
QR.req.uploadStartTime = Date.now()
|
||||||
@ -1109,20 +1113,23 @@ QR =
|
|||||||
post = QR.posts[0]
|
post = QR.posts[0]
|
||||||
post.unlock()
|
post.unlock()
|
||||||
|
|
||||||
tmpDoc = d.implementation.createHTMLDocument ''
|
resDoc = req.response
|
||||||
tmpDoc.documentElement.innerHTML = req.response
|
if ban = $ '.banType', resDoc # banned/warning
|
||||||
if ban = $ '.banType', tmpDoc # banned/warning
|
board = $('.board', resDoc).innerHTML
|
||||||
board = $('.board', tmpDoc).innerHTML
|
|
||||||
err = $.el 'span', innerHTML:
|
err = $.el 'span', innerHTML:
|
||||||
if ban.textContent.toLowerCase() is 'banned'
|
if ban.textContent.toLowerCase() is 'banned'
|
||||||
"You are banned on #{board}! ;_;<br>" +
|
"""
|
||||||
"Click <a href=//www.4chan.org/banned target=_blank>here</a> to see the reason."
|
You are banned on #{board}! ;_;<br>
|
||||||
|
Click <a href=//www.4chan.org/banned target=_blank>here</a> to see the reason.
|
||||||
|
"""
|
||||||
else
|
else
|
||||||
"You were issued a warning on #{board} as #{$('.nameBlock', tmpDoc).innerHTML}.<br>" +
|
"""
|
||||||
"Reason: #{$('.reason', tmpDoc).innerHTML}"
|
You were issued a warning on #{board} as #{$('.nameBlock', resDoc).innerHTML}.<br>
|
||||||
else if err = tmpDoc.getElementById 'errmsg' # error!
|
Reason: #{$('.reason', resDoc).innerHTML}
|
||||||
|
"""
|
||||||
|
else if err = resDoc.getElementById 'errmsg' # error!
|
||||||
$('a', err)?.target = '_blank' # duplicate image link
|
$('a', err)?.target = '_blank' # duplicate image link
|
||||||
else if tmpDoc.title isnt 'Post successful!'
|
else if resDoc.title isnt 'Post successful!'
|
||||||
err = 'Connection error with sys.4chan.org.'
|
err = 'Connection error with sys.4chan.org.'
|
||||||
else if req.status isnt 200
|
else if req.status isnt 200
|
||||||
err = "Error #{req.statusText} (#{req.status})"
|
err = "Error #{req.statusText} (#{req.status})"
|
||||||
@ -1156,8 +1163,8 @@ QR =
|
|||||||
QR.error err
|
QR.error err
|
||||||
return
|
return
|
||||||
|
|
||||||
|
h1 = $ 'h1', resDoc
|
||||||
QR.cleanNotifications()
|
QR.cleanNotifications()
|
||||||
h1 = $ 'h1', tmpDoc
|
|
||||||
|
|
||||||
if Conf['Posting Success Notifications']
|
if Conf['Posting Success Notifications']
|
||||||
QR.notifications.push new Notification 'success', h1.textContent, 5
|
QR.notifications.push new Notification 'success', h1.textContent, 5
|
||||||
|
|||||||
@ -42,7 +42,7 @@ QuoteBacklink =
|
|||||||
$.on link, 'mouseover', QuotePreview.mouseover
|
$.on link, 'mouseover', QuotePreview.mouseover
|
||||||
if Conf['Quote Inlining']
|
if Conf['Quote Inlining']
|
||||||
$.on link, 'click', QuoteInline.toggle
|
$.on link, 'click', QuoteInline.toggle
|
||||||
frag.pushArrays QuoteInline.qiQuote link, $.hasClass link, 'filtered' if Conf['Quote Hash Navigation']
|
frag.push.apply frag, QuoteInline.qiQuote link, $.hasClass link, 'filtered' if Conf['Quote Hash Navigation']
|
||||||
$.add container, frag
|
$.add container, frag
|
||||||
return
|
return
|
||||||
secondNode: ->
|
secondNode: ->
|
||||||
|
|||||||
@ -2,9 +2,6 @@ QuoteInline =
|
|||||||
init: ->
|
init: ->
|
||||||
return if g.VIEW is 'catalog' or !Conf['Quote Inlining']
|
return if g.VIEW is 'catalog' or !Conf['Quote Inlining']
|
||||||
|
|
||||||
if Conf['Comment Expansion']
|
|
||||||
ExpandComment.callbacks.push @node
|
|
||||||
|
|
||||||
if Conf['Quote Hash Navigation']
|
if Conf['Quote Hash Navigation']
|
||||||
@node = ->
|
@node = ->
|
||||||
for link in @nodes.quotelinks.concat [@nodes.backlinks...]
|
for link in @nodes.quotelinks.concat [@nodes.backlinks...]
|
||||||
@ -18,6 +15,9 @@ QuoteInline =
|
|||||||
$.on link, 'click', QuoteInline.toggle
|
$.on link, 'click', QuoteInline.toggle
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if Conf['Comment Expansion']
|
||||||
|
ExpandComment.callbacks.push @node
|
||||||
|
|
||||||
Post::callbacks.push
|
Post::callbacks.push
|
||||||
name: 'Quote Inlining'
|
name: 'Quote Inlining'
|
||||||
cb: @node
|
cb: @node
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user