remove [].contains. It was a bad idea.

I shouldn't be messing with stuff like this without a really good
reason for doing so, and the longer I thought about it, the more
it occurred to me that I didn't have one.
This commit is contained in:
Zixaphir 2013-12-24 14:40:03 -07:00
parent cfb883d8da
commit 91233b8d61
26 changed files with 223 additions and 255 deletions

View File

@ -1,5 +1,5 @@
/*
* 4chan X - Version 1.2.44 - 2013-12-21
* 4chan X - Version 1.2.44 - 2013-12-24
*
* Licensed under the MIT license.
* https://github.com/seaweedchan/4chan-x/blob/master/LICENSE

View File

@ -22,7 +22,7 @@
// ==/UserScript==
/*
* 4chan X - Version 1.2.44 - 2013-12-21
* 4chan X - Version 1.2.44 - 2013-12-24
*
* Licensed under the MIT license.
* https://github.com/seaweedchan/4chan-x/blob/master/LICENSE
@ -105,11 +105,11 @@
(function() {
var $, $$, Anonymize, ArchiveLink, AutoGIF, Banner, Board, Build, CatalogLinks, Clone, Conf, Config, CustomCSS, DataBoard, DeleteLink, Dice, DownloadLink, Emoji, ExpandComment, ExpandThread, FappeTyme, Favicon, FileInfo, Filter, Fourchan, Gallery, Get, Header, IDColor, ImageExpand, ImageHover, ImageLoader, Index, InfiniScroll, Keybinds, Linkify, Main, Menu, Nav, Notice, PSAHiding, Polyfill, Post, PostHiding, QR, QuoteBacklink, QuoteCT, QuoteInline, QuoteOP, QuotePreview, QuoteStrikeThrough, QuoteThreading, QuoteYou, Quotify, Recursive, Redirect, RelativeDates, RemoveSpoilers, Report, ReportLink, RevealSpoilers, Sauce, Settings, Thread, ThreadExcerpt, ThreadHiding, ThreadStats, ThreadUpdater, ThreadWatcher, Time, UI, Unread, c, d, doc, g,
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; },
__slice = [].slice,
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
Config = {
main: {
@ -352,24 +352,12 @@
posts: {}
};
String.prototype.capitalize = function() {
return this.charAt(0).toUpperCase() + this.slice(1);
};
String.prototype.contains = function(string) {
return this.indexOf(string) > -1;
};
Array.prototype.contains = function(object) {
return this.indexOf(object) > -1;
};
Array.prototype.indexOf = function(object) {
Array.prototype.indexOf = function(val) {
var i;
i = this.length;
while (i--) {
if (this[i] === object) {
if (this[i] === val) {
return i;
}
}
@ -383,15 +371,14 @@
return root.querySelector(selector);
};
$.extend = function(object, properties) {
$.extend = function(obj, prop) {
var key, val;
for (key in properties) {
val = properties[key];
if (!properties.hasOwnProperty(key)) {
continue;
for (key in prop) {
val = prop[key];
if (prop.hasOwnProperty(key)) {
obj[key] = val;
}
object[key] = val;
}
};
@ -571,7 +558,7 @@
};
$.hasClass = function(el, className) {
return el.classList.contains(className);
return __indexOf.call(el.classList, className) >= 0;
};
$.rm = (function() {
@ -1063,7 +1050,7 @@
return;
}
fullID = "" + match[1] + "." + match[2];
if (!this.quotes.contains(fullID)) {
if (__indexOf.call(this.quotes, fullID) < 0) {
return this.quotes.push(fullID);
}
};
@ -2965,38 +2952,38 @@
};
},
allQuotelinksLinkingTo: function(post) {
var ID, quote, quotedPost, quotelinks, quoterPost, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2, _ref3;
var ID, quote, quotedPost, quotelinks, quoterPost, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2, _ref3, _ref4;
quotelinks = [];
_ref = g.posts;
for (ID in _ref) {
quoterPost = _ref[ID];
if (quoterPost.quotes.contains(post.fullID)) {
_ref1 = [quoterPost].concat(quoterPost.clones);
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
quoterPost = _ref1[_i];
if (_ref1 = post.fullID, __indexOf.call(quoterPost.quotes, _ref1) >= 0) {
_ref2 = [quoterPost].concat(quoterPost.clones);
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
quoterPost = _ref2[_i];
quotelinks.push.apply(quotelinks, quoterPost.nodes.quotelinks);
}
}
}
if (Conf['Quote Backlinks']) {
_ref2 = post.quotes;
for (_j = 0, _len1 = _ref2.length; _j < _len1; _j++) {
quote = _ref2[_j];
_ref3 = post.quotes;
for (_j = 0, _len1 = _ref3.length; _j < _len1; _j++) {
quote = _ref3[_j];
if (!(quotedPost = g.posts[quote])) {
continue;
}
_ref3 = [quotedPost].concat(quotedPost.clones);
for (_k = 0, _len2 = _ref3.length; _k < _len2; _k++) {
quotedPost = _ref3[_k];
_ref4 = [quotedPost].concat(quotedPost.clones);
for (_k = 0, _len2 = _ref4.length; _k < _len2; _k++) {
quotedPost = _ref4[_k];
quotelinks.push.apply(quotelinks, __slice.call(quotedPost.nodes.backlinks));
}
}
}
return quotelinks.filter(function(quotelink) {
var boardID, postID, _ref4;
var boardID, postID, _ref5;
_ref4 = Get.postDataFromLink(quotelink), boardID = _ref4.boardID, postID = _ref4.postID;
_ref5 = Get.postDataFromLink(quotelink), boardID = _ref5.boardID, postID = _ref5.postID;
return boardID === post.board.ID && postID === post.ID;
});
},
@ -3045,7 +3032,7 @@
return;
}
status = req.status;
if (![200, 304].contains(status)) {
if (status !== 200 && status !== 304) {
if (url = Redirect.to('post', {
boardID: boardID,
postID: postID
@ -3575,7 +3562,9 @@
}
$.on(root, 'mousemove', o.hover);
o.workaround = function(e) {
if (!root.contains(e.target)) {
var _ref;
if (_ref = e.target, __indexOf.call(root, _ref) < 0) {
return o.hoverend();
}
};
@ -3649,7 +3638,7 @@
Filter = {
filters: {},
init: function() {
var boards, err, filter, hl, key, op, regexp, stub, top, _i, _len, _ref, _ref1, _ref2, _ref3, _ref4;
var boards, err, filter, hl, key, op, regexp, stub, top, _i, _len, _ref, _ref1, _ref2, _ref3, _ref4, _ref5;
if (g.VIEW === 'catalog' || !Conf['Filter']) {
return;
@ -3670,10 +3659,10 @@
}
filter = filter.replace(regexp[0], '');
boards = ((_ref1 = filter.match(/boards:([^;]+)/)) != null ? _ref1[1].toLowerCase() : void 0) || 'global';
if (boards !== 'global' && !(boards.split(',')).contains(g.BOARD.ID)) {
if (boards !== 'global' && (_ref2 = !g.BOARD.ID, __indexOf.call(boards.split(','), _ref2) >= 0)) {
continue;
}
if (['uniqueID', 'MD5'].contains(key)) {
if (key === 'uniqueID' || key === 'MD5') {
regexp = regexp[1];
} else {
try {
@ -3684,11 +3673,11 @@
continue;
}
}
op = ((_ref2 = filter.match(/[^t]op:(yes|no|only)/)) != null ? _ref2[1] : void 0) || 'yes';
op = ((_ref3 = filter.match(/[^t]op:(yes|no|only)/)) != null ? _ref3[1] : void 0) || 'yes';
stub = (function() {
var _ref3;
var _ref4;
switch ((_ref3 = filter.match(/stub:(yes|no)/)) != null ? _ref3[1] : void 0) {
switch ((_ref4 = filter.match(/stub:(yes|no)/)) != null ? _ref4[1] : void 0) {
case 'yes':
return true;
case 'no':
@ -3698,8 +3687,8 @@
}
})();
if (hl = /highlight/.test(filter)) {
hl = ((_ref3 = filter.match(/highlight:(\w+)/)) != null ? _ref3[1] : void 0) || 'filter-highlight';
top = ((_ref4 = filter.match(/top:(yes|no)/)) != null ? _ref4[1] : void 0) || 'yes';
hl = ((_ref4 = filter.match(/highlight:(\w+)/)) != null ? _ref4[1] : void 0) || 'filter-highlight';
top = ((_ref5 = filter.match(/top:(yes|no)/)) != null ? _ref5[1] : void 0) || 'yes';
top = top === 'yes';
}
this.filters[key].push(this.createFilter(regexp, op, stub, hl, top));
@ -3897,7 +3886,7 @@
type = this.dataset.type;
value = Filter[type](Filter.menu.post);
re = ['uniqueID', 'MD5'].contains(type) ? value : value.replace(/\/|\\|\^|\$|\n|\.|\(|\)|\{|\}|\[|\]|\?|\*|\+|\|/g, function(c) {
re = type === 'uniqueID' || type === 'MD5' ? value : value.replace(/\/|\\|\^|\$|\n|\.|\(|\)|\{|\}|\[|\]|\?|\*|\+|\|/g, function(c) {
if (c === '\n') {
return '\\n';
} else if (c === '\\') {
@ -3906,7 +3895,7 @@
return "\\" + c;
}
});
re = ['uniqueID', 'MD5'].contains(type) ? "/" + re + "/" : "/^" + re + "$/";
re = type === 'uniqueID' || type === 'MD5' ? "/" + re + "/" : "/^" + re + "$/";
return $.get(type, Conf[type], function(item) {
var save, section, select, ta, tl;
@ -4296,7 +4285,7 @@
_ref = g.posts;
for (ID in _ref) {
post = _ref[ID];
if (post.quotes.contains(fullID)) {
if (__indexOf.call(post.quotes, fullID) >= 0) {
recursive.apply(null, [post].concat(__slice.call(args)));
}
}
@ -4331,7 +4320,7 @@
return $.prepend(this.OP.nodes.root, ThreadHiding.makeButton(this, 'hide'));
},
onIndexBuild: function(_arg) {
var i, nodes, root, thread, _i, _len;
var i, nodes, root, thread, _i, _len, _ref;
nodes = _arg.detail;
for (i = _i = 0, _len = nodes.length; _i < _len; i = _i += 2) {
@ -4342,7 +4331,7 @@
}
if (!thread.stub) {
nodes[i + 1].hidden = true;
} else if (!root.contains(thread.stub)) {
} else if (_ref = thread.stub, __indexOf.call(root, _ref) < 0) {
ThreadHiding.makeStub(thread, root);
}
}
@ -4857,7 +4846,7 @@
});
},
node: function() {
var boardID, fullID, i, postID, quotelink, quotelinks, quotes, _ref;
var boardID, fullID, i, postID, quotelink, quotelinks, quotes, _ref, _ref1;
if (this.isClone && this.thread === this.context.thread) {
return;
@ -4866,19 +4855,19 @@
return;
}
quotelinks = this.nodes.quotelinks;
if (this.isClone && quotes.contains(this.thread.fullID)) {
if (this.isClone && (_ref = this.thread.fullID, __indexOf.call(quotes, _ref) >= 0)) {
i = 0;
while (quotelink = quotelinks[i++]) {
quotelink.textContent = quotelink.textContent.replace(QuoteOP.text, '');
}
}
fullID = (this.isClone ? this.context : this).thread.fullID;
if (!quotes.contains(fullID)) {
if (__indexOf.call(quotes, fullID) < 0) {
return;
}
i = 0;
while (quotelink = quotelinks[i++]) {
_ref = Get.postDataFromLink(quotelink), boardID = _ref.boardID, postID = _ref.postID;
_ref1 = Get.postDataFromLink(quotelink), boardID = _ref1.boardID, postID = _ref1.postID;
if (("" + boardID + "." + postID) === fullID) {
$.add(quotelink, $.tn(QuoteOP.text));
}
@ -5083,7 +5072,7 @@
if (QuoteThreading.hasRun) {
height = doc.clientHeight;
_ref = qpost.nodes.root.getBoundingClientRect(), bottom = _ref.bottom, top = _ref.top;
if (!(Unread.posts.contains(qpost) || ((bottom < height) && (top > 0)))) {
if (!(__indexOf.call(Unread.posts, qpost) >= 0 || ((bottom < height) && (top > 0)))) {
return false;
}
}
@ -5320,12 +5309,11 @@
});
}
}
if (!this.quotes.contains(quoteID)) {
if (__indexOf.call(this.quotes, quoteID) < 0) {
this.quotes.push(quoteID);
}
if (!a) {
deadlink.textContent = "" + quote + "\u00A0(Dead)";
return;
return deadlink.textContent = "" + quote + "\u00A0(Dead)";
}
$.replace(deadlink, a);
if ($.hasClass(a, 'quotelink')) {
@ -5706,7 +5694,7 @@
var embed, file, files, status, type, _i, _j, _len, _len1, _ref;
status = this.status;
if (![200, 304].contains(status)) {
if (status !== 200 && status !== 304) {
return div.innerHTML = "ERROR " + status;
}
files = JSON.parse(this.response).files;
@ -6151,7 +6139,7 @@
});
},
parseItem: function(item, types) {
var boards, match, type, val, _ref, _ref1;
var boards, match, type, val, _ref, _ref1, _ref2;
if (item[0] === '#') {
return;
@ -6162,7 +6150,7 @@
_ref = match, match = _ref[0], type = _ref[1], val = _ref[2];
item = item.replace(match, '');
boards = ((_ref1 = item.match(/boards:([^;]+)/i)) != null ? _ref1[1].toLowerCase() : void 0) || 'global';
if (boards !== 'global' && !((boards.split(',')).contains(g.BOARD.ID))) {
if (boards !== 'global' && (_ref2 = !g.BOARD.ID, __indexOf.call(boards.split(','), _ref2) >= 0)) {
return;
}
if (type === 'password') {
@ -6175,7 +6163,7 @@
if (/always/i.test(item)) {
QR.persona.always[type] = val;
}
if (!types[type].contains(val)) {
if (__indexOf.call(types[type], val) < 0) {
return types[type].push(val);
}
},
@ -6473,12 +6461,12 @@
}
},
handleFile: function(file, isSingle, max) {
var post;
var post, _ref;
if (file.size > max) {
QR.error("" + file.name + ": File too large (file: " + ($.bytesToString(file.size)) + ", max: " + ($.bytesToString(max)) + ").");
return;
} else if (!QR.mimeTypes.contains(file.type)) {
} else if (_ref = file.type, __indexOf.call(QR.mimeTypes, _ref) < 0) {
if (!/^text/.test(file.type)) {
QR.error("" + file.name + ": Unsupported file type.");
return;
@ -6499,6 +6487,8 @@
return post.setFile(file);
},
openFileInput: function(e) {
var _ref;
e.stopPropagation();
if (e.shiftKey && e.type === 'click') {
return QR.selected.rmFile();
@ -6510,7 +6500,7 @@
return $.rmClass(QR.nodes.filename, 'edit');
});
}
if (e.target.nodeName === 'INPUT' || (e.keyCode && ![32, 13].contains(e.keyCode)) || e.ctrlKey) {
if (e.target.nodeName === 'INPUT' || (e.keyCode && ((_ref = !e.keyCode) === 32 || _ref === 13)) || e.ctrlKey) {
return;
}
e.preventDefault();
@ -7804,7 +7794,7 @@
innerHTML: "<input type=checkbox name='" + name + "'> " + name
});
input = label.firstElementChild;
if (['Fit Width', 'Fit Height', 'Hide Thumbnails'].contains(name)) {
if (name === 'Fit Width' || name === 'Fit Height' || name === 'Hide Thumbnails') {
$.on(input, 'change', Gallery.cb.setFitness);
}
input.checked = Conf[name];
@ -7861,7 +7851,7 @@
return ImageExpand.toggle(Get.postFromNode(this));
},
toggleAll: function() {
var ID, file, func, post, _i, _len, _ref, _ref1;
var ID, file, func, post, _i, _len, _ref, _ref1, _ref2;
$.event('CloseMenu');
if (ImageExpand.on = $.hasClass(ImageExpand.EAI, 'expand-all-shortcut')) {
@ -7880,7 +7870,7 @@
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
post = _ref1[_i];
file = post.file;
if (!(file && file.isImage && doc.contains(post.nodes.root))) {
if (!(file && file.isImage && (_ref2 = post.nodes.root, __indexOf.call(doc, _ref2) >= 0))) {
continue;
}
if (ImageExpand.on && (!Conf['Expand spoilers'] && file.isSpoiler || Conf['Expand from here'] && Header.getTopOf(file.thumb) < 0)) {
@ -8124,7 +8114,7 @@
var URL, post, src, timeoutID,
_this = this;
if (!doc.contains(this)) {
if (__indexOf.call(doc, this) < 0) {
return;
}
post = g.posts[this.dataset.fullID];
@ -9130,12 +9120,12 @@
for (ID in _ref) {
post = _ref[ID];
ID = +ID;
if (post.isDead && index.contains(ID)) {
post.resurrect();
} else if (!index.contains(ID)) {
if (__indexOf.call(index, ID) < 0) {
post.kill();
deletedPosts.push(post);
} else if (post.file && !post.file.isDead && !files.contains(ID)) {
} else if (post.isDead) {
post.resurrect();
} else if (post.file && !(post.file.isDead && __indexOf.call(files, ID) >= 0)) {
post.kill(true);
deletedFiles.push(post);
}
@ -9815,7 +9805,7 @@
return Unread.update();
},
addPosts: function(posts) {
var ID, data, post, _i, _len;
var ID, data, post, _i, _len, _ref;
for (_i = 0, _len = posts.length; _i < _len; _i++) {
post = posts[_i];
@ -9837,7 +9827,7 @@
Unread.addPostQuotingYou(post);
}
if (Conf['Unread Line']) {
Unread.setLine(posts.contains(Unread.posts[0]));
Unread.setLine((_ref = Unread.posts[0], __indexOf.call(posts, _ref) >= 0));
}
Unread.read();
return Unread.update();
@ -10002,7 +9992,7 @@
file: {}
},
init: function() {
var archive, boardID, boards, data, id, name, type, _i, _len, _ref, _ref1, _ref2;
var archive, boardID, boards, data, id, name, type, _i, _len, _ref, _ref1, _ref2, _ref3;
_ref = Conf['selectedArchives'];
for (boardID in _ref) {
@ -10011,7 +10001,7 @@
id = data[type];
if (archive = Redirect.archives[id]) {
boards = archive[type] || archive['boards'];
if (!boards.contains(boardID)) {
if (__indexOf.call(boards, boardID) < 0) {
continue;
}
Redirect.data[type][boardID] = archive;
@ -10030,7 +10020,7 @@
if (!(boardID in Redirect.data.post || archive.software !== 'foolfuuka')) {
Redirect.data.post[boardID] = archive;
}
if (!(boardID in Redirect.data.file || !archive.files.contains(boardID))) {
if (!(boardID in Redirect.data.file || (_ref3 = !boardID, __indexOf.call(archive.files, _ref3) >= 0))) {
Redirect.data.file[boardID] = archive;
}
}
@ -10394,7 +10384,7 @@
return CatalogLinks.set(this.checked);
},
set: function(useCatalog) {
var a, board, generateURL, path, _i, _len, _ref;
var a, board, generateURL, path, _i, _len, _ref, _ref1;
path = useCatalog ? 'catalog' : '';
generateURL = useCatalog && Conf['External Catalog'] ? CatalogLinks.external : function(board) {
@ -10403,7 +10393,7 @@
_ref = $$("#board-list a:not(.catalog), #boardNavDesktopFoot a");
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
a = _ref[_i];
if (!['boards.4chan.org', 'catalog.neet.tv', '4index.gropes.us'].contains(a.hostname) || !(board = a.pathname.split('/')[1]) || ['f', 'status', '4chan'].contains(board)) {
if (((_ref1 = !a.hostname) === 'boards.4chan.org' || _ref1 === 'catalog.neet.tv' || _ref1 === '4index.gropes.us') || !(board = a.pathname.split('/')[1]) || (board === 'f' || board === 'status' || board === '4chan')) {
continue;
}
a.href = generateURL(board);
@ -10634,7 +10624,7 @@
var callback, clone, comment, href, postObj, posts, quote, spoilerRange, status, _i, _j, _k, _len, _len1, _len2, _ref, _ref1;
status = req.status;
if (![200, 304].contains(status)) {
if (status !== 200 && status !== 304) {
a.textContent = "Error " + req.statusText + " (" + status + ")";
return;
}
@ -11243,13 +11233,13 @@
return Conf[hotkey] = key;
},
keydown: function(e) {
var key, notification, notifications, op, target, thread, threadRoot, _i, _len;
var key, notification, notifications, op, target, thread, threadRoot, _i, _len, _ref;
if (!(key = Keybinds.keyCode(e))) {
return;
}
target = e.target;
if (['INPUT', 'TEXTAREA'].contains(target.nodeName)) {
if ((_ref = target.nodeName) === 'INPUT' || _ref === 'TEXTAREA') {
if (!/(Esc|Alt|Ctrl|Meta|Shift\+\w{2,})/.test(key)) {
return;
}
@ -12350,7 +12340,7 @@
input = $("[name=" + name + "]", section);
items[name] = Conf[name];
inputs[name] = input;
event = ['favicon', 'usercss', 'sageEmoji', 'emojiPos'].contains(name) ? 'change' : 'input';
event = name === 'favicon' || name === 'usercss' || name === 'sageEmoji' || name === 'emojiPos' ? 'change' : 'input';
$.on(input, event, $.cb.value);
}
ta = $('.personafield', section);
@ -12363,7 +12353,7 @@
for (key in items) {
val = items[key];
if (['emojiPos'].contains(key)) {
if (key === 'emojiPos') {
continue;
}
input = inputs[key];
@ -12394,7 +12384,7 @@
if (archive.software === 'foolfuuka') {
data.post.push(name);
}
if (archive.files.contains(boardID)) {
if (__indexOf.call(archive.files, boardID) >= 0) {
data.file.push(name);
}
}
@ -12648,9 +12638,9 @@
return;
case 'i.4cdn.org':
$.ready(function() {
var URL;
var URL, _ref1;
if (Conf['404 Redirect'] && ['4chan - Temporarily Offline', '4chan - 404 Not Found'].contains(d.title)) {
if (Conf['404 Redirect'] && ((_ref1 = d.title) === '4chan - Temporarily Offline' || _ref1 === '4chan - 404 Not Found')) {
Redirect.init();
pathname = location.pathname.split('/');
URL = Redirect.to('file', {
@ -12790,9 +12780,9 @@
});
},
initReady: function() {
var GMver, err, errors, href, i, passLink, postRoot, posts, styleSelector, thread, threadRoot, v, _i, _j, _len, _len1, _ref, _ref1;
var GMver, err, errors, href, i, passLink, postRoot, posts, styleSelector, thread, threadRoot, v, _i, _j, _len, _len1, _ref, _ref1, _ref2;
if (['4chan - Temporarily Offline', '4chan - 404 Not Found'].contains(d.title)) {
if ((_ref = d.title) === '4chan - Temporarily Offline' || _ref === '4chan - 404 Not Found') {
if (Conf['404 Redirect'] && g.VIEW === 'thread') {
href = Redirect.to('thread', {
boardID: g.BOARD.ID,
@ -12807,9 +12797,9 @@
if (g.VIEW === 'thread' && (threadRoot = $('.thread'))) {
thread = new Thread(+threadRoot.id.slice(1), g.BOARD);
posts = [];
_ref = $$('.thread > .postContainer', threadRoot);
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
postRoot = _ref[_i];
_ref1 = $$('.thread > .postContainer', threadRoot);
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
postRoot = _ref1[_i];
try {
posts.push(new Post(postRoot, thread, g.BOARD));
} catch (_error) {
@ -12843,9 +12833,9 @@
return;
}
GMver = GM_info.version.split('.');
_ref1 = "1.12".split('.');
for (i = _j = 0, _len1 = _ref1.length; _j < _len1; i = ++_j) {
v = _ref1[i];
_ref2 = "1.12".split('.');
for (i = _j = 0, _len1 = _ref2.length; _j < _len1; i = ++_j) {
v = _ref2[i];
if (v < GMver[i]) {
break;
}

View File

@ -1,6 +1,6 @@
// Generated by CoffeeScript
/*
* 4chan X - Version 1.2.44 - 2013-12-21
* 4chan X - Version 1.2.44 - 2013-12-24
*
* Licensed under the MIT license.
* https://github.com/seaweedchan/4chan-x/blob/master/LICENSE
@ -83,8 +83,8 @@
(function() {
var $, $$, Anonymize, ArchiveLink, AutoGIF, Banner, Board, Build, CatalogLinks, Clone, Conf, Config, CustomCSS, DataBoard, DeleteLink, Dice, DownloadLink, Emoji, ExpandComment, ExpandThread, FappeTyme, Favicon, FileInfo, Filter, Fourchan, Gallery, Get, Header, IDColor, ImageExpand, ImageHover, ImageLoader, Index, InfiniScroll, Keybinds, Linkify, Main, Menu, Nav, Notice, PSAHiding, Polyfill, Post, PostHiding, QR, QuoteBacklink, QuoteCT, QuoteInline, QuoteOP, QuotePreview, QuoteStrikeThrough, QuoteThreading, QuoteYou, Quotify, Recursive, Redirect, RelativeDates, RemoveSpoilers, Report, ReportLink, RevealSpoilers, Sauce, Settings, Thread, ThreadExcerpt, ThreadHiding, ThreadStats, ThreadUpdater, ThreadWatcher, Time, UI, Unread, c, d, doc, g,
__slice = [].slice,
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; },
__slice = [].slice,
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
@ -330,24 +330,12 @@
posts: {}
};
String.prototype.capitalize = function() {
return this.charAt(0).toUpperCase() + this.slice(1);
};
String.prototype.contains = function(string) {
return this.indexOf(string) > -1;
};
Array.prototype.contains = function(object) {
return this.indexOf(object) > -1;
};
Array.prototype.indexOf = function(object) {
Array.prototype.indexOf = function(val) {
var i;
i = this.length;
while (i--) {
if (this[i] === object) {
if (this[i] === val) {
return i;
}
}
@ -361,15 +349,14 @@
return root.querySelector(selector);
};
$.extend = function(object, properties) {
$.extend = function(obj, prop) {
var key, val;
for (key in properties) {
val = properties[key];
if (!properties.hasOwnProperty(key)) {
continue;
for (key in prop) {
val = prop[key];
if (prop.hasOwnProperty(key)) {
obj[key] = val;
}
object[key] = val;
}
};
@ -549,7 +536,7 @@
};
$.hasClass = function(el, className) {
return el.classList.contains(className);
return __indexOf.call(el.classList, className) >= 0;
};
$.rm = (function() {
@ -1070,7 +1057,7 @@
return;
}
fullID = "" + match[1] + "." + match[2];
if (!this.quotes.contains(fullID)) {
if (__indexOf.call(this.quotes, fullID) < 0) {
return this.quotes.push(fullID);
}
};
@ -2977,38 +2964,38 @@
};
},
allQuotelinksLinkingTo: function(post) {
var ID, quote, quotedPost, quotelinks, quoterPost, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2, _ref3;
var ID, quote, quotedPost, quotelinks, quoterPost, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2, _ref3, _ref4;
quotelinks = [];
_ref = g.posts;
for (ID in _ref) {
quoterPost = _ref[ID];
if (quoterPost.quotes.contains(post.fullID)) {
_ref1 = [quoterPost].concat(quoterPost.clones);
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
quoterPost = _ref1[_i];
if (_ref1 = post.fullID, __indexOf.call(quoterPost.quotes, _ref1) >= 0) {
_ref2 = [quoterPost].concat(quoterPost.clones);
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
quoterPost = _ref2[_i];
quotelinks.push.apply(quotelinks, quoterPost.nodes.quotelinks);
}
}
}
if (Conf['Quote Backlinks']) {
_ref2 = post.quotes;
for (_j = 0, _len1 = _ref2.length; _j < _len1; _j++) {
quote = _ref2[_j];
_ref3 = post.quotes;
for (_j = 0, _len1 = _ref3.length; _j < _len1; _j++) {
quote = _ref3[_j];
if (!(quotedPost = g.posts[quote])) {
continue;
}
_ref3 = [quotedPost].concat(quotedPost.clones);
for (_k = 0, _len2 = _ref3.length; _k < _len2; _k++) {
quotedPost = _ref3[_k];
_ref4 = [quotedPost].concat(quotedPost.clones);
for (_k = 0, _len2 = _ref4.length; _k < _len2; _k++) {
quotedPost = _ref4[_k];
quotelinks.push.apply(quotelinks, __slice.call(quotedPost.nodes.backlinks));
}
}
}
return quotelinks.filter(function(quotelink) {
var boardID, postID, _ref4;
var boardID, postID, _ref5;
_ref4 = Get.postDataFromLink(quotelink), boardID = _ref4.boardID, postID = _ref4.postID;
_ref5 = Get.postDataFromLink(quotelink), boardID = _ref5.boardID, postID = _ref5.postID;
return boardID === post.board.ID && postID === post.ID;
});
},
@ -3057,7 +3044,7 @@
return;
}
status = req.status;
if (![200, 304].contains(status)) {
if (status !== 200 && status !== 304) {
if (url = Redirect.to('post', {
boardID: boardID,
postID: postID
@ -3654,7 +3641,7 @@
Filter = {
filters: {},
init: function() {
var boards, err, filter, hl, key, op, regexp, stub, top, _i, _len, _ref, _ref1, _ref2, _ref3, _ref4;
var boards, err, filter, hl, key, op, regexp, stub, top, _i, _len, _ref, _ref1, _ref2, _ref3, _ref4, _ref5;
if (g.VIEW === 'catalog' || !Conf['Filter']) {
return;
@ -3675,10 +3662,10 @@
}
filter = filter.replace(regexp[0], '');
boards = ((_ref1 = filter.match(/boards:([^;]+)/)) != null ? _ref1[1].toLowerCase() : void 0) || 'global';
if (boards !== 'global' && !(boards.split(',')).contains(g.BOARD.ID)) {
if (boards !== 'global' && (_ref2 = !g.BOARD.ID, __indexOf.call(boards.split(','), _ref2) >= 0)) {
continue;
}
if (['uniqueID', 'MD5'].contains(key)) {
if (key === 'uniqueID' || key === 'MD5') {
regexp = regexp[1];
} else {
try {
@ -3689,11 +3676,11 @@
continue;
}
}
op = ((_ref2 = filter.match(/[^t]op:(yes|no|only)/)) != null ? _ref2[1] : void 0) || 'yes';
op = ((_ref3 = filter.match(/[^t]op:(yes|no|only)/)) != null ? _ref3[1] : void 0) || 'yes';
stub = (function() {
var _ref3;
var _ref4;
switch ((_ref3 = filter.match(/stub:(yes|no)/)) != null ? _ref3[1] : void 0) {
switch ((_ref4 = filter.match(/stub:(yes|no)/)) != null ? _ref4[1] : void 0) {
case 'yes':
return true;
case 'no':
@ -3703,8 +3690,8 @@
}
})();
if (hl = /highlight/.test(filter)) {
hl = ((_ref3 = filter.match(/highlight:(\w+)/)) != null ? _ref3[1] : void 0) || 'filter-highlight';
top = ((_ref4 = filter.match(/top:(yes|no)/)) != null ? _ref4[1] : void 0) || 'yes';
hl = ((_ref4 = filter.match(/highlight:(\w+)/)) != null ? _ref4[1] : void 0) || 'filter-highlight';
top = ((_ref5 = filter.match(/top:(yes|no)/)) != null ? _ref5[1] : void 0) || 'yes';
top = top === 'yes';
}
this.filters[key].push(this.createFilter(regexp, op, stub, hl, top));
@ -3902,7 +3889,7 @@
type = this.dataset.type;
value = Filter[type](Filter.menu.post);
re = ['uniqueID', 'MD5'].contains(type) ? value : value.replace(/\/|\\|\^|\$|\n|\.|\(|\)|\{|\}|\[|\]|\?|\*|\+|\|/g, function(c) {
re = type === 'uniqueID' || type === 'MD5' ? value : value.replace(/\/|\\|\^|\$|\n|\.|\(|\)|\{|\}|\[|\]|\?|\*|\+|\|/g, function(c) {
if (c === '\n') {
return '\\n';
} else if (c === '\\') {
@ -3911,7 +3898,7 @@
return "\\" + c;
}
});
re = ['uniqueID', 'MD5'].contains(type) ? "/" + re + "/" : "/^" + re + "$/";
re = type === 'uniqueID' || type === 'MD5' ? "/" + re + "/" : "/^" + re + "$/";
return $.get(type, Conf[type], function(item) {
var save, section, select, ta, tl;
@ -4301,7 +4288,7 @@
_ref = g.posts;
for (ID in _ref) {
post = _ref[ID];
if (post.quotes.contains(fullID)) {
if (__indexOf.call(post.quotes, fullID) >= 0) {
recursive.apply(null, [post].concat(__slice.call(args)));
}
}
@ -4336,7 +4323,7 @@
return $.prepend(this.OP.nodes.root, ThreadHiding.makeButton(this, 'hide'));
},
onIndexBuild: function(_arg) {
var i, nodes, root, thread, _i, _len;
var i, nodes, root, thread, _i, _len, _ref;
nodes = _arg.detail;
for (i = _i = 0, _len = nodes.length; _i < _len; i = _i += 2) {
@ -4347,7 +4334,7 @@
}
if (!thread.stub) {
nodes[i + 1].hidden = true;
} else if (!root.contains(thread.stub)) {
} else if (_ref = thread.stub, __indexOf.call(root, _ref) < 0) {
ThreadHiding.makeStub(thread, root);
}
}
@ -4862,7 +4849,7 @@
});
},
node: function() {
var boardID, fullID, i, postID, quotelink, quotelinks, quotes, _ref;
var boardID, fullID, i, postID, quotelink, quotelinks, quotes, _ref, _ref1;
if (this.isClone && this.thread === this.context.thread) {
return;
@ -4871,19 +4858,19 @@
return;
}
quotelinks = this.nodes.quotelinks;
if (this.isClone && quotes.contains(this.thread.fullID)) {
if (this.isClone && (_ref = this.thread.fullID, __indexOf.call(quotes, _ref) >= 0)) {
i = 0;
while (quotelink = quotelinks[i++]) {
quotelink.textContent = quotelink.textContent.replace(QuoteOP.text, '');
}
}
fullID = (this.isClone ? this.context : this).thread.fullID;
if (!quotes.contains(fullID)) {
if (__indexOf.call(quotes, fullID) < 0) {
return;
}
i = 0;
while (quotelink = quotelinks[i++]) {
_ref = Get.postDataFromLink(quotelink), boardID = _ref.boardID, postID = _ref.postID;
_ref1 = Get.postDataFromLink(quotelink), boardID = _ref1.boardID, postID = _ref1.postID;
if (("" + boardID + "." + postID) === fullID) {
$.add(quotelink, $.tn(QuoteOP.text));
}
@ -5088,7 +5075,7 @@
if (QuoteThreading.hasRun) {
height = doc.clientHeight;
_ref = qpost.nodes.root.getBoundingClientRect(), bottom = _ref.bottom, top = _ref.top;
if (!(Unread.posts.contains(qpost) || ((bottom < height) && (top > 0)))) {
if (!(__indexOf.call(Unread.posts, qpost) >= 0 || ((bottom < height) && (top > 0)))) {
return false;
}
}
@ -5325,12 +5312,11 @@
});
}
}
if (!this.quotes.contains(quoteID)) {
if (__indexOf.call(this.quotes, quoteID) < 0) {
this.quotes.push(quoteID);
}
if (!a) {
deadlink.textContent = "" + quote + "\u00A0(Dead)";
return;
return deadlink.textContent = "" + quote + "\u00A0(Dead)";
}
$.replace(deadlink, a);
if ($.hasClass(a, 'quotelink')) {
@ -5711,7 +5697,7 @@
var embed, file, files, status, type, _i, _j, _len, _len1, _ref;
status = this.status;
if (![200, 304].contains(status)) {
if (status !== 200 && status !== 304) {
return div.innerHTML = "ERROR " + status;
}
files = JSON.parse(this.response).files;
@ -6161,7 +6147,7 @@
});
},
parseItem: function(item, types) {
var boards, match, type, val, _ref, _ref1;
var boards, match, type, val, _ref, _ref1, _ref2;
if (item[0] === '#') {
return;
@ -6172,7 +6158,7 @@
_ref = match, match = _ref[0], type = _ref[1], val = _ref[2];
item = item.replace(match, '');
boards = ((_ref1 = item.match(/boards:([^;]+)/i)) != null ? _ref1[1].toLowerCase() : void 0) || 'global';
if (boards !== 'global' && !((boards.split(',')).contains(g.BOARD.ID))) {
if (boards !== 'global' && (_ref2 = !g.BOARD.ID, __indexOf.call(boards.split(','), _ref2) >= 0)) {
return;
}
if (type === 'password') {
@ -6185,7 +6171,7 @@
if (/always/i.test(item)) {
QR.persona.always[type] = val;
}
if (!types[type].contains(val)) {
if (__indexOf.call(types[type], val) < 0) {
return types[type].push(val);
}
},
@ -6483,12 +6469,12 @@
}
},
handleFile: function(file, isSingle, max) {
var post;
var post, _ref;
if (file.size > max) {
QR.error("" + file.name + ": File too large (file: " + ($.bytesToString(file.size)) + ", max: " + ($.bytesToString(max)) + ").");
return;
} else if (!QR.mimeTypes.contains(file.type)) {
} else if (_ref = file.type, __indexOf.call(QR.mimeTypes, _ref) < 0) {
if (!/^text/.test(file.type)) {
QR.error("" + file.name + ": Unsupported file type.");
return;
@ -6509,6 +6495,8 @@
return post.setFile(file);
},
openFileInput: function(e) {
var _ref;
e.stopPropagation();
if (e.shiftKey && e.type === 'click') {
return QR.selected.rmFile();
@ -6520,7 +6508,7 @@
return $.rmClass(QR.nodes.filename, 'edit');
});
}
if (e.target.nodeName === 'INPUT' || (e.keyCode && ![32, 13].contains(e.keyCode)) || e.ctrlKey) {
if (e.target.nodeName === 'INPUT' || (e.keyCode && ((_ref = !e.keyCode) === 32 || _ref === 13)) || e.ctrlKey) {
return;
}
e.preventDefault();
@ -7789,7 +7777,7 @@
innerHTML: "<input type=checkbox name='" + name + "'> " + name
});
input = label.firstElementChild;
if (['Fit Width', 'Fit Height', 'Hide Thumbnails'].contains(name)) {
if (name === 'Fit Width' || name === 'Fit Height' || name === 'Hide Thumbnails') {
$.on(input, 'change', Gallery.cb.setFitness);
}
input.checked = Conf[name];
@ -7846,7 +7834,7 @@
return ImageExpand.toggle(Get.postFromNode(this));
},
toggleAll: function() {
var ID, file, func, post, _i, _len, _ref, _ref1;
var ID, file, func, post, _i, _len, _ref, _ref1, _ref2;
$.event('CloseMenu');
if (ImageExpand.on = $.hasClass(ImageExpand.EAI, 'expand-all-shortcut')) {
@ -7865,7 +7853,7 @@
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
post = _ref1[_i];
file = post.file;
if (!(file && file.isImage && doc.contains(post.nodes.root))) {
if (!(file && file.isImage && (_ref2 = post.nodes.root, __indexOf.call(doc, _ref2) >= 0))) {
continue;
}
if (ImageExpand.on && (!Conf['Expand spoilers'] && file.isSpoiler || Conf['Expand from here'] && Header.getTopOf(file.thumb) < 0)) {
@ -8109,7 +8097,7 @@
var URL, post, src, timeoutID,
_this = this;
if (!doc.contains(this)) {
if (__indexOf.call(doc, this) < 0) {
return;
}
post = g.posts[this.dataset.fullID];
@ -9115,12 +9103,12 @@
for (ID in _ref) {
post = _ref[ID];
ID = +ID;
if (post.isDead && index.contains(ID)) {
post.resurrect();
} else if (!index.contains(ID)) {
if (__indexOf.call(index, ID) < 0) {
post.kill();
deletedPosts.push(post);
} else if (post.file && !post.file.isDead && !files.contains(ID)) {
} else if (post.isDead) {
post.resurrect();
} else if (post.file && !(post.file.isDead && __indexOf.call(files, ID) >= 0)) {
post.kill(true);
deletedFiles.push(post);
}
@ -9800,7 +9788,7 @@
return Unread.update();
},
addPosts: function(posts) {
var ID, data, post, _i, _len;
var ID, data, post, _i, _len, _ref;
for (_i = 0, _len = posts.length; _i < _len; _i++) {
post = posts[_i];
@ -9822,7 +9810,7 @@
Unread.addPostQuotingYou(post);
}
if (Conf['Unread Line']) {
Unread.setLine(posts.contains(Unread.posts[0]));
Unread.setLine((_ref = Unread.posts[0], __indexOf.call(posts, _ref) >= 0));
}
Unread.read();
return Unread.update();
@ -9993,7 +9981,7 @@
file: {}
},
init: function() {
var archive, boardID, boards, data, id, name, type, _i, _len, _ref, _ref1, _ref2;
var archive, boardID, boards, data, id, name, type, _i, _len, _ref, _ref1, _ref2, _ref3;
_ref = Conf['selectedArchives'];
for (boardID in _ref) {
@ -10002,7 +9990,7 @@
id = data[type];
if (archive = Redirect.archives[id]) {
boards = archive[type] || archive['boards'];
if (!boards.contains(boardID)) {
if (__indexOf.call(boards, boardID) < 0) {
continue;
}
Redirect.data[type][boardID] = archive;
@ -10021,7 +10009,7 @@
if (!(boardID in Redirect.data.post || archive.software !== 'foolfuuka')) {
Redirect.data.post[boardID] = archive;
}
if (!(boardID in Redirect.data.file || !archive.files.contains(boardID))) {
if (!(boardID in Redirect.data.file || (_ref3 = !boardID, __indexOf.call(archive.files, _ref3) >= 0))) {
Redirect.data.file[boardID] = archive;
}
}
@ -10385,7 +10373,7 @@
return CatalogLinks.set(this.checked);
},
set: function(useCatalog) {
var a, board, generateURL, path, _i, _len, _ref;
var a, board, generateURL, path, _i, _len, _ref, _ref1;
path = useCatalog ? 'catalog' : '';
generateURL = useCatalog && Conf['External Catalog'] ? CatalogLinks.external : function(board) {
@ -10394,7 +10382,7 @@
_ref = $$("#board-list a:not(.catalog), #boardNavDesktopFoot a");
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
a = _ref[_i];
if (!['boards.4chan.org', 'catalog.neet.tv', '4index.gropes.us'].contains(a.hostname) || !(board = a.pathname.split('/')[1]) || ['f', 'status', '4chan'].contains(board)) {
if (((_ref1 = !a.hostname) === 'boards.4chan.org' || _ref1 === 'catalog.neet.tv' || _ref1 === '4index.gropes.us') || !(board = a.pathname.split('/')[1]) || (board === 'f' || board === 'status' || board === '4chan')) {
continue;
}
a.href = generateURL(board);
@ -10625,7 +10613,7 @@
var callback, clone, comment, href, postObj, posts, quote, spoilerRange, status, _i, _j, _k, _len, _len1, _len2, _ref, _ref1;
status = req.status;
if (![200, 304].contains(status)) {
if (status !== 200 && status !== 304) {
a.textContent = "Error " + req.statusText + " (" + status + ")";
return;
}
@ -11234,13 +11222,13 @@
return Conf[hotkey] = key;
},
keydown: function(e) {
var key, notification, notifications, op, target, thread, threadRoot, _i, _len;
var key, notification, notifications, op, target, thread, threadRoot, _i, _len, _ref;
if (!(key = Keybinds.keyCode(e))) {
return;
}
target = e.target;
if (['INPUT', 'TEXTAREA'].contains(target.nodeName)) {
if ((_ref = target.nodeName) === 'INPUT' || _ref === 'TEXTAREA') {
if (!/(Esc|Alt|Ctrl|Meta|Shift\+\w{2,})/.test(key)) {
return;
}
@ -12339,7 +12327,7 @@
input = $("[name=" + name + "]", section);
items[name] = Conf[name];
inputs[name] = input;
event = ['favicon', 'usercss', 'sageEmoji', 'emojiPos'].contains(name) ? 'change' : 'input';
event = name === 'favicon' || name === 'usercss' || name === 'sageEmoji' || name === 'emojiPos' ? 'change' : 'input';
$.on(input, event, $.cb.value);
}
ta = $('.personafield', section);
@ -12352,7 +12340,7 @@
for (key in items) {
val = items[key];
if (['emojiPos'].contains(key)) {
if (key === 'emojiPos') {
continue;
}
input = inputs[key];
@ -12383,7 +12371,7 @@
if (archive.software === 'foolfuuka') {
data.post.push(name);
}
if (archive.files.contains(boardID)) {
if (__indexOf.call(archive.files, boardID) >= 0) {
data.file.push(name);
}
}
@ -12637,9 +12625,9 @@
return;
case 'i.4cdn.org':
$.ready(function() {
var URL;
var URL, _ref1;
if (Conf['404 Redirect'] && ['4chan - Temporarily Offline', '4chan - 404 Not Found'].contains(d.title)) {
if (Conf['404 Redirect'] && ((_ref1 = d.title) === '4chan - Temporarily Offline' || _ref1 === '4chan - 404 Not Found')) {
Redirect.init();
pathname = location.pathname.split('/');
URL = Redirect.to('file', {
@ -12779,9 +12767,9 @@
});
},
initReady: function() {
var err, errors, href, passLink, postRoot, posts, styleSelector, thread, threadRoot, _i, _len, _ref;
var err, errors, href, passLink, postRoot, posts, styleSelector, thread, threadRoot, _i, _len, _ref, _ref1;
if (['4chan - Temporarily Offline', '4chan - 404 Not Found'].contains(d.title)) {
if ((_ref = d.title) === '4chan - Temporarily Offline' || _ref === '4chan - 404 Not Found') {
if (Conf['404 Redirect'] && g.VIEW === 'thread') {
href = Redirect.to('thread', {
boardID: g.BOARD.ID,
@ -12796,9 +12784,9 @@
if (g.VIEW === 'thread' && (threadRoot = $('.thread'))) {
thread = new Thread(+threadRoot.id.slice(1), g.BOARD);
posts = [];
_ref = $$('.thread > .postContainer', threadRoot);
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
postRoot = _ref[_i];
_ref1 = $$('.thread > .postContainer', threadRoot);
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
postRoot = _ref1[_i];
try {
posts.push(new Post(postRoot, thread, g.BOARD));
} catch (_error) {

View File

@ -9,7 +9,7 @@ Redirect =
for type, id of data
if archive = Redirect.archives[id]
boards = archive[type] or archive['boards']
continue unless boards.contains boardID
continue unless boardID in boards
Redirect.data[type][boardID] = archive
for name, archive of Redirect.archives
for boardID in archive.boards
@ -17,7 +17,7 @@ Redirect =
Redirect.data.thread[boardID] = archive
unless boardID of Redirect.data.post or archive.software isnt 'foolfuuka'
Redirect.data.post[boardID] = archive
unless boardID of Redirect.data.file or !archive.files.contains boardID
unless boardID of Redirect.data.file or not boardID in archive.files
Redirect.data.file[boardID] = archive
return

View File

@ -21,10 +21,10 @@ Filter =
# and it's not specifically applicable to the current board.
# Defaults to global.
boards = filter.match(/boards:([^;]+)/)?[1].toLowerCase() or 'global'
if boards isnt 'global' and not (boards.split ',').contains g.BOARD.ID
if boards isnt 'global' and not g.BOARD.ID in boards.split ','
continue
if ['uniqueID', 'MD5'].contains key
if key in ['uniqueID', 'MD5']
# MD5 filter will use strings instead of regular expressions.
regexp = regexp[1]
else
@ -218,7 +218,7 @@ Filter =
{type} = @dataset
# Convert value -> regexp, unless type is MD5
value = Filter[type] Filter.menu.post
re = if ['uniqueID', 'MD5'].contains type then value else value.replace ///
re = if type in ['uniqueID', 'MD5'] then value else value.replace ///
/
| \\
| \^
@ -243,7 +243,7 @@ Filter =
else
"\\#{c}"
re = if ['uniqueID', 'MD5'].contains type
re = if type in ['uniqueID', 'MD5']
"/#{re}/"
else
"/^#{re}$/"

View File

@ -33,6 +33,6 @@ Recursive =
apply: (recursive, post, args...) ->
{fullID} = post
for ID, post of g.posts
if post.quotes.contains fullID
if fullID in post.quotes
recursive post, args...
return

View File

@ -21,7 +21,7 @@ ThreadHiding =
continue unless thread.isHidden
unless thread.stub
nodes[i + 1].hidden = true
else unless root.contains thread.stub
else unless thread.stub in root
# When we come back to a page, the stub is already there.
ThreadHiding.makeStub thread, root
return

View File

@ -45,7 +45,7 @@ Get =
# if it did quote this post,
# get all their backlinks.
for ID, quoterPost of g.posts
if quoterPost.quotes.contains post.fullID
if post.fullID in quoterPost.quotes
for quoterPost in [quoterPost].concat quoterPost.clones
quotelinks.push.apply quotelinks, quoterPost.nodes.quotelinks
# Second:
@ -98,7 +98,7 @@ Get =
return
{status} = req
unless [200, 304].contains status
unless status in [200, 304]
# The thread can die by the time we check a quote.
if url = Redirect.to 'post', {boardID, postID}
$.cache url,

View File

@ -49,7 +49,7 @@ Main =
return
when 'i.4cdn.org'
$.ready ->
if Conf['404 Redirect'] and ['4chan - Temporarily Offline', '4chan - 404 Not Found'].contains d.title
if Conf['404 Redirect'] and d.title in ['4chan - Temporarily Offline', '4chan - 404 Not Found']
Redirect.init()
pathname = location.pathname.split '/'
URL = Redirect.to 'file',
@ -174,7 +174,7 @@ Main =
attributeFilter: ['href']
initReady: ->
if ['4chan - Temporarily Offline', '4chan - 404 Not Found'].contains d.title
if d.title in ['4chan - Temporarily Offline', '4chan - 404 Not Found']
if Conf['404 Redirect'] and g.VIEW is 'thread'
href = Redirect.to 'thread',
boardID: g.BOARD.ID

View File

@ -307,7 +307,7 @@ Settings =
input = $ "[name=#{name}]", section
items[name] = Conf[name]
inputs[name] = input
event = if ['favicon', 'usercss', 'sageEmoji', 'emojiPos'].contains name
event = if name in ['favicon', 'usercss', 'sageEmoji', 'emojiPos']
'change'
else
'input'
@ -321,7 +321,7 @@ Settings =
$.get items, (items) ->
for key, val of items
continue if ['emojiPos'].contains key
continue if key is 'emojiPos'
input = inputs[key]
input.value = val
continue if key is 'usercss'
@ -342,7 +342,7 @@ Settings =
file: []
data.thread.push name
data.post.push name if archive.software is 'foolfuuka'
data.file.push name if archive.files.contains boardID
data.file.push name if boardID in archive.files
rows = []
boardOptions = []

View File

@ -326,7 +326,7 @@ UI = do ->
$.on root, 'mousemove', o.hover
<% if (type === 'userscript') { %>
# Workaround for https://github.com/MayhemYDG/4chan-x/issues/377
o.workaround = (e) -> o.hoverend() unless root.contains e.target
o.workaround = (e) -> o.hoverend() unless e.target in root
$.on doc, 'mousemove', o.workaround
<% } %>

View File

@ -1,16 +1,7 @@
String::capitalize = ->
@charAt(0).toUpperCase() + @slice(1);
String::contains = (string) ->
@indexOf(string) > -1
Array::contains = (object) ->
@indexOf(object) > -1
Array::indexOf = (object) ->
Array::indexOf = (val) ->
i = @length
while i--
return i if @[i] is object
return i if @[i] is val
return i
# loosely follows the jquery api:
@ -19,13 +10,14 @@ Array::indexOf = (object) ->
$ = (selector, root=d.body) ->
root.querySelector selector
$.extend = (object, properties) ->
for key, val of properties
continue unless properties.hasOwnProperty key
object[key] = val
$.extend = (obj, prop) ->
obj[key] = val for key, val of prop when prop.hasOwnProperty key
return
$.DAY = 24 * ($.HOUR = 60 * ($.MINUTE = 60 * ($.SECOND = 1000)))
$.DAY = 24 *
$.HOUR = 60 *
$.MINUTE = 60 *
$.SECOND = 1000
$.id = (id) ->
d.getElementById id
@ -137,7 +129,7 @@ $.toggleClass = (el, className) ->
el.classList.toggle className
$.hasClass = (el, className) ->
el.classList.contains className
className in el.classList
$.rm = do ->
if 'remove' of Element::

View File

@ -111,7 +111,7 @@ class Post
# ES6 Set when?
fullID = "#{match[1]}.#{match[2]}"
@quotes.push fullID unless @quotes.contains fullID
@quotes.push fullID unless fullID in @quotes
parseFile: (that) ->
return unless (fileEl = $ '.file', @nodes.post) and thumb = $ 'img[data-md5]', fileEl

View File

@ -247,7 +247,7 @@ Gallery =
label = $.el 'label',
innerHTML: "<input type=checkbox name='#{name}'> #{name}"
input = label.firstElementChild
if ['Fit Width', 'Fit Height', 'Hide Thumbnails'].contains name
if name in ['Fit Width', 'Fit Height', 'Hide Thumbnails']
$.on input, 'change', Gallery.cb.setFitness
input.checked = Conf[name]
$.event 'change', null, input

View File

@ -43,7 +43,7 @@ ImageExpand =
for ID, post of g.posts
for post in [post].concat post.clones
{file} = post
continue unless file and file.isImage and doc.contains post.nodes.root
continue unless file and file.isImage and post.nodes.root in doc
if ImageExpand.on and
(!Conf['Expand spoilers'] and file.isSpoiler or
Conf['Expand from here'] and Header.getTopOf(file.thumb) < 0)

View File

@ -23,7 +23,7 @@ ImageHover =
asapTest: -> el.naturalHeight
$.on el, 'error', ImageHover.error
error: ->
return unless doc.contains @
return unless @ in doc
post = g.posts[@dataset.fullID]
src = @src.split '/'

View File

@ -303,7 +303,7 @@ Linkify =
el = $.el 'div'
$.cache "https://mediacru.sh/#{a.dataset.uid}.json", ->
{status} = @
return div.innerHTML = "ERROR #{status}" unless [200, 304].contains status
return div.innerHTML = "ERROR #{status}" unless status in [200, 304]
{files} = JSON.parse @response
for type in ['video/mp4', 'video/ogv', 'image/svg+xml', 'image/png', 'image/gif', 'image/jpeg', 'image/svg', 'audio/mpeg']
for file in files

View File

@ -33,9 +33,9 @@ CatalogLinks =
(board) -> a.href = "/#{board}/#{path}"
for a in $$ """#board-list a:not(.catalog), #boardNavDesktopFoot a"""
continue if !['boards.4chan.org', 'catalog.neet.tv', '4index.gropes.us'].contains(a.hostname) or
continue if not a.hostname in ['boards.4chan.org', 'catalog.neet.tv', '4index.gropes.us'] or
!(board = a.pathname.split('/')[1]) or
['f', 'status', '4chan'].contains board
board in ['f', 'status', '4chan']
# Href is easier than pathname because then we don't have
# conditions where External Catalog has been disabled between switches.

View File

@ -32,7 +32,7 @@ ExpandComment =
post.nodes.comment = post.nodes.shortComment
parse: (req, a, post) ->
{status} = req
unless [200, 304].contains status
unless status in [200, 304]
a.textContent = "Error #{req.statusText} (#{status})"
return

View File

@ -19,7 +19,7 @@ Keybinds =
keydown: (e) ->
return unless key = Keybinds.keyCode e
{target} = e
if ['INPUT', 'TEXTAREA'].contains target.nodeName
if target.nodeName in ['INPUT', 'TEXTAREA']
return unless /(Esc|Alt|Ctrl|Meta|Shift\+\w{2,})/.test key
threadRoot = Nav.getThread()
if op = $ '.op', threadRoot

View File

@ -254,18 +254,20 @@ ThreadUpdater =
deletedPosts = []
deletedFiles = []
# Check for deleted posts/files.
for ID, post of ThreadUpdater.thread.posts
# XXX tmp fix for 4chan's racing condition
# giving us false-positive dead posts.
# continue if post.isDead
ID = +ID
if post.isDead and index.contains ID
post.resurrect()
else unless index.contains ID
unless ID in index
post.kill()
deletedPosts.push post
else if post.file and !post.file.isDead and not files.contains ID
else if post.isDead
post.resurrect()
else if post.file and not (post.file.isDead and ID in files)
post.kill true
deletedFiles.push post

View File

@ -79,7 +79,7 @@ Unread =
Unread.addPostQuotingYou post
if Conf['Unread Line']
# Force line on visible threads if there were no unread posts previously.
Unread.setLine posts.contains Unread.posts[0]
Unread.setLine Unread.posts[0] in posts
Unread.read()
Unread.update()

View File

@ -228,8 +228,7 @@ QR =
item = item.replace match, ''
boards = item.match(/boards:([^;]+)/i)?[1].toLowerCase() or 'global'
if boards isnt 'global' and not ((boards.split ',').contains g.BOARD.ID)
return
return if boards isnt 'global' and not g.BOARD.ID in boards.split ','
if type is 'password'
QR.persona.pwd = val
@ -240,7 +239,7 @@ QR =
if /always/i.test item
QR.persona.always[type] = val
unless types[type].contains val
unless val in types[type]
types[type].push val
loadPersonas: (type, arr) ->
@ -469,7 +468,7 @@ QR =
if file.size > max
QR.error "#{file.name}: File too large (file: #{$.bytesToString file.size}, max: #{$.bytesToString max})."
return
else unless QR.mimeTypes.contains file.type
else unless file.type in QR.mimeTypes
unless /^text/.test file.type
QR.error "#{file.name}: Unsupported file type."
return
@ -493,7 +492,7 @@ QR =
$.addClass QR.nodes.filename, 'edit'
QR.nodes.filename.focus()
return $.on QR.nodes.filename, 'blur', -> $.rmClass QR.nodes.filename, 'edit'
return if e.target.nodeName is 'INPUT' or (e.keyCode and not [32, 13].contains e.keyCode) or e.ctrlKey
return if e.target.nodeName is 'INPUT' or (e.keyCode and not e.keyCode in [32, 13]) or e.ctrlKey
e.preventDefault()
QR.nodes.fileInput.click()

View File

@ -19,7 +19,7 @@ QuoteOP =
{quotelinks} = @nodes
# rm (OP) from cross-thread quotes.
if @isClone and quotes.contains @thread.fullID
if @isClone and @thread.fullID in quotes
i = 0
while quotelink = quotelinks[i++]
quotelink.textContent = quotelink.textContent.replace QuoteOP.text, ''
@ -27,7 +27,7 @@ QuoteOP =
{fullID} = (if @isClone then @context else @).thread
# add (OP) to quotes quoting this context's OP.
return unless quotes.contains fullID
return unless fullID in quotes
i = 0
while quotelink = quotelinks[i++]
{boardID, postID} = Get.postDataFromLink quotelink

View File

@ -68,7 +68,7 @@ QuoteThreading =
{bottom, top} = qpost.nodes.root.getBoundingClientRect()
# Post is unread or is fully visible.
return false unless Unread.posts.contains(qpost) or ((bottom < height) and (top > 0))
return false unless qpost in Unread.posts or ((bottom < height) and (top > 0))
qroot = qpost.nodes.root
unless $.hasClass qroot, 'threadOP'

View File

@ -69,19 +69,16 @@ Quotify =
$.addClass a, 'quotelink'
$.extend a.dataset, {boardID, postID}
unless @quotes.contains quoteID
@quotes.push quoteID
@quotes.push quoteID unless quoteID in @quotes
unless a
deadlink.textContent = "#{quote}\u00A0(Dead)"
return
return deadlink.textContent = "#{quote}\u00A0(Dead)" unless a
$.replace deadlink, a
if $.hasClass a, 'quotelink'
@nodes.quotelinks.push a
fixDeadlink: (deadlink) ->
if !(el = deadlink.previousSibling) or el.nodeName is 'BR'
if not (el = deadlink.previousSibling) or el.nodeName is 'BR'
green = $.el 'span',
className: 'quote'
$.before deadlink, green