diff --git a/CHANGELOG.md b/CHANGELOG.md
index 77b7ac8e0..4f7ee091c 100755
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,9 @@
+### v1.2.29
+*2013-08-14*
+
+**Zixaphir**:
+- Fix issue that caused 4chan X to show settings after every page load
+
### v1.2.28
*2013-08-14*
diff --git a/LICENSE b/LICENSE
index 57f1ba77b..a68102944 100755
--- a/LICENSE
+++ b/LICENSE
@@ -1,5 +1,5 @@
/*
-* 4chan X - Version 1.2.28 - 2013-08-15
+* 4chan X - Version 1.2.29 - 2013-08-15
*
* Licensed under the MIT license.
* https://github.com/seaweedchan/4chan-x/blob/master/LICENSE
diff --git a/builds/4chan-X.meta.js b/builds/4chan-X.meta.js
index 8cb87aec6..5a8ad9123 100755
--- a/builds/4chan-X.meta.js
+++ b/builds/4chan-X.meta.js
@@ -1,6 +1,6 @@
// ==UserScript==
// @name 4chan X
-// @version 1.2.28
+// @version 1.2.29
// @namespace 4chan-X
// @description Cross-browser userscript for maximum lurking on 4chan.
// @license MIT; https://github.com/seaweedchan/4chan-x/blob/master/LICENSE
diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js
index af3e751bf..fd10445f4 100644
--- a/builds/4chan-X.user.js
+++ b/builds/4chan-X.user.js
@@ -1,7 +1,7 @@
// Generated by CoffeeScript
// ==UserScript==
// @name 4chan X
-// @version 1.2.28
+// @version 1.2.29
// @namespace 4chan-X
// @description Cross-browser userscript for maximum lurking on 4chan.
// @license MIT; https://github.com/seaweedchan/4chan-x/blob/master/LICENSE
@@ -19,7 +19,7 @@
// @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAgMAAAAqbBEUAAAACVBMVEUAAGcAAABmzDNZt9VtAAAAAXRSTlMAQObYZgAAAHFJREFUKFOt0LENACEIBdBv4Qju4wgWanEj3D6OcIVMKaitYHEU/jwTCQj8W75kiVCSBvdQ5/AvfVHBin11BgdRq3ysBgfwBDRrj3MCIA+oAQaku/Q1cNctrAmyDl577tOThYt/Y1RBM4DgOHzM0HFTAyLukH/cmRnqAAAAAElFTkSuQmCC
// ==/UserScript==
/*
-* 4chan X - Version 1.2.28 - 2013-08-15
+* 4chan X - Version 1.2.29 - 2013-08-15
*
* Licensed under the MIT license.
* https://github.com/seaweedchan/4chan-x/blob/master/LICENSE
@@ -326,7 +326,7 @@
doc = d.documentElement;
g = {
- VERSION: '1.2.28',
+ VERSION: '1.2.29',
NAMESPACE: '4chan X.',
boards: {},
threads: {},
@@ -347,6 +347,7 @@
Array.prototype.indexOf = function(object) {
var i;
+
i = this.length;
while (i--) {
if (this[i] === object) {
@@ -365,6 +366,7 @@
$.extend = function(object, properties) {
var key, val;
+
for (key in properties) {
val = properties[key];
if (!properties.hasOwnProperty(key)) {
@@ -382,6 +384,7 @@
$.ready = function(fc) {
var cb;
+
if (d.readyState !== 'loading') {
$.queueTask(fc);
return;
@@ -395,6 +398,7 @@
$.formData = function(form) {
var fd, key, val;
+
if (form instanceof HTMLFormElement) {
return new FormData(form);
}
@@ -414,6 +418,7 @@
$.extend = function(object, properties) {
var key, val;
+
for (key in properties) {
val = properties[key];
object[key] = val;
@@ -422,9 +427,11 @@
$.ajax = (function() {
var lastModified;
+
lastModified = {};
return function(url, options, extra) {
var form, r, sync, type, upCallbacks, whenModified;
+
if (extra == null) {
extra = {};
}
@@ -447,9 +454,11 @@
$.cache = (function() {
var reqs;
+
reqs = {};
return function(url, cb, options) {
var err, req, rm;
+
if (req = reqs[url]) {
if (req.readyState === 4) {
cb.call(req, req.evt);
@@ -469,6 +478,7 @@
}
$.on(req, 'load', function(e) {
var _i, _len, _ref;
+
_ref = this.callbacks;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
cb = _ref[_i];
@@ -504,6 +514,7 @@
$.addStyle = function(css, id) {
var style;
+
style = $.el('style', {
id: id,
textContent: css
@@ -550,6 +561,7 @@
} else {
return function(el) {
var _ref;
+
return (_ref = el.parentNode) != null ? _ref.removeChild(el) : void 0;
};
}
@@ -557,6 +569,7 @@
$.rmAll = function(root) {
var node;
+
while (node = root.firstChild) {
root.removeChild(node);
}
@@ -572,6 +585,7 @@
$.nodes = function(nodes) {
var frag, node, _i, _len;
+
if (!(nodes instanceof Array)) {
return nodes;
}
@@ -605,6 +619,7 @@
$.el = function(tag, properties) {
var el;
+
el = d.createElement(tag);
if (properties) {
$.extend(el, properties);
@@ -614,6 +629,7 @@
$.on = function(el, events, handler) {
var event, _i, _len, _ref;
+
_ref = events.split(' ');
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
event = _ref[_i];
@@ -623,6 +639,7 @@
$.off = function(el, events, handler) {
var event, _i, _len, _ref;
+
_ref = events.split(' ');
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
event = _ref[_i];
@@ -644,6 +661,7 @@
$.debounce = function(wait, fn) {
var args, exec, lastCall, that, timeout;
+
lastCall = 0;
timeout = null;
that = null;
@@ -665,9 +683,11 @@
$.queueTask = (function() {
var execTask, taskChannel, taskQueue;
+
taskQueue = [];
execTask = function() {
var args, func, task;
+
task = taskQueue.shift();
func = task[0];
args = Array.prototype.slice.call(task, 1);
@@ -690,6 +710,7 @@
$.globalEval = function(code) {
var script;
+
script = $.el('script', {
textContent: code
});
@@ -699,6 +720,7 @@
$.bytesToString = function(size) {
var unit;
+
unit = 0;
while (size >= 1024) {
size /= 1024;
@@ -714,6 +736,7 @@
$.item = function(key, val) {
var item;
+
item = {};
item[key] = val;
return item;
@@ -724,6 +747,7 @@
$.sync = (function() {
$.on(window, 'storage', function(e) {
var cb;
+
if (cb = $.syncing[e.key]) {
return cb(JSON.parse(e.newValue));
}
@@ -735,6 +759,7 @@
$["delete"] = function(keys) {
var key, _i, _len;
+
if (!(keys instanceof Array)) {
keys = [keys];
}
@@ -748,6 +773,7 @@
$.get = function(key, val, cb) {
var items;
+
if (typeof cb === 'function') {
items = $.item(key, val);
} else {
@@ -766,6 +792,7 @@
$.set = (function() {
var set;
+
set = function(key, val) {
key = g.NAMESPACE + key;
val = JSON.stringify(val);
@@ -776,6 +803,7 @@
};
return function(keys, val) {
var key;
+
if (typeof keys === 'string') {
set(keys, val);
return;
@@ -843,6 +871,7 @@
function Post(root, thread, board, that) {
var capcode, date, email, flag, info, name, post, subject, tripcode, uniqueID;
+
this.thread = thread;
this.board = board;
if (that == null) {
@@ -918,6 +947,7 @@
Post.prototype.parseComment = function() {
var bq, i, node, nodes, text;
+
bq = this.nodes.comment.cloneNode(true);
nodes = $$('.abbr, .capcodeReplies, .exif, b', bq);
i = 0;
@@ -935,6 +965,7 @@
Post.prototype.parseQuotes = function() {
var quotelink, _i, _len, _ref;
+
this.quotes = [];
_ref = $$('.quotelink', this.nodes.comment);
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
@@ -945,6 +976,7 @@
Post.prototype.parseQuote = function(quotelink) {
var fullID, match;
+
if (!(match = quotelink.href.match(/boards\.4chan\.org\/([^\/]+)\/res\/\d+#p(\d+)$/))) {
return;
}
@@ -960,6 +992,7 @@
Post.prototype.parseFile = function(that) {
var alt, anchor, fileEl, fileInfo, size, thumb, unit;
+
if (!((fileEl = $('.file', this.nodes.post)) && (thumb = $('img[data-md5]', fileEl)))) {
return;
}
@@ -990,6 +1023,7 @@
Post.prototype.kill = function(file, now) {
var clone, quotelink, strong, _i, _j, _len, _len1, _ref, _ref1;
+
now || (now = new Date());
if (file) {
if (this.file.isDead) {
@@ -1038,6 +1072,7 @@
Post.prototype.resurrect = function() {
var clone, quotelink, strong, _i, _j, _len, _len1, _ref, _ref1;
+
delete this.isDead;
delete this.timeOfDeath;
$.rmClass(this.nodes.root, 'deleted-post');
@@ -1071,6 +1106,7 @@
Post.prototype.rmClone = function(index) {
var clone, _i, _len, _ref;
+
this.clones.splice(index, 1);
_ref = this.clones.slice(index);
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
@@ -1088,6 +1124,7 @@
function Clone(origin, context) {
var file, info, inline, inlined, key, nodes, post, root, val, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2, _ref3;
+
this.origin = origin;
this.context = context;
_ref = ['ID', 'fullID', 'board', 'thread', 'info', 'quotes', 'isReply'];
@@ -1175,6 +1212,7 @@
function DataBoard(key, sync, dontClean) {
var init,
_this = this;
+
this.key = key;
this.data = Conf[key];
$.sync(key, this.onSync.bind(this));
@@ -1197,6 +1235,7 @@
DataBoard.prototype["delete"] = function(_arg) {
var boardID, postID, threadID;
+
boardID = _arg.boardID, threadID = _arg.threadID, postID = _arg.postID;
if (postID) {
delete this.data.boards[boardID][threadID][postID];
@@ -1217,6 +1256,7 @@
DataBoard.prototype.deleteIfEmpty = function(_arg) {
var boardID, threadID;
+
boardID = _arg.boardID, threadID = _arg.threadID;
if (threadID) {
if (!Object.keys(this.data.boards[boardID][threadID]).length) {
@@ -1232,6 +1272,7 @@
DataBoard.prototype.set = function(_arg) {
var boardID, postID, threadID, val, _base, _base1, _base2;
+
boardID = _arg.boardID, threadID = _arg.threadID, postID = _arg.postID, val = _arg.val;
if (postID !== void 0) {
((_base = ((_base1 = this.data.boards)[boardID] || (_base1[boardID] = {})))[threadID] || (_base[threadID] = {}))[postID] = val;
@@ -1245,6 +1286,7 @@
DataBoard.prototype.get = function(_arg) {
var ID, board, boardID, defaultValue, postID, thread, threadID, val, _i, _len;
+
boardID = _arg.boardID, threadID = _arg.threadID, postID = _arg.postID, defaultValue = _arg.defaultValue;
if (board = this.data.boards[boardID]) {
if (!threadID) {
@@ -1268,6 +1310,7 @@
DataBoard.prototype.clean = function() {
var boardID, now, val, _ref;
+
_ref = this.data.boards;
for (boardID in _ref) {
val = _ref[boardID];
@@ -1287,8 +1330,10 @@
DataBoard.prototype.ajaxClean = function(boardID) {
var _this = this;
+
return $.cache("//api.4chan.org/" + boardID + "/threads.json", function(e) {
var board, page, thread, threads, _i, _j, _len, _len1, _ref, _ref1;
+
if (e.target.status === 404) {
_this["delete"](boardID);
} else if (e.target.status === 200) {
@@ -1373,8 +1418,10 @@
init: function() {},
toBlob: function() {
var _base;
+
return (_base = HTMLCanvasElement.prototype).toBlob || (_base.toBlob = function(cb) {
var data, i, l, ui8a, _i;
+
data = atob(this.toDataURL().slice(22));
l = data.length;
ui8a = new Uint8Array(l);
@@ -1412,6 +1459,7 @@
init: function() {
var barFixedToggler, barPositionToggler, customNavToggler, editCustomNav, footerToggler, headerToggler, linkJustifyToggler, menuButton,
_this = this;
+
this.menu = new UI.Menu('header');
menuButton = $.el('span', {
className: 'menu-button',
@@ -1502,6 +1550,7 @@
});
return $.ready(function() {
var a, cs;
+
_this.footer = $.id('boardNavDesktopFoot');
if (a = $("a[href*='/" + g.BOARD + "/']", $.id('boardNavDesktopFoot'))) {
a.className = 'current';
@@ -1535,6 +1584,7 @@
}),
setBoardList: function() {
var a, boardList, btn, fourchannav, fullBoardList;
+
fourchannav = $.id('boardNavDesktop');
if (a = $("a[href*='/" + g.BOARD + "/']", fourchannav)) {
a.className = 'current';
@@ -1556,6 +1606,7 @@
},
generateBoardList: function(text) {
var as, list, nodes;
+
list = $('#custom-board-list', Header.bar);
$.rmAll(list);
if (!text) {
@@ -1564,6 +1615,7 @@
as = $$('#full-board-list a[title]', Header.bar);
nodes = text.match(/[\w@]+((-(all|title|replace|full|index|catalog|url:"[^"]+[^"]"|text:"[^"]+")|\,"[^"]+[^"]"))*|[^\w@]+/g).map(function(t) {
var a, board, m, _i, _len;
+
if (/^[^\w@]/.test(t)) {
return $.tn(t);
}
@@ -1614,6 +1666,7 @@
},
toggleBoardList: function() {
var bar, custom, full, showBoardList;
+
bar = Header.bar;
custom = $('#custom-board-list', bar);
full = $('#full-board-list', bar);
@@ -1649,6 +1702,7 @@
},
toggleLinkJustify: function() {
var centered;
+
$.event('CloseMenu');
centered = this.nodeName === 'INPUT' ? this.checked : void 0;
Header.setLinkJustify(centered);
@@ -1678,6 +1732,7 @@
},
toggleBarVisibility: function(e) {
var hide, message;
+
if (e.type === 'mousedown' && e.button !== 0) {
return;
}
@@ -1694,6 +1749,7 @@
},
toggleFooterVisibility: function() {
var hide, message;
+
$.event('CloseMenu');
hide = this.nodeName === 'INPUT' ? this.checked : !!Header.footer.hidden;
Header.setFooterVisibility(hide);
@@ -1703,6 +1759,7 @@
},
setCustomNav: function(show) {
var btn, cust, full, _ref;
+
Header.customNavToggler.checked = show;
cust = $('#custom-board-list', Header.bar);
full = $('#full-board-list', Header.bar);
@@ -1715,12 +1772,14 @@
},
editCustomNav: function() {
var settings;
+
Settings.open('Advanced');
settings = $.id('fourchanx-settings');
return $('input[name=boardnav]', settings).focus();
},
hashScroll: function() {
var hash, post;
+
if (!((hash = this.location.hash.slice(1)) && (post = $.id(hash)))) {
return;
}
@@ -1731,6 +1790,7 @@
},
scrollToPost: function(post) {
var headRect, top;
+
top = post.getBoundingClientRect().top;
if (Conf['Fixed Header'] && !Conf['Bottom Header']) {
headRect = Header.bar.getBoundingClientRect();
@@ -1740,6 +1800,7 @@
},
addShortcut: function(el) {
var shortcut;
+
shortcut = $.el('span', {
className: 'shortcut brackets-wrap'
});
@@ -1751,6 +1812,7 @@
},
createNotification: function(e) {
var cb, content, lifetime, notif, type, _ref;
+
_ref = e.detail, type = _ref.type, content = _ref.content, lifetime = _ref.lifetime, cb = _ref.cb;
notif = new Notification(type, content, lifetime);
if (cb) {
@@ -1763,6 +1825,7 @@
spoilerRange: {},
shortFilename: function(filename, isReply) {
var threshold;
+
threshold = isReply ? 30 : 40;
if (filename.length - 4 > threshold) {
return "" + filename.slice(0, threshold - 5) + "(...)." + filename.slice(-3);
@@ -1772,6 +1835,7 @@
},
postFromObject: function(data, boardID) {
var o;
+
o = {
postID: data.no,
threadID: data.resto || data.no,
@@ -1816,6 +1880,7 @@
*/
var a, boardID, capcode, capcodeClass, capcodeReplies, capcodeStart, closed, comment, container, date, dateUTC, email, emailEnd, emailStart, ext, file, fileDims, fileHTML, fileInfo, fileSize, fileThumb, filename, flag, flagCode, flagName, href, imgSrc, isClosed, isOP, isSticky, name, postID, quote, shortFilename, spoilerRange, staticPath, sticky, subject, threadID, tripcode, uniqueID, userID, _i, _len, _ref;
+
postID = o.postID, threadID = o.threadID, boardID = o.boardID, name = o.name, capcode = o.capcode, tripcode = o.tripcode, uniqueID = o.uniqueID, email = o.email, subject = o.subject, flagCode = o.flagCode, flagName = o.flagName, date = o.date, dateUTC = o.dateUTC, isSticky = o.isSticky, isClosed = o.isClosed, comment = o.comment, capcodeReplies = o.capcodeReplies, file = o.file;
isOP = postID === threadID;
staticPath = '//static.4chan.org/image/';
@@ -1914,6 +1979,7 @@
},
capcodeReplies: function(_arg) {
var array, boardID, bq, capcodeReplies, capcodeType, generateCapcodeReplies, html, root, threadID;
+
boardID = _arg.boardID, threadID = _arg.threadID, bq = _arg.bq, root = _arg.root, capcodeReplies = _arg.capcodeReplies;
if (!capcodeReplies) {
return;
@@ -1950,6 +2016,7 @@
Get = {
threadExcerpt: function(thread) {
var OP, excerpt, _ref;
+
OP = thread.OP;
excerpt = ((_ref = OP.info.subject) != null ? _ref.trim() : void 0) || OP.info.comment.replace(/\n+/g, ' // ') || Conf['Anonymize'] && 'Anonymous' || $('.nameBlock', OP.nodes.info).textContent.trim();
if (excerpt.length > 70) {
@@ -1965,6 +2032,7 @@
},
postFromRoot: function(root) {
var boardID, index, link, post, postID;
+
link = $('a[title="Highlight this post"]', root);
boardID = link.pathname.split('/')[1];
postID = link.hash.slice(2);
@@ -1984,6 +2052,7 @@
},
postDataFromLink: function(link) {
var boardID, path, postID, threadID, _ref;
+
if (link.hostname === 'boards.4chan.org') {
path = link.pathname.split('/');
boardID = path[1];
@@ -2001,6 +2070,7 @@
},
allQuotelinksLinkingTo: function(post) {
var ID, quote, quotedPost, quotelinks, quoterPost, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2, _ref3;
+
quotelinks = [];
_ref = g.posts;
for (ID in _ref) {
@@ -2029,12 +2099,14 @@
}
return quotelinks.filter(function(quotelink) {
var boardID, postID, _ref4;
+
_ref4 = Get.postDataFromLink(quotelink), boardID = _ref4.boardID, postID = _ref4.postID;
return boardID === post.board.ID && postID === post.ID;
});
},
postClone: function(boardID, threadID, postID, root, context) {
var post, url;
+
if (post = g.posts["" + boardID + "." + postID]) {
Get.insert(post, root, context);
return;
@@ -2057,6 +2129,7 @@
},
insert: function(post, root, context) {
var clone, nodes;
+
if (!root.parentNode) {
return;
}
@@ -2070,6 +2143,7 @@
},
fetchedPost: function(req, boardID, threadID, postID, root, context) {
var board, post, posts, status, thread, url, _i, _len;
+
if (post = g.posts["" + boardID + "." + postID]) {
Get.insert(post, root, context);
return;
@@ -2123,6 +2197,7 @@
},
archivedPost: function(req, boardID, postID, root, context) {
var board, bq, comment, data, o, post, thread, threadID, _ref;
+
if (post = g.posts["" + boardID + "." + postID]) {
Get.insert(post, root, context);
return;
@@ -2217,8 +2292,10 @@
UI = (function() {
var Menu, dialog, drag, dragend, dragstart, hover, hoverend, hoverstart, touchend, touchmove;
+
dialog = function(id, position, html) {
var child, el, move, _i, _len, _ref;
+
el = $.el('div', {
className: 'dialog',
innerHTML: html,
@@ -2258,6 +2335,7 @@
Menu.prototype.makeMenu = function() {
var menu;
+
menu = $.el('div', {
className: 'dialog',
id: 'menu',
@@ -2272,6 +2350,7 @@
Menu.prototype.toggle = function(e, button, data) {
var previousButton;
+
e.preventDefault();
e.stopPropagation();
if (currentMenu) {
@@ -2289,6 +2368,7 @@
Menu.prototype.open = function(button, data) {
var bLeft, bRect, bTop, bottom, cHeight, cWidth, entry, left, mRect, menu, right, style, top, _i, _len, _ref, _ref1, _ref2;
+
menu = this.makeMenu();
currentMenu = menu;
lastToggledButton = button;
@@ -2327,6 +2407,7 @@
Menu.prototype.insertEntry = function(entry, parent, data) {
var subEntry, submenu, _i, _len, _ref;
+
if (typeof entry.open === 'function') {
if (!entry.open(data)) {
return;
@@ -2360,6 +2441,7 @@
Menu.prototype.findNextEntry = function(entry, direction) {
var entries;
+
entries = __slice.call(entry.parentNode.children);
entries.sort(function(first, second) {
return +(first.style.order || first.style.webkitOrder) - +(second.style.order || second.style.webkitOrder);
@@ -2369,6 +2451,7 @@
Menu.prototype.keybinds = function(e) {
var entry, next, nextPrev, subEntry, submenu;
+
entry = $('.focused', currentMenu);
while (subEntry = $('.focused', entry)) {
entry = subEntry;
@@ -2414,6 +2497,7 @@
Menu.prototype.focus = function(entry) {
var bottom, cHeight, cWidth, eRect, focused, left, right, sRect, style, submenu, top, _i, _len, _ref, _ref1, _ref2;
+
while (focused = $.x('parent::*/child::*[contains(@class,"focused")]', entry)) {
$.rmClass(focused, 'focused');
}
@@ -2441,6 +2525,7 @@
Menu.prototype.addEntry = function(e) {
var entry;
+
entry = e.detail;
if (entry.type !== this.type) {
return;
@@ -2451,6 +2536,7 @@
Menu.prototype.parseEntry = function(entry) {
var el, style, subEntries, subEntry, _i, _len;
+
el = entry.el, subEntries = entry.subEntries;
$.addClass(el, 'entry');
$.on(el, 'focus mouseover', (function(e) {
@@ -2474,6 +2560,7 @@
})();
dragstart = function(e) {
var el, isTouching, o, rect, screenHeight, screenWidth, _ref;
+
if (e.type === 'mousedown' && e.button !== 0) {
return;
}
@@ -2512,6 +2599,7 @@
};
touchmove = function(e) {
var touch, _i, _len, _ref;
+
_ref = e.changedTouches;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
touch = _ref[_i];
@@ -2523,6 +2611,7 @@
};
drag = function(e) {
var bottom, clientX, clientY, left, right, style, top;
+
clientX = e.clientX, clientY = e.clientY;
left = clientX - this.dx;
left = left < 10 ? 0 : this.width - left < 10 ? null : left / this.screenWidth * 100 + '%';
@@ -2538,6 +2627,7 @@
};
touchend = function(e) {
var touch, _i, _len, _ref;
+
_ref = e.changedTouches;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
touch = _ref[_i];
@@ -2559,6 +2649,7 @@
};
hoverstart = function(_arg) {
var asapTest, cb, el, endEvents, latestEvent, o, root;
+
root = _arg.root, el = _arg.el, latestEvent = _arg.latestEvent, endEvents = _arg.endEvents, asapTest = _arg.asapTest, cb = _arg.cb;
o = {
root: root,
@@ -2593,6 +2684,7 @@
};
hover = function(e) {
var clientX, clientY, height, left, right, style, top, _ref;
+
this.latestEvent = e;
height = this.el.offsetHeight;
clientX = e.clientX, clientY = e.clientY;
@@ -2636,6 +2728,7 @@
},
node: function() {
var email, name, tripcode, _ref;
+
if (this.info.capcode || this.isClone) {
return;
}
@@ -2662,6 +2755,7 @@
filters: {},
init: function() {
var boards, err, filter, hl, key, op, regexp, stub, top, _i, _len, _ref, _ref1, _ref2, _ref3, _ref4;
+
if (g.VIEW === 'catalog' || !Conf['Filter']) {
return;
}
@@ -2698,6 +2792,7 @@
op = ((_ref2 = filter.match(/[^t]op:(yes|no|only)/)) != null ? _ref2[1] : void 0) || 'yes';
stub = (function() {
var _ref3;
+
switch ((_ref3 = filter.match(/stub:(yes|no)/)) != null ? _ref3[1] : void 0) {
case 'yes':
return true;
@@ -2728,6 +2823,7 @@
},
createFilter: function(regexp, op, stub, hl, top) {
var settings, test;
+
test = typeof regexp === 'string' ? function(value) {
return regexp === value;
} : function(value) {
@@ -2751,6 +2847,7 @@
},
node: function() {
var filter, firstThread, key, result, thisThread, value, _i, _len, _ref;
+
if (this.isClone) {
return;
}
@@ -2862,6 +2959,7 @@
menu: {
init: function() {
var div, entry, type, _i, _len, _ref;
+
if (g.VIEW === 'catalog' || !Conf['Menu'] || !Conf['Filter']) {
return;
}
@@ -2887,6 +2985,7 @@
},
createSubEntry: function(text, type) {
var el;
+
el = $.el('a', {
href: 'javascript:;',
textContent: text
@@ -2897,6 +2996,7 @@
el: el,
open: function(post) {
var value;
+
value = Filter[type](post);
return value !== false;
}
@@ -2904,6 +3004,7 @@
},
makeFilter: function() {
var re, type, value;
+
type = this.dataset.type;
value = Filter[type](Filter.menu.post);
re = ['uniqueID', 'MD5'].contains(type) ? value : value.replace(/\/|\\|\^|\$|\n|\.|\(|\)|\{|\}|\[|\]|\?|\*|\+|\|/g, function(c) {
@@ -2918,6 +3019,7 @@
re = ['uniqueID', 'MD5'].contains(type) ? "/" + re + "/" : "/^" + re + "$/";
return $.get(type, Conf[type], function(item) {
var save, section, select, ta, tl;
+
save = item[type];
save = save ? "" + save + "\n" + re : re;
$.set(type, save);
@@ -2951,6 +3053,7 @@
},
node: function() {
var data;
+
if (!this.isReply || this.isClone) {
return;
}
@@ -2974,6 +3077,7 @@
menu: {
init: function() {
var apply, div, hideStubLink, makeStub, replies, thisPost;
+
if (g.VIEW === 'catalog' || !Conf['Menu'] || !Conf['Reply Hiding Link']) {
return;
}
@@ -3044,6 +3148,7 @@
order: 20,
open: function(post) {
var data;
+
if (!post.isReply || post.isClone || !post.isHidden) {
return false;
}
@@ -3075,6 +3180,7 @@
order: 15,
open: function(post) {
var data;
+
if (!post.isReply || post.isClone || !post.isHidden) {
return false;
}
@@ -3091,6 +3197,7 @@
},
hide: function() {
var makeStub, parent, post, replies, thisPost;
+
parent = this.parentNode;
thisPost = $('input[name=thisPost]', parent).checked;
replies = $('input[name=replies]', parent).checked;
@@ -3109,6 +3216,7 @@
},
show: function() {
var data, parent, post, replies, thisPost;
+
parent = this.parentNode;
thisPost = $('input[name=thisPost]', parent).checked;
replies = $('input[name=replies]', parent).checked;
@@ -3132,6 +3240,7 @@
},
hideStub: function() {
var post;
+
post = PostHiding.menu.post;
post.nodes.root.hidden = true;
$.event('CloseMenu');
@@ -3139,6 +3248,7 @@
},
makeButton: function(post, type) {
var a;
+
a = $.el('a', {
className: "" + type + "-reply-button",
innerHTML: " " + (type === 'hide' ? '-' : '+') + " ",
@@ -3149,6 +3259,7 @@
},
saveHiddenState: function(post, isHiding, thisPost, makeStub, hideRecursively) {
var data;
+
data = {
boardID: post.board.ID,
threadID: post.thread.ID,
@@ -3167,12 +3278,14 @@
},
toggle: function() {
var post;
+
post = Get.postFromNode(this);
PostHiding[(post.isHidden ? 'show' : 'hide')](post);
return PostHiding.saveHiddenState(post, post.isHidden);
},
hide: function(post, makeStub, hideRecursively) {
var a, button, postInfo, quotelink, _i, _len, _ref;
+
if (makeStub == null) {
makeStub = Conf['Stubs'];
}
@@ -3207,6 +3320,7 @@
},
show: function(post, showRecursively) {
var quotelink, _i, _len, _ref;
+
if (showRecursively == null) {
showRecursively = Conf['Recursive Hiding'];
}
@@ -3242,6 +3356,7 @@
},
node: function() {
var i, obj, quote, recursive, _i, _j, _len, _len1, _ref, _ref1;
+
if (this.isClone) {
return;
}
@@ -3259,6 +3374,7 @@
},
add: function() {
var args, obj, post, recursive, _base, _name;
+
recursive = arguments[0], post = arguments[1], args = 3 <= arguments.length ? __slice.call(arguments, 2) : [];
obj = (_base = Recursive.recursives)[_name = post.fullID] || (_base[_name] = {
recursives: [],
@@ -3269,6 +3385,7 @@
},
rm: function(recursive, post) {
var i, obj, rec, _i, _len, _ref;
+
if (!(obj = Recursive.recursives[post.fullID])) {
return;
}
@@ -3283,6 +3400,7 @@
},
apply: function() {
var ID, args, fullID, post, recursive, _ref;
+
recursive = arguments[0], post = arguments[1], args = 3 <= arguments.length ? __slice.call(arguments, 2) : [];
fullID = post.fullID;
_ref = g.posts;
@@ -3309,6 +3427,7 @@
},
node: function() {
var data;
+
if (data = ThreadHiding.db.get({
boardID: this.board.ID,
threadID: this.ID
@@ -3322,6 +3441,7 @@
},
syncCatalog: function() {
var hiddenThreads, hiddenThreadsOnCatalog, threadID;
+
hiddenThreads = ThreadHiding.db.get({
boardID: g.BOARD.ID,
defaultValue: {}
@@ -3348,6 +3468,7 @@
cleanCatalog: function(hiddenThreadsOnCatalog) {
return $.cache("//api.4chan.org/" + g.BOARD + "/threads.json", function() {
var page, thread, threads, _i, _j, _len, _len1, _ref, _ref1;
+
if (this.status !== 200) {
return;
}
@@ -3373,6 +3494,7 @@
menu: {
init: function() {
var apply, div, hideStubLink, makeStub;
+
if (g.VIEW !== 'index' || !Conf['Menu'] || !Conf['Thread Hiding Link']) {
return;
}
@@ -3394,6 +3516,7 @@
order: 20,
open: function(_arg) {
var isReply, thread;
+
thread = _arg.thread, isReply = _arg.isReply;
if (isReply || thread.isHidden) {
return false;
@@ -3423,6 +3546,7 @@
order: 20,
open: function(_arg) {
var isReply, thread;
+
thread = _arg.thread, isReply = _arg.isReply;
if (isReply || !thread.isHidden) {
return false;
@@ -3442,6 +3566,7 @@
order: 15,
open: function(_arg) {
var isReply, thread;
+
thread = _arg.thread, isReply = _arg.isReply;
if (isReply || !thread.isHidden) {
return false;
@@ -3452,6 +3577,7 @@
},
hide: function() {
var makeStub, thread;
+
makeStub = $('input', this.parentNode).checked;
thread = ThreadHiding.menu.thread;
ThreadHiding.hide(thread, makeStub);
@@ -3460,6 +3586,7 @@
},
show: function() {
var thread;
+
thread = ThreadHiding.menu.thread;
ThreadHiding.show(thread);
ThreadHiding.saveHiddenState(thread);
@@ -3467,6 +3594,7 @@
},
hideStub: function() {
var thread;
+
thread = ThreadHiding.menu.thread;
ThreadHiding.hide(thread, false);
$.event('CloseMenu');
@@ -3474,6 +3602,7 @@
},
makeButton: function(thread, type) {
var a;
+
a = $.el('a', {
className: "" + type + "-thread-button",
innerHTML: " " + (type === 'hide' ? '-' : '+') + " ",
@@ -3485,6 +3614,7 @@
},
saveHiddenState: function(thread, makeStub) {
var hiddenThreadsOnCatalog;
+
hiddenThreadsOnCatalog = JSON.parse(localStorage.getItem("4chan-hide-t-" + g.BOARD)) || {};
if (thread.isHidden) {
ThreadHiding.db.set({
@@ -3517,6 +3647,7 @@
},
hide: function(thread, makeStub) {
var OP, a, numReplies, opInfo, span, threadRoot;
+
if (makeStub == null) {
makeStub = Conf['Stubs'];
}
@@ -3540,6 +3671,7 @@
},
show: function(thread) {
var threadRoot;
+
if (thread.stub) {
$.rm(thread.stub);
delete thread.stub;
@@ -3552,6 +3684,7 @@
QuoteBacklink = {
init: function() {
var format;
+
if (g.VIEW === 'catalog' || !Conf['Quote Backlinks']) {
return;
}
@@ -3569,6 +3702,7 @@
},
firstNode: function() {
var a, clone, container, containers, frag, link, post, quote, _i, _j, _k, _len, _len1, _len2, _ref, _ref1;
+
if (this.isClone || !this.quotes.length) {
return;
}
@@ -3606,6 +3740,7 @@
},
secondNode: function() {
var container;
+
if (this.isClone && (this.origin.isReply || Conf['OP Backlinks'])) {
this.nodes.backlinkContainer = $('.container', this.nodes.info);
return;
@@ -3619,6 +3754,7 @@
},
getContainer: function(id) {
var _base;
+
return (_base = this.containers)[id] || (_base[id] = $.el('span', {
className: 'container'
}));
@@ -3641,6 +3777,7 @@
},
node: function() {
var board, boardID, quotelink, thread, threadID, _i, _len, _ref, _ref1, _ref2;
+
if (this.isClone && this.thread === this.context.thread) {
return;
}
@@ -3670,6 +3807,7 @@
if (Conf['Quote Hash Navigation']) {
this.node = function() {
var link, _i, _len, _ref;
+
_ref = this.nodes.quotelinks.concat(__slice.call(this.nodes.backlinks));
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
link = _ref[_i];
@@ -3682,6 +3820,7 @@
} else {
this.node = function() {
var link, _i, _len, _ref;
+
_ref = this.nodes.quotelinks.concat(__slice.call(this.nodes.backlinks));
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
link = _ref[_i];
@@ -3708,6 +3847,7 @@
},
toggle: function(e) {
var boardID, context, postID, threadID, _ref;
+
if (e.shiftKey || e.altKey || e.ctrlKey || e.metaKey || e.button !== 0) {
return;
}
@@ -3733,6 +3873,7 @@
},
add: function(quotelink, boardID, threadID, postID, context) {
var inline, isBacklink, post, qroot, root;
+
isBacklink = $.hasClass(quotelink, 'backlink');
inline = $.el('div', {
id: "i" + postID,
@@ -3757,6 +3898,7 @@
},
rm: function(quotelink, boardID, threadID, postID, context) {
var el, inlined, isBacklink, post, qroot, root, _ref;
+
isBacklink = $.hasClass(quotelink, 'backlink');
root = QuoteInline.findRoot(quotelink, isBacklink);
root = $.x("following-sibling::div[@id='i" + postID + "'][1]", root);
@@ -3798,6 +3940,7 @@
},
node: function() {
var boardID, fullID, i, postID, quotelink, quotelinks, quotes, _ref;
+
if (this.isClone && this.thread === this.context.thread) {
return;
}
@@ -3840,6 +3983,7 @@
},
node: function() {
var link, _i, _len, _ref;
+
_ref = this.nodes.quotelinks.concat(__slice.call(this.nodes.backlinks));
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
link = _ref[_i];
@@ -3848,6 +3992,7 @@
},
mouseover: function(e) {
var boardID, clone, origin, post, postID, posts, qp, quote, quoterID, threadID, _i, _j, _len, _len1, _ref, _ref1;
+
if ($.hasClass(this, 'inlined')) {
return;
}
@@ -3891,6 +4036,7 @@
},
mouseout: function() {
var clone, post, root, _i, _len, _ref;
+
if (!(root = this.el.firstElementChild)) {
return;
}
@@ -3920,6 +4066,7 @@
},
node: function() {
var boardID, postID, quotelink, _i, _len, _ref, _ref1, _ref2;
+
if (this.isClone) {
return;
}
@@ -3942,6 +4089,7 @@
QuoteThreading = {
init: function() {
var input;
+
if (!(Conf['Quote Threading'] && g.VIEW === 'thread')) {
return;
}
@@ -3964,6 +4112,7 @@
},
setup: function() {
var ID, post, posts;
+
$.off(d, '4chanXInitFinished', QuoteThreading.setup);
posts = g.posts;
for (ID in posts) {
@@ -3976,6 +4125,7 @@
},
node: function() {
var ID, fullID, keys, len, post, posts, qid, quote, quotes, uniq, _i, _len;
+
if (this.isClone || !QuoteThreading.enabled || this.thread.OP === this) {
return;
}
@@ -4005,6 +4155,7 @@
},
nodeinsert: function() {
var bottom, height, qpost, qroot, threadContainer, top, _ref;
+
qpost = g.posts[this.threaded];
delete this.threaded;
delete this.cb;
@@ -4033,6 +4184,7 @@
},
toggle: function() {
var container, containers, node, post, replies, reply, thread, _i, _j, _k, _len, _len1, _len2, _ref;
+
thread = $('.thread');
replies = $$('.thread > .replyContainer, .threadContainer > .replyContainer', thread);
QuoteThreading.enabled = this.checked;
@@ -4049,6 +4201,7 @@
} else {
replies.sort(function(a, b) {
var aID, bID;
+
aID = Number(a.id.slice(2));
bID = Number(b.id.slice(2));
return aID - bID;
@@ -4069,6 +4222,7 @@
},
kb: function() {
var control;
+
control = $.id('threadingControl');
return control.click();
}
@@ -4095,6 +4249,7 @@
},
node: function() {
var quotelink, _i, _len, _ref;
+
if (this.isClone) {
return;
}
@@ -4117,6 +4272,7 @@
cb: {
seek: function(type) {
var highlight, post, posts, result, str;
+
if (!(Conf['Mark Quotes of You'] && Conf['Quick Reply'])) {
return;
}
@@ -4172,6 +4328,7 @@
},
node: function() {
var deadlink, _i, _len, _ref;
+
_ref = $$('.deadlink', this.nodes.comment);
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
deadlink = _ref[_i];
@@ -4186,6 +4343,7 @@
},
parseDeadlink: function(deadlink) {
var a, boardID, m, post, postID, quote, quoteID, redirect, _ref;
+
if (deadlink.parentNode.className === 'prettyprint') {
Quotify.fixDeadlink(deadlink);
return;
@@ -4278,6 +4436,7 @@
},
node: function() {
var data, el, end, endNode, i, index, items, length, link, links, node, range, result, saved, snapshot, space, test, _i, _len, _ref;
+
if (this.isClone) {
if (Conf['Embedding']) {
i = 0;
@@ -4356,6 +4515,7 @@
},
makeRange: function(startNode, endNode, startOffset, endOffset) {
var range;
+
range = document.createRange();
range.setStart(startNode, startOffset);
range.setEnd(endNode, endOffset);
@@ -4363,6 +4523,7 @@
},
makeLink: function(range) {
var a, char, i, text;
+
text = range.toString();
i = 0;
while (/[(\[{<>]/.test(text.charAt(i))) {
@@ -4406,6 +4567,7 @@
},
services: function(link) {
var href, key, match, type, _ref;
+
href = link.href;
_ref = Linkify.types;
for (key in _ref) {
@@ -4418,6 +4580,7 @@
},
embed: function(data) {
var embed, href, key, link, name, options, uid, value, _ref;
+
key = data[0], uid = data[1], options = data[2], link = data[3];
href = link.href;
embed = $.el('a', {
@@ -4446,6 +4609,7 @@
},
title: function(data) {
var embed, err, key, link, options, service, title, titles, uid;
+
key = data[0], uid = data[1], options = data[2], link = data[3], embed = data[4];
if (!(service = Linkify.types[key].title)) {
return;
@@ -4482,18 +4646,21 @@
cb: {
toggle: function() {
var string, _ref;
+
_ref = $.hasClass(this, "embedded") ? ['unembed', '(embed)'] : ['embed', '(unembed)'], string = _ref[0], this.textContent = _ref[1];
$.replace(this.previousElementSibling, Linkify.cb[string](this));
return $.toggleClass(this, 'embedded');
},
embed: function(a) {
var el, style, type;
+
el = (type = Linkify.types[a.dataset.key]).el(a);
el.style.cssText = (style = type.style) ? style : "border: 0; width: 640px; height: 390px";
return el;
},
unembed: function(a) {
var el;
+
el = $.el('a', {
rel: 'nofollow noreferrer',
target: 'blank',
@@ -4506,6 +4673,7 @@
},
title: function(response, data) {
var embed, key, link, options, service, text, uid;
+
key = data[0], uid = data[1], options = data[2], link = data[3], embed = data[4];
service = Linkify.types[key].title;
switch (response.status) {
@@ -4545,6 +4713,7 @@
regExp: /.*(?:gist.github.com.*\/)([^\/][^\/]*)$/,
el: function(a) {
var div;
+
return div = $.el('iframe', {
src: "http://www.purplegene.com/script?url=https://gist.github.com/" + a.dataset.uid + ".js"
});
@@ -4555,6 +4724,7 @@
},
text: function(_arg) {
var file, files;
+
files = _arg.files;
for (file in files) {
if (files.hasOwnProperty(file)) {
@@ -4602,6 +4772,7 @@
regExp: /.*(?:pastebin.com\/(?!u\/))([^#\&\?]*).*/,
el: function(a) {
var div;
+
return div = $.el('iframe', {
src: "http://pastebin.com/embed_iframe.php?i=" + a.dataset.uid
});
@@ -4612,6 +4783,7 @@
style: 'height: auto; width: 500px; display: inline-block;',
el: function(a) {
var div;
+
div = $.el('div', {
className: "soundcloud",
name: "soundcloud"
@@ -4637,6 +4809,7 @@
style: "border: none; width: 640px; height: 360px;",
el: function(a) {
var channel, chapter, result, _;
+
if (result = /(\w+)\/(?:[a-z]\/)?(\d+)/i.exec(a.dataset.uid)) {
_ = result[0], channel = result[1], chapter = result[2];
return $.el('object', {
@@ -4708,6 +4881,7 @@
QR = {
init: function() {
var sc;
+
if (!Conf['Quick Reply']) {
return;
}
@@ -4754,6 +4928,7 @@
},
initReady: function() {
var link;
+
QR.postingIsEnabled = !!$.id('postForm');
if (!QR.postingIsEnabled) {
return;
@@ -4773,11 +4948,13 @@
$.before($.id('postForm'), link);
$.on(d, 'QRGetSelectedPost', function(_arg) {
var cb;
+
cb = _arg.detail;
return cb(QR.selected);
});
$.on(d, 'QRAddPreSubmitHook', function(_arg) {
var cb;
+
cb = _arg.detail;
return QR.preSubmitHooks.push(cb);
});
@@ -4806,6 +4983,7 @@
},
open: function() {
var err;
+
if (QR.nodes) {
QR.nodes.el.hidden = false;
QR.unhide();
@@ -4824,6 +5002,7 @@
},
close: function() {
var post, _i, _len, _ref;
+
if (QR.req) {
QR.abort();
return;
@@ -4871,6 +5050,7 @@
},
error: function(err) {
var el;
+
QR.open();
if (typeof err === 'string') {
el = $.tn(err);
@@ -4898,6 +5078,7 @@
notifications: [],
cleanNotifications: function() {
var notification, _i, _len, _ref;
+
_ref = QR.notifications;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
notification = _ref[_i];
@@ -4907,6 +5088,7 @@
},
status: function() {
var disabled, status, thread, value;
+
if (!QR.nodes) {
return;
}
@@ -4928,6 +5110,7 @@
QR.persona.getPassword();
return $.get('QR.personas', Conf['QR.personas'], function(_arg) {
var arr, item, personas, type, types, _i, _len, _ref;
+
personas = _arg['QR.personas'];
types = {
name: [],
@@ -4947,6 +5130,7 @@
},
parseItem: function(item, types) {
var boards, match, type, val, _ref, _ref1;
+
if (item[0] === '#') {
return;
}
@@ -4975,6 +5159,7 @@
},
loadPersonas: function(type, arr) {
var list, val, _i, _len;
+
list = $("#list-" + type, QR.nodes.el);
for (_i = 0, _len = arr.length; _i < _len; _i++) {
val = arr[_i];
@@ -4987,6 +5172,7 @@
},
getPassword: function() {
var input, m;
+
if (!QR.persona.pwd) {
QR.persona.pwd = (m = d.cookie.match(/4chan_pass=([^;]+)/)) ? decodeURIComponent(m[1]) : (input = $.id('postPassword')) ? input.value : $.id('delPassword').value;
}
@@ -4995,6 +5181,7 @@
get: function(cb) {
return $.get('QR.persona', {}, function(_arg) {
var persona;
+
persona = _arg['QR.persona'];
return cb(persona);
});
@@ -5002,6 +5189,7 @@
set: function(post) {
return $.get('QR.persona', {}, function(_arg) {
var persona;
+
persona = _arg['QR.persona'];
persona = {
name: post.name,
@@ -5015,6 +5203,7 @@
cooldown: {
init: function() {
var board;
+
if (!Conf['Cooldown']) {
return;
}
@@ -5056,6 +5245,7 @@
},
sync: function(cooldowns) {
var id;
+
for (id in cooldowns) {
QR.cooldown.cooldowns[id] = cooldowns[id];
}
@@ -5063,6 +5253,7 @@
},
set: function(data) {
var cooldown, delay, hasFile, isReply, isSage, post, req, start, type, upSpd;
+
if (!Conf['Cooldown']) {
return;
}
@@ -5102,6 +5293,7 @@
},
count: function() {
var cooldown, cooldowns, elapsed, hasFile, isReply, isSage, now, post, seconds, start, type, types, upSpd, upSpdAccuracy, update, _ref;
+
if (!Object.keys(QR.cooldown.cooldowns).length) {
$["delete"]("" + g.BOARD + ".cooldown");
delete QR.cooldown.isCounting;
@@ -5155,6 +5347,7 @@
},
quote: function(e) {
var caretPos, com, index, post, range, s, sel, text, thread, _ref;
+
if (e != null) {
e.preventDefault();
}
@@ -5192,6 +5385,7 @@
},
characterCount: function() {
var count, counter;
+
counter = QR.nodes.charCount;
count = QR.nodes.com.textLength;
counter.textContent = count;
@@ -5200,6 +5394,7 @@
},
drag: function(e) {
var toggle;
+
toggle = e.type === 'dragstart' ? $.off : $.on;
toggle(d, 'dragover', QR.dragOver);
return toggle(d, 'drop', QR.dropFile);
@@ -5219,6 +5414,7 @@
},
paste: function(e) {
var blob, files, item, _i, _len, _ref;
+
files = [];
_ref = e.clipboardData.items;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
@@ -5245,8 +5441,19 @@
return QR.nodes.fileInput.click();
},
fileInput: function(files) {
- var file, length, max, post, _i, _len;
- if (files instanceof Event) {
+ var check, err, file, length, max, post, _i, _len;
+
+ try {
+ if (files instanceof Event) {
+ check = true;
+ }
+ } catch (_error) {
+ err = _error;
+ if (this instanceof Element) {
+ check = true;
+ }
+ }
+ if (check) {
files = __slice.call(this.files);
QR.nodes.fileInput.value = null;
}
@@ -5294,6 +5501,7 @@
function _Class(select) {
var el, elm, event, prev, _i, _j, _len, _len1, _ref, _ref1,
_this = this;
+
el = $.el('a', {
className: 'qr-preview',
draggable: true,
@@ -5353,6 +5561,7 @@
_Class.prototype.rm = function() {
var index;
+
this["delete"]();
index = QR.posts.indexOf(this);
if (QR.posts.length === 1) {
@@ -5372,6 +5581,7 @@
_Class.prototype.lock = function(lock) {
var name, _i, _len, _ref;
+
if (lock == null) {
lock = true;
}
@@ -5396,6 +5606,7 @@
_Class.prototype.select = function() {
var rectEl, rectList;
+
if (QR.selected) {
QR.selected.nodes.el.id = null;
QR.selected.forceSave();
@@ -5412,6 +5623,7 @@
_Class.prototype.load = function() {
var name, _i, _len, _ref;
+
_ref = ['thread', 'name', 'email', 'sub', 'com'];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
name = _ref[_i];
@@ -5423,6 +5635,7 @@
_Class.prototype.save = function(input) {
var name, _ref;
+
if (input.type === 'checkbox') {
this.spoiler = input.checked;
return;
@@ -5443,6 +5656,7 @@
_Class.prototype.forceSave = function() {
var name, _i, _len, _ref;
+
if (this !== QR.selected) {
return;
}
@@ -5472,9 +5686,11 @@
_Class.prototype.setThumbnail = function() {
var fileURL, img,
_this = this;
+
img = $.el('img');
img.onload = function() {
var cv, height, s, width;
+
s = 90 * 2;
if (_this.file.type === 'image/gif') {
s *= 3;
@@ -5532,9 +5748,11 @@
_Class.prototype.pasteText = function(file) {
var reader,
_this = this;
+
reader = new FileReader();
reader.onload = function(e) {
var text;
+
text = e.target.result;
if (_this.com) {
_this.com += "\n" + text;
@@ -5572,6 +5790,7 @@
_Class.prototype.drop = function() {
var el, index, newIndex, oldIndex, post;
+
$.rmClass(this, 'over');
if (!this.draggable) {
return;
@@ -5606,6 +5825,7 @@
ready: function() {
var imgContainer, input, setLifetime,
_this = this;
+
setLifetime = function(e) {
return _this.lifetime = e.detail;
};
@@ -5642,6 +5862,7 @@
});
$.get('captchas', [], function(_arg) {
var captchas;
+
captchas = _arg.captchas;
return _this.sync(captchas);
});
@@ -5658,6 +5879,7 @@
},
getOne: function() {
var captcha, challenge, response;
+
this.clear();
if (captcha = this.captchas.shift()) {
challenge = captcha.challenge, response = captcha.response;
@@ -5682,6 +5904,7 @@
},
save: function() {
var response;
+
if (!(response = this.nodes.input.value.trim())) {
return;
}
@@ -5696,6 +5919,7 @@
},
clear: function() {
var captcha, i, now, _i, _len, _ref;
+
now = Date.now();
_ref = this.captchas;
for (i = _i = 0, _len = _ref.length; _i < _len; i = ++_i) {
@@ -5713,6 +5937,7 @@
},
load: function() {
var challenge;
+
if (!this.nodes.challenge.firstChild) {
return;
}
@@ -5725,6 +5950,7 @@
},
count: function() {
var count;
+
count = this.captchas.length;
this.nodes.input.placeholder = (function() {
switch (count) {
@@ -5757,6 +5983,7 @@
},
dialog: function() {
var dialog, elm, i, items, mimeTypes, name, nodes, thread;
+
dialog = UI.dialog('qr', 'top:0;right:0;', "
");
QR.nodes = nodes = {
el: dialog,
@@ -5875,6 +6102,7 @@
preSubmitHooks: [],
submit: function(e) {
var challenge, err, extra, filetag, hook, options, post, postData, response, textOnly, thread, threadID, _i, _len, _ref, _ref1;
+
if (e != null) {
e.preventDefault();
}
@@ -5988,6 +6216,7 @@
},
response: function() {
var URL, ban, board, err, h1, isReply, m, post, postID, req, resDoc, threadID, _, _ref, _ref1;
+
req = QR.req;
delete QR.req;
post = QR.posts[0];
@@ -6085,6 +6314,7 @@
FappeTyme = {
init: function() {
var el, input;
+
if (!Conf['Fappe Tyme'] || g.VIEW === 'catalog' || g.BOARD === 'f') {
return;
}
@@ -6136,6 +6366,7 @@
},
node: function() {
var thumb, _ref;
+
if (!((_ref = this.file) != null ? _ref.isImage : void 0)) {
return;
}
@@ -6160,6 +6391,7 @@
},
toggleAll: function() {
var ID, file, func, post, _i, _len, _ref, _ref1;
+
$.event('CloseMenu');
if (ImageExpand.on = $.hasClass(ImageExpand.EAI, 'expand-all-shortcut')) {
ImageExpand.EAI.className = 'contract-all-shortcut';
@@ -6193,6 +6425,7 @@
},
toggle: function(post) {
var headRect, rect, root, thumb, x, y;
+
thumb = post.file.thumb;
if (!(post.file.isExpanded || $.hasClass(thumb, 'expanding'))) {
ImageExpand.expand(post);
@@ -6202,6 +6435,7 @@
root = post.nodes.root;
rect = (Conf['Advance on contract'] ? (function() {
var next;
+
next = root;
while (next = $.x("following::div[contains(@class,'postContainer')][1]", next)) {
if ($('.stub', next) || next.offsetHeight === 0) {
@@ -6232,6 +6466,7 @@
},
expand: function(post, src) {
var img, thumb;
+
thumb = post.file.thumb;
if (post.isHidden || post.file.isExpanded || $.hasClass(thumb, 'expanding')) {
return;
@@ -6259,6 +6494,7 @@
},
completeExpand: function(post) {
var prev, thumb;
+
thumb = post.file.thumb;
if (!$.hasClass(thumb, 'expanding')) {
return;
@@ -6272,6 +6508,7 @@
prev = post.nodes.root.getBoundingClientRect();
return $.queueTask(function() {
var curr;
+
$.addClass(post.nodes.root, 'expanded-image');
$.rmClass(post.file.thumb, 'expanding');
if (!(prev.top + prev.height <= 0)) {
@@ -6283,6 +6520,7 @@
},
error: function() {
var URL, post, src, timeoutID;
+
post = Get.postFromNode(this);
$.rm(this);
delete post.file.fullImage;
@@ -6308,6 +6546,7 @@
return $.ajax("//api.4chan.org/" + post.board + "/res/" + post.thread + ".json", {
onload: function() {
var postObj, _i, _len, _ref;
+
if (this.status !== 200) {
return;
}
@@ -6331,6 +6570,7 @@
menu: {
init: function() {
var conf, createSubEntry, el, name, subEntries, _ref;
+
if (g.VIEW === 'catalog' || !Conf['Image Expansion']) {
return;
}
@@ -6354,6 +6594,7 @@
},
createSubEntry: function(name, desc) {
var input, label;
+
label = $.el('label', {
innerHTML: " " + name,
title: desc
@@ -6387,6 +6628,7 @@
},
node: function() {
var _ref;
+
if (!((_ref = this.file) != null ? _ref.isImage : void 0)) {
return;
}
@@ -6394,6 +6636,7 @@
},
mouseover: function(e) {
var el, post;
+
post = Get.postFromNode(this);
el = $.el('img', {
id: 'ihover',
@@ -6415,6 +6658,7 @@
error: function() {
var URL, post, src, timeoutID,
_this = this;
+
if (!doc.contains(this)) {
return;
}
@@ -6439,6 +6683,7 @@
return $.ajax("//api.4chan.org/" + post.board + "/res/" + post.thread + ".json", {
onload: function() {
var postObj, _i, _len, _ref;
+
if (this.status !== 200) {
return;
}
@@ -6464,6 +6709,7 @@
ImageLoader = {
init: function() {
var prefetch;
+
if (g.VIEW === 'catalog') {
return;
}
@@ -6490,6 +6736,7 @@
},
node: function() {
var URL, img, string, style, thumb, type, _ref, _ref1;
+
if (this.isClone || this.isHidden || this.thread.isHidden || !((_ref = this.file) != null ? _ref.isImage : void 0)) {
return;
}
@@ -6511,6 +6758,7 @@
},
toggle: function() {
var enabled, id, post, _ref;
+
enabled = Conf['prefetch'] = this.checked;
if (enabled) {
_ref = g.threads["" + g.BOARD.ID + "." + g.THREADID].posts;
@@ -6534,6 +6782,7 @@
},
node: function() {
var thumb, _ref;
+
if (this.isClone || !((_ref = this.file) != null ? _ref.isSpoiler : void 0)) {
return;
}
@@ -6546,6 +6795,7 @@
Sauce = {
init: function() {
var err, link, links, _i, _len, _ref;
+
if (g.VIEW === 'catalog' || !Conf['Sauce']) {
return;
}
@@ -6575,6 +6825,7 @@
},
createSauceLink: function(link) {
var m, text;
+
link = link.replace(/%(T?URL|MD5|board)/ig, function(parameter) {
switch (parameter) {
case '%TURL':
@@ -6595,6 +6846,7 @@
},
node: function() {
var link, nodes, _i, _len, _ref;
+
if (this.isClone || !this.file) {
return;
}
@@ -6611,6 +6863,7 @@
ArchiveLink = {
init: function() {
var div, entry, type, _i, _len, _ref;
+
if (g.VIEW === 'catalog' || !Conf['Menu'] || !Conf['Archive Link']) {
return;
}
@@ -6623,6 +6876,7 @@
order: 90,
open: function(_arg) {
var ID, board, thread;
+
ID = _arg.ID, thread = _arg.thread, board = _arg.board;
return !!Redirect.to('thread', {
postID: ID,
@@ -6641,12 +6895,14 @@
},
createSubEntry: function(text, type) {
var el, open;
+
el = $.el('a', {
textContent: text,
target: '_blank'
});
open = type === 'post' ? function(_arg) {
var ID, board, thread;
+
ID = _arg.ID, thread = _arg.thread, board = _arg.board;
el.href = Redirect.to('thread', {
postID: ID,
@@ -6656,6 +6912,7 @@
return true;
} : function(post) {
var value;
+
value = Filter[type](post);
if (!value) {
return false;
@@ -6678,6 +6935,7 @@
DeleteLink = {
init: function() {
var div, fileEl, fileEntry, postEl, postEntry;
+
if (g.VIEW === 'catalog' || !Conf['Menu'] || !Conf['Delete Link']) {
return;
}
@@ -6705,6 +6963,7 @@
el: fileEl,
open: function(_arg) {
var file;
+
file = _arg.file;
if (!file || file.isDead) {
return false;
@@ -6720,6 +6979,7 @@
order: 40,
open: function(post) {
var node;
+
if (post.isDead || post.board.ID === 'q') {
return false;
}
@@ -6734,6 +6994,7 @@
},
"delete": function() {
var fileOnly, form, link, post;
+
post = DeleteLink.post;
if (DeleteLink.cooldown.counting === post) {
return;
@@ -6763,6 +7024,7 @@
},
load: function(link, post, fileOnly, resDoc) {
var msg, s;
+
if (resDoc.title === '4chan - Banned') {
s = 'Banned!';
} else if (msg = resDoc.getElementById('errmsg')) {
@@ -6783,6 +7045,7 @@
cooldown: {
start: function(post, node) {
var length, seconds, _ref;
+
if (!((_ref = QR.db) != null ? _ref.get({
boardID: post.board.ID,
threadID: post.thread.ID,
@@ -6816,6 +7079,7 @@
DownloadLink = {
init: function() {
var a;
+
if (g.VIEW === 'catalog' || !Conf['Menu'] || !Conf['Download Link']) {
return;
}
@@ -6829,6 +7093,7 @@
order: 100,
open: function(_arg) {
var file;
+
file = _arg.file;
if (!file) {
return false;
@@ -6861,6 +7126,7 @@
},
makeButton: (function() {
var a;
+
a = $.el('a', {
className: 'menu-button brackets-wrap',
innerHTML: '',
@@ -6868,6 +7134,7 @@
});
return function() {
var button;
+
button = a.cloneNode(true);
$.on(button, 'click', Menu.toggle);
return button;
@@ -6875,6 +7142,7 @@
})(),
toggle: function(e) {
var post;
+
post = Get.postFromNode(this);
return Menu.menu.toggle(e, this, post);
}
@@ -6883,6 +7151,7 @@
ReportLink = {
init: function() {
var a;
+
if (g.VIEW === 'catalog' || !Conf['Menu'] || !Conf['Report Link']) {
return;
}
@@ -6904,6 +7173,7 @@
},
report: function() {
var id, post, set, url;
+
post = ReportLink.post;
url = "//sys.4chan.org/" + post.board + "/imgboard.php?mode=report&no=" + post;
id = Date.now();
@@ -6916,6 +7186,7 @@
init: function() {
return $.ready(function() {
var href;
+
Favicon.el = $('link[rel="shortcut icon"]', d.head);
Favicon.el.type = 'image/x-icon';
href = Favicon.el.href;
@@ -6988,6 +7259,7 @@
init: function() {
var sc,
_this = this;
+
if (g.VIEW !== 'thread' || !Conf['Thread Stats']) {
return;
}
@@ -7016,6 +7288,7 @@
},
node: function() {
var ID, fileCount, post, postCount, _ref;
+
postCount = 0;
fileCount = 0;
_ref = this.posts;
@@ -7033,6 +7306,7 @@
},
onUpdate: function(e) {
var fileCount, postCount, _ref;
+
if (e.detail[404]) {
return;
}
@@ -7041,6 +7315,7 @@
},
update: function(postCount, fileCount) {
var fileCountEl, postCountEl, thread;
+
thread = ThreadStats.thread, postCountEl = ThreadStats.postCountEl, fileCountEl = ThreadStats.fileCountEl;
postCountEl.textContent = postCount;
fileCountEl.textContent = fileCount;
@@ -7065,6 +7340,7 @@
},
onThreadsLoad: function() {
var page, pages, thread, _i, _j, _len, _len1, _ref;
+
if (!(Conf["Page Count in Stats"] && this.status === 200)) {
return;
}
@@ -7088,6 +7364,7 @@
init: function() {
var checked, conf, el, input, name, sc, settings, subEntries, _ref,
_this = this;
+
if (g.VIEW !== 'thread' || !Conf['Thread Updater']) {
return;
}
@@ -7237,6 +7514,7 @@
},
interval: function() {
var val;
+
val = +this.value;
if (val < 1) {
val = 1;
@@ -7246,6 +7524,7 @@
},
load: function() {
var klass, req, text, _ref;
+
req = ThreadUpdater.req;
switch (req.status) {
case 200:
@@ -7278,6 +7557,7 @@
},
getInterval: function() {
var i, j;
+
i = ThreadUpdater.interval;
j = Math.min(ThreadUpdater.outdateCount, 10);
if (!d.hidden) {
@@ -7287,12 +7567,14 @@
},
intervalShortcut: function() {
var settings;
+
Settings.open('Advanced');
settings = $.id('fourchanx-settings');
return $('input[name=Interval]', settings).focus();
},
set: function(name, text, klass) {
var el, node;
+
el = ThreadUpdater[name];
if (node = el.firstChild) {
node.data = text;
@@ -7305,6 +7587,7 @@
},
timeout: function() {
var n;
+
ThreadUpdater.timeoutID = setTimeout(ThreadUpdater.timeout, 1000);
if (!(n = --ThreadUpdater.seconds)) {
return ThreadUpdater.update();
@@ -7317,6 +7600,7 @@
},
update: function() {
var url;
+
if (!ThreadUpdater.online) {
return;
}
@@ -7339,6 +7623,7 @@
},
updateThreadStatus: function(title, OP) {
var icon, message, root, titleLC;
+
titleLC = title.toLowerCase();
if (ThreadUpdater.thread["is" + title] === !!OP[titleLC]) {
return;
@@ -7365,6 +7650,7 @@
},
parse: function(postObjects) {
var ID, OP, count, deletedFiles, deletedPosts, files, index, key, node, num, post, postObject, posts, root, scroll, _i, _len, _ref;
+
OP = postObjects[0];
Build.spoilerRange[ThreadUpdater.thread.board] = OP.custom_spoiler;
ThreadUpdater.updateThreadStatus('Sticky', OP);
@@ -7450,6 +7736,7 @@
}
$.queueTask(function() {
var length, threadID;
+
threadID = ThreadUpdater.thread.ID;
length = $$('.thread > .postContainer', ThreadUpdater.root).length;
return Fourchan.parseThread(threadID, length - count, length);
@@ -7470,6 +7757,7 @@
ThreadWatcher = {
init: function() {
var now, sc;
+
if (!Conf['Thread Watcher']) {
return;
}
@@ -7502,6 +7790,7 @@
}
$.get('WatchedThreads', null, function(_arg) {
var WatchedThreads, boardID, data, threadID, threads, _ref;
+
WatchedThreads = _arg.WatchedThreads;
if (!WatchedThreads) {
return;
@@ -7527,6 +7816,7 @@
},
node: function() {
var toggler;
+
toggler = $.el('img', {
className: 'watch-thread-link'
});
@@ -7548,6 +7838,7 @@
}
return $.get('AutoWatch', 0, function(_arg) {
var AutoWatch, thread;
+
AutoWatch = _arg.AutoWatch;
if (!(thread = g.BOARD.threads[AutoWatch])) {
return;
@@ -7563,6 +7854,7 @@
cb: {
openAll: function() {
var a, _i, _len, _ref;
+
if ($.hasClass(this, 'disabled')) {
return;
}
@@ -7581,6 +7873,7 @@
},
pruneDeads: function() {
var boardID, data, threadID, _i, _len, _ref, _ref1;
+
if ($.hasClass(this, 'disabled')) {
return;
}
@@ -7604,11 +7897,13 @@
},
rm: function() {
var boardID, threadID, _ref;
+
_ref = this.parentNode.dataset.fullID.split('.'), boardID = _ref[0], threadID = _ref[1];
return ThreadWatcher.rm(boardID, +threadID);
},
post: function(e) {
var board, postID, threadID, _ref;
+
_ref = e.detail, board = _ref.board, postID = _ref.postID, threadID = _ref.threadID;
if (postID === threadID) {
if (Conf['Auto Watch']) {
@@ -7620,6 +7915,7 @@
},
threadUpdate: function(e) {
var thread;
+
thread = e.detail.thread;
if (!(e.detail[404] && ThreadWatcher.db.get({
boardID: thread.board.ID,
@@ -7636,6 +7932,7 @@
},
fetchAllStatus: function() {
var thread, threads, _i, _len;
+
if (!(threads = ThreadWatcher.getAll()).length) {
return;
}
@@ -7647,6 +7944,7 @@
},
fetchStatus: function(_arg) {
var boardID, data, fetchCount, threadID;
+
boardID = _arg.boardID, threadID = _arg.threadID, data = _arg.data;
if (data.isDead) {
return;
@@ -7656,6 +7954,7 @@
return $.ajax("//api.4chan.org/" + boardID + "/res/" + threadID + ".json", {
onloadend: function() {
var status;
+
fetchCount.fetched++;
if (fetchCount.fetched === fetchCount.fetching) {
fetchCount.fetched = 0;
@@ -7686,6 +7985,7 @@
},
getAll: function() {
var all, boardID, data, threadID, threads, _ref;
+
all = [];
_ref = ThreadWatcher.db.data.boards;
for (boardID in _ref) {
@@ -7706,6 +8006,7 @@
},
makeLine: function(boardID, threadID, data) {
var div, fullID, href, link, x;
+
x = $.el('a', {
textContent: '×',
href: 'javascript:;'
@@ -7736,6 +8037,7 @@
},
refresh: function() {
var boardID, data, list, nodes, refresher, thread, threadID, toggler, watched, _i, _j, _len, _len1, _ref, _ref1, _ref2, _ref3;
+
nodes = [];
_ref = ThreadWatcher.getAll();
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
@@ -7763,6 +8065,7 @@
},
toggle: function(thread) {
var boardID, threadID;
+
boardID = thread.board.ID;
threadID = thread.ID;
if (ThreadWatcher.db.get({
@@ -7776,6 +8079,7 @@
},
add: function(thread) {
var boardID, data, threadID;
+
data = {};
boardID = thread.board.ID;
threadID = thread.ID;
@@ -7806,6 +8110,7 @@
},
convert: function(oldFormat) {
var boardID, data, newFormat, threadID, threads;
+
newFormat = {};
for (boardID in oldFormat) {
threads = oldFormat[boardID];
@@ -7822,6 +8127,7 @@
refreshers: [],
init: function() {
var menu;
+
if (!Conf['Thread Watcher']) {
return;
}
@@ -7834,6 +8140,7 @@
},
addHeaderMenuEntry: function() {
var entryEl;
+
if (g.VIEW !== 'thread') {
return;
}
@@ -7850,6 +8157,7 @@
});
return this.refreshers.push(function() {
var addClass, rmClass, text, _ref;
+
_ref = $('.current', ThreadWatcher.list) ? ['unwatch-thread', 'watch-thread', 'Unwatch thread'] : ['watch-thread', 'unwatch-thread', 'Watch thread'], addClass = _ref[0], rmClass = _ref[1], text = _ref[2];
$.addClass(entryEl, addClass);
$.rmClass(entryEl, rmClass);
@@ -7858,6 +8166,7 @@
},
addMenuEntries: function() {
var cb, conf, entries, entry, name, refresh, subEntries, _i, _len, _ref, _ref1, _results;
+
entries = [];
entries.push({
cb: ThreadWatcher.cb.openAll,
@@ -7928,6 +8237,7 @@
},
createSubEntry: function(name, desc) {
var entry, input;
+
entry = {
type: 'thread watcher',
el: $.el('label', {
@@ -7979,6 +8289,7 @@
},
ready: function() {
var ID, post, posts, _ref;
+
$.off(d, '4chanXInitFinished', Unread.ready);
posts = [];
_ref = Unread.thread.posts;
@@ -7995,6 +8306,7 @@
},
scroll: function() {
var checkPosition, hash, onload, post, posts, root;
+
if ((hash = location.hash.match(/\d+/)) && hash[0] in Unread.thread.posts) {
return;
}
@@ -8024,6 +8336,7 @@
}
checkPosition = function(target) {
var height, top, _ref;
+
_ref = target.getBoundingClientRect(), top = _ref.top, height = _ref.height;
return top + height - doc.clientHeight > 0;
};
@@ -8031,6 +8344,7 @@
},
sync: function() {
var lastReadPost;
+
lastReadPost = Unread.db.get({
boardID: Unread.thread.board.ID,
threadID: Unread.thread.ID,
@@ -8047,6 +8361,7 @@
},
addPosts: function(posts) {
var ID, data, post, _i, _len;
+
for (_i = 0, _len = posts.length; _i < _len; _i++) {
post = posts[_i];
ID = post.ID;
@@ -8074,6 +8389,7 @@
},
addPostQuotingYou: function(post) {
var quotelink, _i, _len, _ref;
+
if (!QR.db) {
return;
}
@@ -8094,6 +8410,7 @@
},
readSinglePost: function(post) {
var i;
+
if ((i = Unread.posts.indexOf(post)) === -1) {
return;
}
@@ -8109,6 +8426,7 @@
},
readArray: function(arr) {
var i, post, _i, _len;
+
for (i = _i = 0, _len = arr.length; _i < _len; i = ++_i) {
post = arr[i];
if (post.ID > Unread.lastReadPost) {
@@ -8119,6 +8437,7 @@
},
read: $.debounce(50, function(e) {
var ID, bottom, height, i, post, posts;
+
if (d.hidden || !Unread.posts.length) {
return;
}
@@ -8174,6 +8493,7 @@
}),
setLine: function(force) {
var post, root;
+
if (!(d.hidden || force === true)) {
return;
}
@@ -8188,6 +8508,7 @@
},
update: function() {
var count;
+
count = Unread.posts.length;
if (Conf['Unread Count']) {
d.title = "" + (Conf['Quoted Title'] && Unread.postsQuotingYou.length ? '(!) ' : '') + (count || !Conf['Hide Unread Count at (0)'] ? "(" + count + ") " : '') + (g.DEAD ? "/" + g.BOARD + "/ - 404" : "" + Unread.title);
@@ -8208,6 +8529,7 @@
},
init: function() {
var archive, boardID, boards, data, id, name, type, _i, _len, _ref, _ref1, _ref2;
+
_ref = Conf['selectedArchives'];
for (boardID in _ref) {
data = _ref[boardID];
@@ -8339,6 +8661,7 @@
},
to: function(dest, data) {
var archive;
+
archive = (dest === 'search' ? Redirect.data.thread : Redirect.data[dest])[data.boardID];
if (!archive) {
return '';
@@ -8347,6 +8670,7 @@
},
protocol: function(archive) {
var protocol;
+
protocol = location.protocol;
if (!archive[protocol.slice(0, -1)]) {
protocol = protocol === 'https:' ? 'http:' : 'https:';
@@ -8355,6 +8679,7 @@
},
thread: function(archive, _arg) {
var boardID, path, postID, threadID;
+
boardID = _arg.boardID, threadID = _arg.threadID, postID = _arg.postID;
path = threadID ? "" + boardID + "/thread/" + threadID : "" + boardID + "/post/" + postID;
if (archive.software === 'foolfuuka') {
@@ -8367,6 +8692,7 @@
},
post: function(archive, _arg) {
var URL, boardID, postID, protocol;
+
boardID = _arg.boardID, postID = _arg.postID;
protocol = Redirect.protocol(archive);
if (['Foolz', 'NSFW Foolz'].contains(archive.name)) {
@@ -8378,11 +8704,13 @@
},
file: function(archive, _arg) {
var boardID, filename;
+
boardID = _arg.boardID, filename = _arg.filename;
return "" + (Redirect.protocol(archive)) + archive.domain + "/" + boardID + "/full_image/" + filename;
},
search: function(archive, _arg) {
var boardID, path, type, value;
+
boardID = _arg.boardID, type = _arg.type, value = _arg.value;
type = type === 'name' ? 'username' : type === 'MD5' ? 'image' : type;
value = encodeURIComponent(value);
@@ -8401,6 +8729,7 @@
},
setup: function() {
var btn, entry, psa;
+
$.off(d, '4chanXInitFinished', PSAHiding.setup);
if (!(psa = $.id('globalMessage'))) {
$.rmClass(doc, 'hide-announcement');
@@ -8429,6 +8758,7 @@
$.on(btn, 'click', PSAHiding.toggle);
$.get('hiddenPSA', 0, function(_arg) {
var hiddenPSA;
+
hiddenPSA = _arg.hiddenPSA;
PSAHiding.sync(hiddenPSA);
$.before(psa, btn);
@@ -8438,6 +8768,7 @@
},
toggle: function(e) {
var UTC;
+
if ($.hasClass(this, 'hide-announcement')) {
UTC = +$.id('globalMessage').dataset.utc;
$.set('hiddenPSA', UTC);
@@ -8449,6 +8780,7 @@
},
sync: function(UTC) {
var hr, psa;
+
psa = $.id('globalMessage');
psa.hidden = PSAHiding.btn.hidden = UTC && UTC >= +psa.dataset.utc ? true : false;
if ((hr = psa.nextElementSibling) && hr.nodeName === 'HR') {
@@ -8460,6 +8792,7 @@
CatalogLinks = {
init: function() {
var el, input;
+
if (!Conf['Catalog Links']) {
return;
}
@@ -8483,12 +8816,14 @@
},
toggle: function() {
var useCatalog;
+
$.event('CloseMenu');
$.set('Header catalog links', useCatalog = this.checked);
return CatalogLinks.set(useCatalog);
},
set: function(useCatalog) {
var a, board, path, _i, _len, _ref;
+
path = useCatalog ? 'catalog' : '';
_ref = $$("#board-list a[href*=\"boards.4chan.org\"]:not(.catalog),\n#boardNavDesktopFoot a[href*=\"boards.4chan.org\"]");
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
@@ -8512,7 +8847,7 @@
IDColor = {
init: function() {
- if (g.VIEW === 'catalog' || !Conf['Color user IDs']) {
+ if (g.VIEW === 'catalog' || !Conf['Color User IDs']) {
return;
}
return Post.prototype.callbacks.push({
@@ -8522,6 +8857,7 @@
},
node: function() {
var str, uid;
+
if (this.isClone || !(str = this.info.uniqueID)) {
return;
}
@@ -8534,6 +8870,7 @@
ids: {},
compute: function(str) {
var hash, rgb;
+
hash = IDColor.hash(str);
rgb = [(hash >> 24) & 0xFF, (hash >> 16) & 0xFF, (hash >> 8) & 0xFF];
rgb[3] = ((rgb[0] * 0.299) + (rgb[1] * 0.587) + (rgb[2] * 0.114)) > 125;
@@ -8545,6 +8882,7 @@
},
hash: function(str) {
var i, j, msg;
+
msg = 0;
i = 0;
j = str.length;
@@ -8592,6 +8930,7 @@
},
node: function() {
var dicestats, roll, _ref;
+
if (this.isClone || !(dicestats = (_ref = this.info.email) != null ? _ref.match(/dice[+\s](\d+)d(\d+)/) : void 0)) {
return;
}
@@ -8603,6 +8942,7 @@
Emoji = {
init: function() {
var css, icon, name, pos, _ref;
+
if (!Conf['Emoji']) {
return;
}
@@ -8672,6 +9012,7 @@
},
node: function() {
var a;
+
if (a = $('.abbr > a:not([onclick])', this.nodes.comment)) {
return $.on(a, 'click', ExpandComment.cb);
}
@@ -8683,6 +9024,7 @@
},
expand: function(post) {
var a;
+
if (post.nodes.longComment && !post.nodes.longComment.parentNode) {
$.replace(post.nodes.shortComment, post.nodes.longComment);
post.nodes.comment = post.nodes.longComment;
@@ -8698,6 +9040,7 @@
},
contract: function(post) {
var a;
+
if (!post.nodes.shortComment) {
return;
}
@@ -8708,6 +9051,7 @@
},
parse: function(req, a, post) {
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)) {
a.textContent = "Error " + req.statusText + " (" + status + ")";
@@ -8770,6 +9114,7 @@
},
node: function() {
var a, files, posts, span, _ref;
+
if (!(span = $.x('following-sibling::span[contains(@class,"summary")][1]', this.OP.nodes.root))) {
return;
}
@@ -8790,6 +9135,7 @@
},
toggle: function(thread) {
var a, files, filesCount, inlined, num, post, posts, postsCount, reply, threadRoot, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2, _ref3, _ref4;
+
threadRoot = thread.OP.nodes.root.parentNode;
a = $('.summary', threadRoot);
switch (thread.isExpanded) {
@@ -8867,6 +9213,7 @@
},
parse: function(req, thread, a) {
var filesCount, link, post, posts, postsCount, postsObj, postsRoot, reply, root, spoilerRange, _i, _len;
+
if (a.textContent[0] === '+') {
return;
}
@@ -8930,6 +9277,7 @@
},
createFunc: function(format) {
var code;
+
code = format.replace(/%(.)/g, function(s, c) {
if (c in FileInfo.formatters) {
return "' + FileInfo.formatters." + c + ".call(post) + '";
@@ -8941,6 +9289,7 @@
},
convertUnit: function(size, unit) {
var i;
+
if (unit === 'B') {
return "" + (size.toFixed()) + " Bytes";
}
@@ -8971,6 +9320,7 @@
},
n: function() {
var fullname, shortname;
+
fullname = this.file.name;
shortname = Build.shortFilename(this.file.name, this.isReply);
if (fullname === shortname) {
@@ -9014,6 +9364,7 @@
Fourchan = {
init: function() {
var board;
+
if (g.VIEW === 'catalog') {
return;
}
@@ -9035,6 +9386,7 @@
},
code: function() {
var pre, _i, _len, _ref;
+
if (this.isClone) {
return;
}
@@ -9064,11 +9416,13 @@
Keybinds = {
init: function() {
var init;
+
if (g.VIEW === 'catalog' || !Conf['Keybinds']) {
return;
}
init = function() {
var node, _i, _len, _ref;
+
$.off(d, '4chanXInitFinished', init);
$.on(d, 'keydown', Keybinds.keydown);
_ref = $$('[accesskey]');
@@ -9081,6 +9435,7 @@
},
keydown: function(e) {
var form, key, notification, notifications, op, target, thread, threadRoot, _i, _len;
+
if (!(key = Keybinds.keyCode(e))) {
return;
}
@@ -9261,6 +9616,7 @@
},
keyCode: function(e) {
var kc, key;
+
key = (function() {
switch (kc = e.keyCode) {
case 8:
@@ -9316,6 +9672,7 @@
},
tags: function(tag, ta) {
var range, selEnd, selStart, value;
+
value = ta.value;
selStart = ta.selectionStart;
selEnd = ta.selectionEnd;
@@ -9326,11 +9683,13 @@
},
sage: function() {
var isSage;
+
isSage = /sage/i.test(QR.nodes.email.value);
return QR.nodes.email.value = isSage ? "" : "sage";
},
img: function(thread, all) {
var post;
+
if (all) {
return ImageExpand.cb.toggleAll();
} else {
@@ -9340,6 +9699,7 @@
},
open: function(thread, tab) {
var url;
+
if (g.VIEW !== 'index') {
return;
}
@@ -9352,6 +9712,7 @@
},
hl: function(delta, thread) {
var axe, headRect, next, postEl, rect, replies, reply, root, topMargin, _i, _len;
+
if (!delta) {
if (postEl = $('.reply.highlight', thread)) {
$.rmClass(postEl, 'highlight');
@@ -9411,6 +9772,7 @@
Nav = {
init: function() {
var append, next, prev, span;
+
switch (g.VIEW) {
case 'index':
if (!Conf['Index Navigation']) {
@@ -9461,6 +9823,7 @@
},
getThread: function(full) {
var headRect, i, rect, thread, threads, topMargin, _i, _len;
+
if (Conf['Bottom header'] || !Conf['Fixed Header']) {
topMargin = 0;
} else {
@@ -9486,6 +9849,7 @@
},
scroll: function(delta) {
var i, rect, thread, threads, top, topMargin, _ref, _ref1;
+
_ref = Nav.getThread(true), threads = _ref[0], thread = _ref[1], i = _ref[2], rect = _ref[3], topMargin = _ref[4];
top = rect.top - topMargin;
if ((delta === -1 && top > -5) || (delta === +1 && top < 5)) {
@@ -9510,6 +9874,7 @@
},
node: function() {
var dateEl;
+
if (this.isClone) {
return;
}
@@ -9519,6 +9884,7 @@
},
relative: function(diff, now, date) {
var days, months, number, rounded, unit, years;
+
unit = (number = diff / $.DAY) >= 1 ? (years = now.getYear() - date.getYear(), months = now.getMonth() - date.getMonth(), days = now.getDate() - date.getDate(), years > 1 ? (number = years - (months < 0 || months === 0 && days < 0), 'year') : years === 1 && (months > 0 || months === 0 && days >= 0) ? (number = years, 'year') : (months = (months + 12) % 12) > 1 ? (number = months - (days < 0), 'month') : months === 1 && days >= 0 ? (number = months, 'month') : 'day') : (number = diff / $.HOUR) >= 1 ? 'hour' : (number = diff / $.MINUTE) >= 1 ? 'minute' : (number = Math.max(0, diff) / $.SECOND, 'second');
rounded = Math.round(number);
if (rounded !== 1) {
@@ -9529,6 +9895,7 @@
stale: [],
flush: function() {
var now, update, _i, _len, _ref;
+
if (d.hidden) {
return;
}
@@ -9544,13 +9911,16 @@
},
setUpdate: function(post) {
var markStale, setOwnTimeout, update;
+
setOwnTimeout = function(diff) {
var delay;
+
delay = diff < $.MINUTE ? $.SECOND - (diff + $.SECOND / 2) % $.SECOND : diff < $.HOUR ? $.MINUTE - (diff + $.MINUTE / 2) % $.MINUTE : diff < $.DAY ? $.HOUR - (diff + $.HOUR / 2) % $.HOUR : $.DAY - (diff + $.DAY / 2) % $.DAY;
return setTimeout(markStale, delay);
};
update = function(now) {
var date, diff, relative, singlePost, _i, _len, _ref;
+
date = post.info.date;
diff = now - date;
relative = RelativeDates.relative(diff, now, date);
@@ -9591,6 +9961,7 @@
},
node: function(post) {
var spoiler, spoilers, _i, _len;
+
spoilers = $$('s', this.nodes.comment);
for (_i = 0, _len = spoilers.length; _i < _len; _i++) {
spoiler = spoilers[_i];
@@ -9610,6 +9981,7 @@
},
ready: function() {
var field;
+
field = $.id('recaptcha_response_field');
$.on(field, 'keydown', function(e) {
if (e.keyCode === 8 && !field.value) {
@@ -9618,6 +9990,7 @@
});
return $.on($('form'), 'submit', function(e) {
var response;
+
e.preventDefault();
response = field.value.trim();
if (!/\s/.test(response)) {
@@ -9647,6 +10020,7 @@
},
createFunc: function(format) {
var code;
+
code = format.replace(/%([A-Za-z])/g, function(s, c) {
if (c in Time.formatters) {
return "' + Time.formatters." + c + ".call(date) + '";
@@ -9731,6 +10105,7 @@
Settings = {
init: function() {
var link, settings;
+
link = $.el('a', {
className: 'settings-link',
textContent: 'Settings',
@@ -9740,6 +10115,7 @@
Header.addShortcut(link);
$.get('previousversion', null, function(item) {
var changelog, el, previous;
+
if (previous = item['previousversion']) {
if (previous === g.VERSION) {
return;
@@ -9774,6 +10150,7 @@
},
open: function(openSection) {
var dialog, html, link, links, overlay, section, sectionToOpen, _i, _len, _ref;
+
$.off(d, '4chanXInitFinished', Settings.open);
if (Settings.dialog) {
return;
@@ -9826,6 +10203,7 @@
sections: [],
addSection: function(title, open) {
var hyphenatedTitle, _ref;
+
if (typeof title !== 'string') {
_ref = title.detail, title = _ref.title, open = _ref.open;
}
@@ -9838,6 +10216,7 @@
},
openSection: function() {
var section, selected;
+
if (selected = $('.tab-selected', Settings.dialog)) {
$.rmClass(selected, 'tab-selected');
}
@@ -9851,6 +10230,7 @@
},
main: function(section) {
var arr, button, description, div, fs, hiddenNum, input, inputs, items, key, obj, _ref;
+
items = {};
inputs = {};
_ref = Config.main;
@@ -9875,6 +10255,7 @@
}
$.get(items, function(items) {
var val;
+
for (key in items) {
val = items[key];
inputs[key].checked = val;
@@ -9889,6 +10270,7 @@
boards: {}
}, function(item) {
var ID, board, thread, _ref1;
+
_ref1 = item.hiddenThreads.boards;
for (ID in _ref1) {
board = _ref1[ID];
@@ -9903,6 +10285,7 @@
boards: {}
}, function(item) {
var ID, board, post, thread, _ref1;
+
_ref1 = item.hiddenPosts.boards;
for (ID in _ref1) {
board = _ref1[ID];
@@ -9922,6 +10305,7 @@
boards: {}
}, function(item) {
var boardID;
+
for (boardID in item.hiddenThreads.boards) {
localStorage.removeItem("4chan-hide-t-" + boardID);
}
@@ -9932,6 +10316,7 @@
},
"export": function(now, data) {
var a, db, p, _i, _len;
+
if (typeof now !== 'number') {
now = Date.now();
data = {
@@ -9967,6 +10352,7 @@
},
onImport: function() {
var file, output, reader;
+
if (!(file = this.files[0])) {
return;
}
@@ -9978,6 +10364,7 @@
reader = new FileReader();
reader.onload = function(e) {
var data, err;
+
try {
data = JSON.parse(e.target.result);
Settings.loadSettings(data);
@@ -9994,6 +10381,7 @@
},
loadSettings: function(data) {
var key, val, version, _ref;
+
version = data.version.split('.');
if (version[0] === '2') {
data = Settings.convertSettings(data, {
@@ -10081,6 +10469,7 @@
},
convertSettings: function(data, map) {
var newKey, prevKey;
+
for (prevKey in map) {
newKey = map[prevKey];
if (newKey) {
@@ -10092,6 +10481,7 @@
},
filter: function(section) {
var select;
+
section.innerHTML = "";
select = $('select', section);
$.on(select, 'change', Settings.selectFilter);
@@ -10099,6 +10489,7 @@
},
selectFilter: function() {
var div, name, ta;
+
div = this.nextElementSibling;
if ((name = this.value) !== 'guide') {
$.rmAll(div);
@@ -10118,6 +10509,7 @@
},
sauce: function(section) {
var ta;
+
section.innerHTML = " Sauce is disabled.
Lines starting with a # will be ignored.
You can specify a display text by appending ;text:[text] to the URL.
These parameters will be replaced by their corresponding values:\n%TURL: Thumbnail URL.%URL: Full image URL.%MD5: MD5 hash.%board: Current board.
";
ta = $('textarea', section);
$.get('sauces', Conf['sauces'], function(item) {
@@ -10127,6 +10519,7 @@
},
advanced: function(section) {
var archive, boardID, boardOptions, boardSelect, boards, data, event, input, inputs, item, items, name, row, rows, ta, table, _i, _j, _k, _l, _len, _len1, _len2, _len3, _ref, _ref1, _ref2, _ref3, _ref4;
+
section.innerHTML = " ";
items = {};
inputs = {};
@@ -10146,6 +10539,7 @@
$.on(ta, 'change', $.cb.value);
$.get(items, function(items) {
var key, val;
+
for (key in items) {
val = items[key];
if (['emojiPos'].contains(key)) {
@@ -10216,6 +10610,7 @@
});
$.get('selectedArchives', Conf['selectedArchives'], function(_arg) {
var option, selectedArchives, type;
+
selectedArchives = _arg.selectedArchives;
for (boardID in selectedArchives) {
data = selectedArchives[boardID];
@@ -10230,6 +10625,7 @@
},
addArchiveCell: function(boardID, data, type) {
var archive, i, length, options, select, td;
+
length = data[type].length;
td = $.el('td', {
className: 'archive-cell'
@@ -10259,8 +10655,10 @@
},
saveSelectedArchive: function() {
var _this = this;
+
return $.get('selectedArchives', Conf['selectedArchives'], function(_arg) {
var selectedArchives, _name;
+
selectedArchives = _arg.selectedArchives;
(selectedArchives[_name = _this.dataset.boardid] || (selectedArchives[_name] = {}))[_this.dataset.type] = _this.value;
return $.set('selectedArchives', selectedArchives);
@@ -10271,6 +10669,7 @@
},
time: function() {
var funk;
+
funk = Time.createFunc(this.value);
return this.nextElementSibling.textContent = funk(Time, new Date());
},
@@ -10279,6 +10678,7 @@
},
fileInfo: function() {
var data, funk;
+
data = {
isReply: true,
file: {
@@ -10317,6 +10717,7 @@
},
keybinds: function(section) {
var arr, input, inputs, items, key, tbody, tr, _ref;
+
section.innerHTML = "Keybinds are disabled.
Allowed keys: a-z, 0-9, Ctrl, Shift, Alt, Meta, Enter, Esc, Up, Down, Right, Left.
Press Backspace to disable a keybind.
";
tbody = $('tbody', section);
items = {};
@@ -10337,6 +10738,7 @@
}
return $.get(items, function(items) {
var val;
+
for (key in items) {
val = items[key];
inputs[key].value = val;
@@ -10345,6 +10747,7 @@
},
keybind: function(e) {
var key;
+
if (e.keyCode === 9) {
return;
}
@@ -10361,8 +10764,10 @@
Main = {
init: function() {
var db, flatten, _i, _len;
+
flatten = function(parent, obj) {
var key, val;
+
if (obj instanceof Array) {
Conf[parent] = obj[0];
} else if (typeof obj === 'object') {
@@ -10394,6 +10799,7 @@
},
initFeatures: function() {
var init, pathname, _ref;
+
pathname = location.pathname.split('/');
g.BOARD = new Board(pathname[1]);
if ((_ref = g.BOARD.ID) === 'z' || _ref === 'fk') {
@@ -10421,6 +10827,7 @@
case 'images.4chan.org':
$.ready(function() {
var URL;
+
if (Conf['404 Redirect'] && ['4chan - Temporarily Offline', '4chan - 404 Not Found'].contains(d.title)) {
Redirect.init();
pathname = location.pathname.split('/');
@@ -10437,6 +10844,7 @@
}
init = function(features) {
var err, module, name;
+
for (name in features) {
module = features[name];
try {
@@ -10514,6 +10922,7 @@
},
initStyle: function() {
var mainStyleSheet, setStyle, style, styleSheets, _ref;
+
$.off(d, '4chanMainInit', Main.initStyle);
if (!Main.isThisPageLegit() || $.hasClass(doc, 'fourchan-x')) {
return;
@@ -10535,6 +10944,7 @@
styleSheets = $$('link[rel="alternate stylesheet"]', d.head);
setStyle = function() {
var styleSheet, _i, _len;
+
$.rmClass(doc, style);
for (_i = 0, _len = styleSheets.length; _i < _len; _i++) {
styleSheet = styleSheets[_i];
@@ -10556,6 +10966,7 @@
},
initReady: function() {
var board, err, errors, href, passLink, postRoot, posts, styleSelector, thread, threadRoot, threads, _i, _j, _len, _len1, _ref, _ref1;
+
if (['4chan - Temporarily Offline', '4chan - 404 Not Found'].contains(d.title)) {
if (Conf['404 Redirect'] && g.VIEW === 'thread') {
href = Redirect.to('thread', {
@@ -10622,6 +11033,7 @@
},
callbackNodes: function(klass, nodes) {
var callback, err, errors, i, len, node, _i, _len, _ref;
+
len = nodes.length;
_ref = klass.prototype.callbacks;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
@@ -10649,9 +11061,11 @@
},
callbackNodesDB: function(klass, nodes, cb) {
var errors, func, i, len, node, queue, softTask;
+
queue = [];
softTask = function() {
var args, func, task;
+
task = queue.shift();
func = task[0];
args = Array.prototype.slice.call(task, 1);
@@ -10670,6 +11084,7 @@
errors = null;
func = function(node, i) {
var callback, err, _i, _len, _ref;
+
_ref = klass.prototype.callbacks;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
callback = _ref[_i];
@@ -10703,6 +11118,7 @@
},
addCallback: function(e) {
var Klass, obj;
+
obj = e.detail;
if (typeof obj.callback.name !== 'string') {
throw new Error("Invalid callback name: " + obj.callback.name);
@@ -10722,6 +11138,7 @@
},
handleErrors: function(errors) {
var div, error, logs, _i, _len;
+
if (!(errors instanceof Array)) {
error = errors;
} else if (errors.length === 1) {
@@ -10736,6 +11153,7 @@
});
$.on(div.lastElementChild, 'click', function() {
var _ref;
+
return _ref = this.textContent === 'show' ? ['hide', false] : ['show', true], this.textContent = _ref[0], logs.hidden = _ref[1], _ref;
});
logs = $.el('div', {
@@ -10749,6 +11167,7 @@
},
parseError: function(data) {
var error, message;
+
Main.logError(data);
message = $.el('div', {
textContent: data.message
@@ -10765,6 +11184,7 @@
},
isThisPageLegit: function() {
var _ref;
+
if (!('thisPageIsLegit' in Main)) {
Main.thisPageIsLegit = location.hostname === 'boards.4chan.org' && !$('link[href*="favicon-status.ico"]', d.head) && ((_ref = d.title) !== '4chan - Temporarily Offline' && _ref !== '4chan - Error' && _ref !== '504 Gateway Time-out');
}
diff --git a/builds/crx/manifest.json b/builds/crx/manifest.json
index b05f0afcd..2353e1607 100755
--- a/builds/crx/manifest.json
+++ b/builds/crx/manifest.json
@@ -1,6 +1,6 @@
{
"name": "4chan X",
- "version": "1.2.28",
+ "version": "1.2.29",
"manifest_version": 2,
"description": "Cross-browser userscript for maximum lurking on 4chan.",
"icons": {
diff --git a/builds/crx/script.js b/builds/crx/script.js
index 6c9502770..8b0b1986f 100644
--- a/builds/crx/script.js
+++ b/builds/crx/script.js
@@ -1,6 +1,6 @@
// Generated by CoffeeScript
/*
-* 4chan X - Version 1.2.28 - 2013-08-15
+* 4chan X - Version 1.2.29 - 2013-08-15
*
* Licensed under the MIT license.
* https://github.com/seaweedchan/4chan-x/blob/master/LICENSE
@@ -308,7 +308,7 @@
doc = d.documentElement;
g = {
- VERSION: '1.2.28',
+ VERSION: '1.2.29',
NAMESPACE: '4chan X.',
boards: {},
threads: {},
@@ -329,6 +329,7 @@
Array.prototype.indexOf = function(object) {
var i;
+
i = this.length;
while (i--) {
if (this[i] === object) {
@@ -347,6 +348,7 @@
$.extend = function(object, properties) {
var key, val;
+
for (key in properties) {
val = properties[key];
if (!properties.hasOwnProperty(key)) {
@@ -364,6 +366,7 @@
$.ready = function(fc) {
var cb;
+
if (d.readyState !== 'loading') {
$.queueTask(fc);
return;
@@ -377,6 +380,7 @@
$.formData = function(form) {
var fd, key, val;
+
if (form instanceof HTMLFormElement) {
return new FormData(form);
}
@@ -396,6 +400,7 @@
$.extend = function(object, properties) {
var key, val;
+
for (key in properties) {
val = properties[key];
object[key] = val;
@@ -404,9 +409,11 @@
$.ajax = (function() {
var lastModified;
+
lastModified = {};
return function(url, options, extra) {
var form, r, sync, type, upCallbacks, whenModified;
+
if (extra == null) {
extra = {};
}
@@ -429,9 +436,11 @@
$.cache = (function() {
var reqs;
+
reqs = {};
return function(url, cb, options) {
var err, req, rm;
+
if (req = reqs[url]) {
if (req.readyState === 4) {
cb.call(req, req.evt);
@@ -451,6 +460,7 @@
}
$.on(req, 'load', function(e) {
var _i, _len, _ref;
+
_ref = this.callbacks;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
cb = _ref[_i];
@@ -486,6 +496,7 @@
$.addStyle = function(css, id) {
var style;
+
style = $.el('style', {
id: id,
textContent: css
@@ -532,6 +543,7 @@
} else {
return function(el) {
var _ref;
+
return (_ref = el.parentNode) != null ? _ref.removeChild(el) : void 0;
};
}
@@ -539,6 +551,7 @@
$.rmAll = function(root) {
var node;
+
while (node = root.firstChild) {
root.removeChild(node);
}
@@ -554,6 +567,7 @@
$.nodes = function(nodes) {
var frag, node, _i, _len;
+
if (!(nodes instanceof Array)) {
return nodes;
}
@@ -587,6 +601,7 @@
$.el = function(tag, properties) {
var el;
+
el = d.createElement(tag);
if (properties) {
$.extend(el, properties);
@@ -596,6 +611,7 @@
$.on = function(el, events, handler) {
var event, _i, _len, _ref;
+
_ref = events.split(' ');
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
event = _ref[_i];
@@ -605,6 +621,7 @@
$.off = function(el, events, handler) {
var event, _i, _len, _ref;
+
_ref = events.split(' ');
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
event = _ref[_i];
@@ -628,6 +645,7 @@
$.debounce = function(wait, fn) {
var args, exec, lastCall, that, timeout;
+
lastCall = 0;
timeout = null;
that = null;
@@ -649,9 +667,11 @@
$.queueTask = (function() {
var execTask, taskChannel, taskQueue;
+
taskQueue = [];
execTask = function() {
var args, func, task;
+
task = taskQueue.shift();
func = task[0];
args = Array.prototype.slice.call(task, 1);
@@ -674,6 +694,7 @@
$.globalEval = function(code) {
var script;
+
script = $.el('script', {
textContent: code
});
@@ -683,6 +704,7 @@
$.bytesToString = function(size) {
var unit;
+
unit = 0;
while (size >= 1024) {
size /= 1024;
@@ -698,6 +720,7 @@
$.item = function(key, val) {
var item;
+
item = {};
item[key] = val;
return item;
@@ -708,6 +731,7 @@
$.sync = (function() {
chrome.storage.onChanged.addListener(function(changes) {
var cb, key;
+
for (key in changes) {
if (cb = $.syncing[key]) {
cb(changes[key].newValue);
@@ -727,6 +751,7 @@
$.get = function(key, val, cb) {
var count, done, items, localItems, syncItems;
+
if (typeof cb === 'function') {
items = $.item(key, val);
} else {
@@ -746,6 +771,7 @@
count = 0;
done = function(item) {
var lastError;
+
lastError = chrome.runtime.lastError;
if (lastError) {
c.error(lastError, lastError.message || 'No message.');
@@ -767,10 +793,12 @@
$.set = (function() {
var items, localItems, set;
+
items = {};
localItems = {};
set = $.debounce($.SECOND, function() {
var err, key, _i, _len, _ref;
+
_ref = $.localKeys;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
key = _ref[_i];
@@ -855,6 +883,7 @@
function Post(root, thread, board, that) {
var capcode, date, email, flag, info, name, post, subject, tripcode, uniqueID;
+
this.thread = thread;
this.board = board;
if (that == null) {
@@ -930,6 +959,7 @@
Post.prototype.parseComment = function() {
var bq, i, node, nodes, text;
+
bq = this.nodes.comment.cloneNode(true);
nodes = $$('.abbr, .capcodeReplies, .exif, b', bq);
i = 0;
@@ -947,6 +977,7 @@
Post.prototype.parseQuotes = function() {
var quotelink, _i, _len, _ref;
+
this.quotes = [];
_ref = $$('.quotelink', this.nodes.comment);
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
@@ -957,6 +988,7 @@
Post.prototype.parseQuote = function(quotelink) {
var fullID, match;
+
if (!(match = quotelink.href.match(/boards\.4chan\.org\/([^\/]+)\/res\/\d+#p(\d+)$/))) {
return;
}
@@ -972,6 +1004,7 @@
Post.prototype.parseFile = function(that) {
var alt, anchor, fileEl, fileInfo, size, thumb, unit;
+
if (!((fileEl = $('.file', this.nodes.post)) && (thumb = $('img[data-md5]', fileEl)))) {
return;
}
@@ -1003,6 +1036,7 @@
Post.prototype.kill = function(file, now) {
var clone, quotelink, strong, _i, _j, _len, _len1, _ref, _ref1;
+
now || (now = new Date());
if (file) {
if (this.file.isDead) {
@@ -1051,6 +1085,7 @@
Post.prototype.resurrect = function() {
var clone, quotelink, strong, _i, _j, _len, _len1, _ref, _ref1;
+
delete this.isDead;
delete this.timeOfDeath;
$.rmClass(this.nodes.root, 'deleted-post');
@@ -1084,6 +1119,7 @@
Post.prototype.rmClone = function(index) {
var clone, _i, _len, _ref;
+
this.clones.splice(index, 1);
_ref = this.clones.slice(index);
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
@@ -1101,6 +1137,7 @@
function Clone(origin, context) {
var file, info, inline, inlined, key, nodes, post, root, val, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2, _ref3;
+
this.origin = origin;
this.context = context;
_ref = ['ID', 'fullID', 'board', 'thread', 'info', 'quotes', 'isReply'];
@@ -1188,6 +1225,7 @@
function DataBoard(key, sync, dontClean) {
var init,
_this = this;
+
this.key = key;
this.data = Conf[key];
$.sync(key, this.onSync.bind(this));
@@ -1210,6 +1248,7 @@
DataBoard.prototype["delete"] = function(_arg) {
var boardID, postID, threadID;
+
boardID = _arg.boardID, threadID = _arg.threadID, postID = _arg.postID;
if (postID) {
delete this.data.boards[boardID][threadID][postID];
@@ -1230,6 +1269,7 @@
DataBoard.prototype.deleteIfEmpty = function(_arg) {
var boardID, threadID;
+
boardID = _arg.boardID, threadID = _arg.threadID;
if (threadID) {
if (!Object.keys(this.data.boards[boardID][threadID]).length) {
@@ -1245,6 +1285,7 @@
DataBoard.prototype.set = function(_arg) {
var boardID, postID, threadID, val, _base, _base1, _base2;
+
boardID = _arg.boardID, threadID = _arg.threadID, postID = _arg.postID, val = _arg.val;
if (postID !== void 0) {
((_base = ((_base1 = this.data.boards)[boardID] || (_base1[boardID] = {})))[threadID] || (_base[threadID] = {}))[postID] = val;
@@ -1258,6 +1299,7 @@
DataBoard.prototype.get = function(_arg) {
var ID, board, boardID, defaultValue, postID, thread, threadID, val, _i, _len;
+
boardID = _arg.boardID, threadID = _arg.threadID, postID = _arg.postID, defaultValue = _arg.defaultValue;
if (board = this.data.boards[boardID]) {
if (!threadID) {
@@ -1281,6 +1323,7 @@
DataBoard.prototype.clean = function() {
var boardID, now, val, _ref;
+
_ref = this.data.boards;
for (boardID in _ref) {
val = _ref[boardID];
@@ -1300,8 +1343,10 @@
DataBoard.prototype.ajaxClean = function(boardID) {
var _this = this;
+
return $.cache("//api.4chan.org/" + boardID + "/threads.json", function(e) {
var board, page, thread, threads, _i, _j, _len, _len1, _ref, _ref1;
+
if (e.target.status === 404) {
_this["delete"](boardID);
} else if (e.target.status === 200) {
@@ -1389,8 +1434,10 @@
},
toBlob: function() {
var _base;
+
return (_base = HTMLCanvasElement.prototype).toBlob || (_base.toBlob = function(cb) {
var data, i, l, ui8a, _i;
+
data = atob(this.toDataURL().slice(22));
l = data.length;
ui8a = new Uint8Array(l);
@@ -1428,6 +1475,7 @@
init: function() {
var barFixedToggler, barPositionToggler, customNavToggler, editCustomNav, footerToggler, headerToggler, linkJustifyToggler, menuButton,
_this = this;
+
this.menu = new UI.Menu('header');
menuButton = $.el('span', {
className: 'menu-button',
@@ -1518,6 +1566,7 @@
});
return $.ready(function() {
var a, cs;
+
_this.footer = $.id('boardNavDesktopFoot');
if (a = $("a[href*='/" + g.BOARD + "/']", $.id('boardNavDesktopFoot'))) {
a.className = 'current';
@@ -1551,6 +1600,7 @@
}),
setBoardList: function() {
var a, boardList, btn, fourchannav, fullBoardList;
+
fourchannav = $.id('boardNavDesktop');
if (a = $("a[href*='/" + g.BOARD + "/']", fourchannav)) {
a.className = 'current';
@@ -1572,6 +1622,7 @@
},
generateBoardList: function(text) {
var as, list, nodes;
+
list = $('#custom-board-list', Header.bar);
$.rmAll(list);
if (!text) {
@@ -1580,6 +1631,7 @@
as = $$('#full-board-list a[title]', Header.bar);
nodes = text.match(/[\w@]+((-(all|title|replace|full|index|catalog|url:"[^"]+[^"]"|text:"[^"]+")|\,"[^"]+[^"]"))*|[^\w@]+/g).map(function(t) {
var a, board, m, _i, _len;
+
if (/^[^\w@]/.test(t)) {
return $.tn(t);
}
@@ -1630,6 +1682,7 @@
},
toggleBoardList: function() {
var bar, custom, full, showBoardList;
+
bar = Header.bar;
custom = $('#custom-board-list', bar);
full = $('#full-board-list', bar);
@@ -1665,6 +1718,7 @@
},
toggleLinkJustify: function() {
var centered;
+
$.event('CloseMenu');
centered = this.nodeName === 'INPUT' ? this.checked : void 0;
Header.setLinkJustify(centered);
@@ -1694,6 +1748,7 @@
},
toggleBarVisibility: function(e) {
var hide, message;
+
if (e.type === 'mousedown' && e.button !== 0) {
return;
}
@@ -1710,6 +1765,7 @@
},
toggleFooterVisibility: function() {
var hide, message;
+
$.event('CloseMenu');
hide = this.nodeName === 'INPUT' ? this.checked : !!Header.footer.hidden;
Header.setFooterVisibility(hide);
@@ -1719,6 +1775,7 @@
},
setCustomNav: function(show) {
var btn, cust, full, _ref;
+
Header.customNavToggler.checked = show;
cust = $('#custom-board-list', Header.bar);
full = $('#full-board-list', Header.bar);
@@ -1731,12 +1788,14 @@
},
editCustomNav: function() {
var settings;
+
Settings.open('Advanced');
settings = $.id('fourchanx-settings');
return $('input[name=boardnav]', settings).focus();
},
hashScroll: function() {
var hash, post;
+
if (!((hash = this.location.hash.slice(1)) && (post = $.id(hash)))) {
return;
}
@@ -1747,6 +1806,7 @@
},
scrollToPost: function(post) {
var headRect, top;
+
top = post.getBoundingClientRect().top;
if (Conf['Fixed Header'] && !Conf['Bottom Header']) {
headRect = Header.bar.getBoundingClientRect();
@@ -1756,6 +1816,7 @@
},
addShortcut: function(el) {
var shortcut;
+
shortcut = $.el('span', {
className: 'shortcut brackets-wrap'
});
@@ -1767,6 +1828,7 @@
},
createNotification: function(e) {
var cb, content, lifetime, notif, type, _ref;
+
_ref = e.detail, type = _ref.type, content = _ref.content, lifetime = _ref.lifetime, cb = _ref.cb;
notif = new Notification(type, content, lifetime);
if (cb) {
@@ -1779,6 +1841,7 @@
spoilerRange: {},
shortFilename: function(filename, isReply) {
var threshold;
+
threshold = isReply ? 30 : 40;
if (filename.length - 4 > threshold) {
return "" + filename.slice(0, threshold - 5) + "(...)." + filename.slice(-3);
@@ -1788,6 +1851,7 @@
},
postFromObject: function(data, boardID) {
var o;
+
o = {
postID: data.no,
threadID: data.resto || data.no,
@@ -1832,6 +1896,7 @@
*/
var a, boardID, capcode, capcodeClass, capcodeReplies, capcodeStart, closed, comment, container, date, dateUTC, email, emailEnd, emailStart, ext, file, fileDims, fileHTML, fileInfo, fileSize, fileThumb, filename, flag, flagCode, flagName, href, imgSrc, isClosed, isOP, isSticky, name, postID, quote, shortFilename, spoilerRange, staticPath, sticky, subject, threadID, tripcode, uniqueID, userID, _i, _len, _ref;
+
postID = o.postID, threadID = o.threadID, boardID = o.boardID, name = o.name, capcode = o.capcode, tripcode = o.tripcode, uniqueID = o.uniqueID, email = o.email, subject = o.subject, flagCode = o.flagCode, flagName = o.flagName, date = o.date, dateUTC = o.dateUTC, isSticky = o.isSticky, isClosed = o.isClosed, comment = o.comment, capcodeReplies = o.capcodeReplies, file = o.file;
isOP = postID === threadID;
staticPath = '//static.4chan.org/image/';
@@ -1930,6 +1995,7 @@
},
capcodeReplies: function(_arg) {
var array, boardID, bq, capcodeReplies, capcodeType, generateCapcodeReplies, html, root, threadID;
+
boardID = _arg.boardID, threadID = _arg.threadID, bq = _arg.bq, root = _arg.root, capcodeReplies = _arg.capcodeReplies;
if (!capcodeReplies) {
return;
@@ -1966,6 +2032,7 @@
Get = {
threadExcerpt: function(thread) {
var OP, excerpt, _ref;
+
OP = thread.OP;
excerpt = ((_ref = OP.info.subject) != null ? _ref.trim() : void 0) || OP.info.comment.replace(/\n+/g, ' // ') || Conf['Anonymize'] && 'Anonymous' || $('.nameBlock', OP.nodes.info).textContent.trim();
if (excerpt.length > 70) {
@@ -1981,6 +2048,7 @@
},
postFromRoot: function(root) {
var boardID, index, link, post, postID;
+
link = $('a[title="Highlight this post"]', root);
boardID = link.pathname.split('/')[1];
postID = link.hash.slice(2);
@@ -2000,6 +2068,7 @@
},
postDataFromLink: function(link) {
var boardID, path, postID, threadID, _ref;
+
if (link.hostname === 'boards.4chan.org') {
path = link.pathname.split('/');
boardID = path[1];
@@ -2017,6 +2086,7 @@
},
allQuotelinksLinkingTo: function(post) {
var ID, quote, quotedPost, quotelinks, quoterPost, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2, _ref3;
+
quotelinks = [];
_ref = g.posts;
for (ID in _ref) {
@@ -2045,12 +2115,14 @@
}
return quotelinks.filter(function(quotelink) {
var boardID, postID, _ref4;
+
_ref4 = Get.postDataFromLink(quotelink), boardID = _ref4.boardID, postID = _ref4.postID;
return boardID === post.board.ID && postID === post.ID;
});
},
postClone: function(boardID, threadID, postID, root, context) {
var post, url;
+
if (post = g.posts["" + boardID + "." + postID]) {
Get.insert(post, root, context);
return;
@@ -2073,6 +2145,7 @@
},
insert: function(post, root, context) {
var clone, nodes;
+
if (!root.parentNode) {
return;
}
@@ -2086,6 +2159,7 @@
},
fetchedPost: function(req, boardID, threadID, postID, root, context) {
var board, post, posts, status, thread, url, _i, _len;
+
if (post = g.posts["" + boardID + "." + postID]) {
Get.insert(post, root, context);
return;
@@ -2139,6 +2213,7 @@
},
archivedPost: function(req, boardID, postID, root, context) {
var board, bq, comment, data, o, post, thread, threadID, _ref;
+
if (post = g.posts["" + boardID + "." + postID]) {
Get.insert(post, root, context);
return;
@@ -2233,8 +2308,10 @@
UI = (function() {
var Menu, dialog, drag, dragend, dragstart, hover, hoverend, hoverstart, touchend, touchmove;
+
dialog = function(id, position, html) {
var child, el, move, _i, _len, _ref;
+
el = $.el('div', {
className: 'dialog',
innerHTML: html,
@@ -2274,6 +2351,7 @@
Menu.prototype.makeMenu = function() {
var menu;
+
menu = $.el('div', {
className: 'dialog',
id: 'menu',
@@ -2288,6 +2366,7 @@
Menu.prototype.toggle = function(e, button, data) {
var previousButton;
+
e.preventDefault();
e.stopPropagation();
if (currentMenu) {
@@ -2305,6 +2384,7 @@
Menu.prototype.open = function(button, data) {
var bLeft, bRect, bTop, bottom, cHeight, cWidth, entry, left, mRect, menu, right, style, top, _i, _len, _ref, _ref1, _ref2;
+
menu = this.makeMenu();
currentMenu = menu;
lastToggledButton = button;
@@ -2343,6 +2423,7 @@
Menu.prototype.insertEntry = function(entry, parent, data) {
var subEntry, submenu, _i, _len, _ref;
+
if (typeof entry.open === 'function') {
if (!entry.open(data)) {
return;
@@ -2376,6 +2457,7 @@
Menu.prototype.findNextEntry = function(entry, direction) {
var entries;
+
entries = __slice.call(entry.parentNode.children);
entries.sort(function(first, second) {
return +(first.style.order || first.style.webkitOrder) - +(second.style.order || second.style.webkitOrder);
@@ -2385,6 +2467,7 @@
Menu.prototype.keybinds = function(e) {
var entry, next, nextPrev, subEntry, submenu;
+
entry = $('.focused', currentMenu);
while (subEntry = $('.focused', entry)) {
entry = subEntry;
@@ -2430,6 +2513,7 @@
Menu.prototype.focus = function(entry) {
var bottom, cHeight, cWidth, eRect, focused, left, right, sRect, style, submenu, top, _i, _len, _ref, _ref1, _ref2;
+
while (focused = $.x('parent::*/child::*[contains(@class,"focused")]', entry)) {
$.rmClass(focused, 'focused');
}
@@ -2457,6 +2541,7 @@
Menu.prototype.addEntry = function(e) {
var entry;
+
entry = e.detail;
if (entry.type !== this.type) {
return;
@@ -2467,6 +2552,7 @@
Menu.prototype.parseEntry = function(entry) {
var el, style, subEntries, subEntry, _i, _len;
+
el = entry.el, subEntries = entry.subEntries;
$.addClass(el, 'entry');
$.on(el, 'focus mouseover', (function(e) {
@@ -2490,6 +2576,7 @@
})();
dragstart = function(e) {
var el, isTouching, o, rect, screenHeight, screenWidth, _ref;
+
if (e.type === 'mousedown' && e.button !== 0) {
return;
}
@@ -2528,6 +2615,7 @@
};
touchmove = function(e) {
var touch, _i, _len, _ref;
+
_ref = e.changedTouches;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
touch = _ref[_i];
@@ -2539,6 +2627,7 @@
};
drag = function(e) {
var bottom, clientX, clientY, left, right, style, top;
+
clientX = e.clientX, clientY = e.clientY;
left = clientX - this.dx;
left = left < 10 ? 0 : this.width - left < 10 ? null : left / this.screenWidth * 100 + '%';
@@ -2554,6 +2643,7 @@
};
touchend = function(e) {
var touch, _i, _len, _ref;
+
_ref = e.changedTouches;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
touch = _ref[_i];
@@ -2575,6 +2665,7 @@
};
hoverstart = function(_arg) {
var asapTest, cb, el, endEvents, latestEvent, o, root;
+
root = _arg.root, el = _arg.el, latestEvent = _arg.latestEvent, endEvents = _arg.endEvents, asapTest = _arg.asapTest, cb = _arg.cb;
o = {
root: root,
@@ -2603,6 +2694,7 @@
};
hover = function(e) {
var clientX, clientY, height, left, right, style, top, _ref;
+
this.latestEvent = e;
height = this.el.offsetHeight;
clientX = e.clientX, clientY = e.clientY;
@@ -2645,6 +2737,7 @@
},
node: function() {
var email, name, tripcode, _ref;
+
if (this.info.capcode || this.isClone) {
return;
}
@@ -2671,6 +2764,7 @@
filters: {},
init: function() {
var boards, err, filter, hl, key, op, regexp, stub, top, _i, _len, _ref, _ref1, _ref2, _ref3, _ref4;
+
if (g.VIEW === 'catalog' || !Conf['Filter']) {
return;
}
@@ -2707,6 +2801,7 @@
op = ((_ref2 = filter.match(/[^t]op:(yes|no|only)/)) != null ? _ref2[1] : void 0) || 'yes';
stub = (function() {
var _ref3;
+
switch ((_ref3 = filter.match(/stub:(yes|no)/)) != null ? _ref3[1] : void 0) {
case 'yes':
return true;
@@ -2737,6 +2832,7 @@
},
createFilter: function(regexp, op, stub, hl, top) {
var settings, test;
+
test = typeof regexp === 'string' ? function(value) {
return regexp === value;
} : function(value) {
@@ -2760,6 +2856,7 @@
},
node: function() {
var filter, firstThread, key, result, thisThread, value, _i, _len, _ref;
+
if (this.isClone) {
return;
}
@@ -2871,6 +2968,7 @@
menu: {
init: function() {
var div, entry, type, _i, _len, _ref;
+
if (g.VIEW === 'catalog' || !Conf['Menu'] || !Conf['Filter']) {
return;
}
@@ -2896,6 +2994,7 @@
},
createSubEntry: function(text, type) {
var el;
+
el = $.el('a', {
href: 'javascript:;',
textContent: text
@@ -2906,6 +3005,7 @@
el: el,
open: function(post) {
var value;
+
value = Filter[type](post);
return value !== false;
}
@@ -2913,6 +3013,7 @@
},
makeFilter: function() {
var re, type, value;
+
type = this.dataset.type;
value = Filter[type](Filter.menu.post);
re = ['uniqueID', 'MD5'].contains(type) ? value : value.replace(/\/|\\|\^|\$|\n|\.|\(|\)|\{|\}|\[|\]|\?|\*|\+|\|/g, function(c) {
@@ -2927,6 +3028,7 @@
re = ['uniqueID', 'MD5'].contains(type) ? "/" + re + "/" : "/^" + re + "$/";
return $.get(type, Conf[type], function(item) {
var save, section, select, ta, tl;
+
save = item[type];
save = save ? "" + save + "\n" + re : re;
$.set(type, save);
@@ -2960,6 +3062,7 @@
},
node: function() {
var data;
+
if (!this.isReply || this.isClone) {
return;
}
@@ -2983,6 +3086,7 @@
menu: {
init: function() {
var apply, div, hideStubLink, makeStub, replies, thisPost;
+
if (g.VIEW === 'catalog' || !Conf['Menu'] || !Conf['Reply Hiding Link']) {
return;
}
@@ -3053,6 +3157,7 @@
order: 20,
open: function(post) {
var data;
+
if (!post.isReply || post.isClone || !post.isHidden) {
return false;
}
@@ -3084,6 +3189,7 @@
order: 15,
open: function(post) {
var data;
+
if (!post.isReply || post.isClone || !post.isHidden) {
return false;
}
@@ -3100,6 +3206,7 @@
},
hide: function() {
var makeStub, parent, post, replies, thisPost;
+
parent = this.parentNode;
thisPost = $('input[name=thisPost]', parent).checked;
replies = $('input[name=replies]', parent).checked;
@@ -3118,6 +3225,7 @@
},
show: function() {
var data, parent, post, replies, thisPost;
+
parent = this.parentNode;
thisPost = $('input[name=thisPost]', parent).checked;
replies = $('input[name=replies]', parent).checked;
@@ -3141,6 +3249,7 @@
},
hideStub: function() {
var post;
+
post = PostHiding.menu.post;
post.nodes.root.hidden = true;
$.event('CloseMenu');
@@ -3148,6 +3257,7 @@
},
makeButton: function(post, type) {
var a;
+
a = $.el('a', {
className: "" + type + "-reply-button",
innerHTML: " " + (type === 'hide' ? '-' : '+') + " ",
@@ -3158,6 +3268,7 @@
},
saveHiddenState: function(post, isHiding, thisPost, makeStub, hideRecursively) {
var data;
+
data = {
boardID: post.board.ID,
threadID: post.thread.ID,
@@ -3176,12 +3287,14 @@
},
toggle: function() {
var post;
+
post = Get.postFromNode(this);
PostHiding[(post.isHidden ? 'show' : 'hide')](post);
return PostHiding.saveHiddenState(post, post.isHidden);
},
hide: function(post, makeStub, hideRecursively) {
var a, button, postInfo, quotelink, _i, _len, _ref;
+
if (makeStub == null) {
makeStub = Conf['Stubs'];
}
@@ -3216,6 +3329,7 @@
},
show: function(post, showRecursively) {
var quotelink, _i, _len, _ref;
+
if (showRecursively == null) {
showRecursively = Conf['Recursive Hiding'];
}
@@ -3251,6 +3365,7 @@
},
node: function() {
var i, obj, quote, recursive, _i, _j, _len, _len1, _ref, _ref1;
+
if (this.isClone) {
return;
}
@@ -3268,6 +3383,7 @@
},
add: function() {
var args, obj, post, recursive, _base, _name;
+
recursive = arguments[0], post = arguments[1], args = 3 <= arguments.length ? __slice.call(arguments, 2) : [];
obj = (_base = Recursive.recursives)[_name = post.fullID] || (_base[_name] = {
recursives: [],
@@ -3278,6 +3394,7 @@
},
rm: function(recursive, post) {
var i, obj, rec, _i, _len, _ref;
+
if (!(obj = Recursive.recursives[post.fullID])) {
return;
}
@@ -3292,6 +3409,7 @@
},
apply: function() {
var ID, args, fullID, post, recursive, _ref;
+
recursive = arguments[0], post = arguments[1], args = 3 <= arguments.length ? __slice.call(arguments, 2) : [];
fullID = post.fullID;
_ref = g.posts;
@@ -3318,6 +3436,7 @@
},
node: function() {
var data;
+
if (data = ThreadHiding.db.get({
boardID: this.board.ID,
threadID: this.ID
@@ -3331,6 +3450,7 @@
},
syncCatalog: function() {
var hiddenThreads, hiddenThreadsOnCatalog, threadID;
+
hiddenThreads = ThreadHiding.db.get({
boardID: g.BOARD.ID,
defaultValue: {}
@@ -3357,6 +3477,7 @@
cleanCatalog: function(hiddenThreadsOnCatalog) {
return $.cache("//api.4chan.org/" + g.BOARD + "/threads.json", function() {
var page, thread, threads, _i, _j, _len, _len1, _ref, _ref1;
+
if (this.status !== 200) {
return;
}
@@ -3382,6 +3503,7 @@
menu: {
init: function() {
var apply, div, hideStubLink, makeStub;
+
if (g.VIEW !== 'index' || !Conf['Menu'] || !Conf['Thread Hiding Link']) {
return;
}
@@ -3403,6 +3525,7 @@
order: 20,
open: function(_arg) {
var isReply, thread;
+
thread = _arg.thread, isReply = _arg.isReply;
if (isReply || thread.isHidden) {
return false;
@@ -3432,6 +3555,7 @@
order: 20,
open: function(_arg) {
var isReply, thread;
+
thread = _arg.thread, isReply = _arg.isReply;
if (isReply || !thread.isHidden) {
return false;
@@ -3451,6 +3575,7 @@
order: 15,
open: function(_arg) {
var isReply, thread;
+
thread = _arg.thread, isReply = _arg.isReply;
if (isReply || !thread.isHidden) {
return false;
@@ -3461,6 +3586,7 @@
},
hide: function() {
var makeStub, thread;
+
makeStub = $('input', this.parentNode).checked;
thread = ThreadHiding.menu.thread;
ThreadHiding.hide(thread, makeStub);
@@ -3469,6 +3595,7 @@
},
show: function() {
var thread;
+
thread = ThreadHiding.menu.thread;
ThreadHiding.show(thread);
ThreadHiding.saveHiddenState(thread);
@@ -3476,6 +3603,7 @@
},
hideStub: function() {
var thread;
+
thread = ThreadHiding.menu.thread;
ThreadHiding.hide(thread, false);
$.event('CloseMenu');
@@ -3483,6 +3611,7 @@
},
makeButton: function(thread, type) {
var a;
+
a = $.el('a', {
className: "" + type + "-thread-button",
innerHTML: " " + (type === 'hide' ? '-' : '+') + " ",
@@ -3494,6 +3623,7 @@
},
saveHiddenState: function(thread, makeStub) {
var hiddenThreadsOnCatalog;
+
hiddenThreadsOnCatalog = JSON.parse(localStorage.getItem("4chan-hide-t-" + g.BOARD)) || {};
if (thread.isHidden) {
ThreadHiding.db.set({
@@ -3526,6 +3656,7 @@
},
hide: function(thread, makeStub) {
var OP, a, numReplies, opInfo, span, threadRoot;
+
if (makeStub == null) {
makeStub = Conf['Stubs'];
}
@@ -3549,6 +3680,7 @@
},
show: function(thread) {
var threadRoot;
+
if (thread.stub) {
$.rm(thread.stub);
delete thread.stub;
@@ -3561,6 +3693,7 @@
QuoteBacklink = {
init: function() {
var format;
+
if (g.VIEW === 'catalog' || !Conf['Quote Backlinks']) {
return;
}
@@ -3578,6 +3711,7 @@
},
firstNode: function() {
var a, clone, container, containers, frag, link, post, quote, _i, _j, _k, _len, _len1, _len2, _ref, _ref1;
+
if (this.isClone || !this.quotes.length) {
return;
}
@@ -3615,6 +3749,7 @@
},
secondNode: function() {
var container;
+
if (this.isClone && (this.origin.isReply || Conf['OP Backlinks'])) {
this.nodes.backlinkContainer = $('.container', this.nodes.info);
return;
@@ -3628,6 +3763,7 @@
},
getContainer: function(id) {
var _base;
+
return (_base = this.containers)[id] || (_base[id] = $.el('span', {
className: 'container'
}));
@@ -3650,6 +3786,7 @@
},
node: function() {
var board, boardID, quotelink, thread, threadID, _i, _len, _ref, _ref1, _ref2;
+
if (this.isClone && this.thread === this.context.thread) {
return;
}
@@ -3679,6 +3816,7 @@
if (Conf['Quote Hash Navigation']) {
this.node = function() {
var link, _i, _len, _ref;
+
_ref = this.nodes.quotelinks.concat(__slice.call(this.nodes.backlinks));
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
link = _ref[_i];
@@ -3691,6 +3829,7 @@
} else {
this.node = function() {
var link, _i, _len, _ref;
+
_ref = this.nodes.quotelinks.concat(__slice.call(this.nodes.backlinks));
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
link = _ref[_i];
@@ -3717,6 +3856,7 @@
},
toggle: function(e) {
var boardID, context, postID, threadID, _ref;
+
if (e.shiftKey || e.altKey || e.ctrlKey || e.metaKey || e.button !== 0) {
return;
}
@@ -3742,6 +3882,7 @@
},
add: function(quotelink, boardID, threadID, postID, context) {
var inline, isBacklink, post, qroot, root;
+
isBacklink = $.hasClass(quotelink, 'backlink');
inline = $.el('div', {
id: "i" + postID,
@@ -3766,6 +3907,7 @@
},
rm: function(quotelink, boardID, threadID, postID, context) {
var el, inlined, isBacklink, post, qroot, root, _ref;
+
isBacklink = $.hasClass(quotelink, 'backlink');
root = QuoteInline.findRoot(quotelink, isBacklink);
root = $.x("following-sibling::div[@id='i" + postID + "'][1]", root);
@@ -3807,6 +3949,7 @@
},
node: function() {
var boardID, fullID, i, postID, quotelink, quotelinks, quotes, _ref;
+
if (this.isClone && this.thread === this.context.thread) {
return;
}
@@ -3849,6 +3992,7 @@
},
node: function() {
var link, _i, _len, _ref;
+
_ref = this.nodes.quotelinks.concat(__slice.call(this.nodes.backlinks));
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
link = _ref[_i];
@@ -3857,6 +4001,7 @@
},
mouseover: function(e) {
var boardID, clone, origin, post, postID, posts, qp, quote, quoterID, threadID, _i, _j, _len, _len1, _ref, _ref1;
+
if ($.hasClass(this, 'inlined')) {
return;
}
@@ -3900,6 +4045,7 @@
},
mouseout: function() {
var clone, post, root, _i, _len, _ref;
+
if (!(root = this.el.firstElementChild)) {
return;
}
@@ -3929,6 +4075,7 @@
},
node: function() {
var boardID, postID, quotelink, _i, _len, _ref, _ref1, _ref2;
+
if (this.isClone) {
return;
}
@@ -3951,6 +4098,7 @@
QuoteThreading = {
init: function() {
var input;
+
if (!(Conf['Quote Threading'] && g.VIEW === 'thread')) {
return;
}
@@ -3973,6 +4121,7 @@
},
setup: function() {
var ID, post, posts;
+
$.off(d, '4chanXInitFinished', QuoteThreading.setup);
posts = g.posts;
for (ID in posts) {
@@ -3985,6 +4134,7 @@
},
node: function() {
var ID, fullID, keys, len, post, posts, qid, quote, quotes, uniq, _i, _len;
+
if (this.isClone || !QuoteThreading.enabled || this.thread.OP === this) {
return;
}
@@ -4014,6 +4164,7 @@
},
nodeinsert: function() {
var bottom, height, qpost, qroot, threadContainer, top, _ref;
+
qpost = g.posts[this.threaded];
delete this.threaded;
delete this.cb;
@@ -4042,6 +4193,7 @@
},
toggle: function() {
var container, containers, node, post, replies, reply, thread, _i, _j, _k, _len, _len1, _len2, _ref;
+
thread = $('.thread');
replies = $$('.thread > .replyContainer, .threadContainer > .replyContainer', thread);
QuoteThreading.enabled = this.checked;
@@ -4058,6 +4210,7 @@
} else {
replies.sort(function(a, b) {
var aID, bID;
+
aID = Number(a.id.slice(2));
bID = Number(b.id.slice(2));
return aID - bID;
@@ -4078,6 +4231,7 @@
},
kb: function() {
var control;
+
control = $.id('threadingControl');
return control.click();
}
@@ -4104,6 +4258,7 @@
},
node: function() {
var quotelink, _i, _len, _ref;
+
if (this.isClone) {
return;
}
@@ -4126,6 +4281,7 @@
cb: {
seek: function(type) {
var highlight, post, posts, result, str;
+
if (!(Conf['Mark Quotes of You'] && Conf['Quick Reply'])) {
return;
}
@@ -4181,6 +4337,7 @@
},
node: function() {
var deadlink, _i, _len, _ref;
+
_ref = $$('.deadlink', this.nodes.comment);
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
deadlink = _ref[_i];
@@ -4195,6 +4352,7 @@
},
parseDeadlink: function(deadlink) {
var a, boardID, m, post, postID, quote, quoteID, redirect, _ref;
+
if (deadlink.parentNode.className === 'prettyprint') {
Quotify.fixDeadlink(deadlink);
return;
@@ -4287,6 +4445,7 @@
},
node: function() {
var data, el, end, endNode, i, index, items, length, link, links, node, range, result, saved, snapshot, space, test, _i, _len, _ref;
+
if (this.isClone) {
if (Conf['Embedding']) {
i = 0;
@@ -4365,6 +4524,7 @@
},
makeRange: function(startNode, endNode, startOffset, endOffset) {
var range;
+
range = document.createRange();
range.setStart(startNode, startOffset);
range.setEnd(endNode, endOffset);
@@ -4372,6 +4532,7 @@
},
makeLink: function(range) {
var a, char, i, text;
+
text = range.toString();
i = 0;
while (/[(\[{<>]/.test(text.charAt(i))) {
@@ -4415,6 +4576,7 @@
},
services: function(link) {
var href, key, match, type, _ref;
+
href = link.href;
_ref = Linkify.types;
for (key in _ref) {
@@ -4427,6 +4589,7 @@
},
embed: function(data) {
var embed, href, key, link, name, options, uid, value, _ref;
+
key = data[0], uid = data[1], options = data[2], link = data[3];
href = link.href;
embed = $.el('a', {
@@ -4455,6 +4618,7 @@
},
title: function(data) {
var embed, err, key, link, options, service, title, titles, uid;
+
key = data[0], uid = data[1], options = data[2], link = data[3], embed = data[4];
if (!(service = Linkify.types[key].title)) {
return;
@@ -4491,18 +4655,21 @@
cb: {
toggle: function() {
var string, _ref;
+
_ref = $.hasClass(this, "embedded") ? ['unembed', '(embed)'] : ['embed', '(unembed)'], string = _ref[0], this.textContent = _ref[1];
$.replace(this.previousElementSibling, Linkify.cb[string](this));
return $.toggleClass(this, 'embedded');
},
embed: function(a) {
var el, style, type;
+
el = (type = Linkify.types[a.dataset.key]).el(a);
el.style.cssText = (style = type.style) ? style : "border: 0; width: 640px; height: 390px";
return el;
},
unembed: function(a) {
var el;
+
el = $.el('a', {
rel: 'nofollow noreferrer',
target: 'blank',
@@ -4515,6 +4682,7 @@
},
title: function(response, data) {
var embed, key, link, options, service, text, uid;
+
key = data[0], uid = data[1], options = data[2], link = data[3], embed = data[4];
service = Linkify.types[key].title;
switch (response.status) {
@@ -4554,6 +4722,7 @@
regExp: /.*(?:gist.github.com.*\/)([^\/][^\/]*)$/,
el: function(a) {
var div;
+
return div = $.el('iframe', {
src: "http://www.purplegene.com/script?url=https://gist.github.com/" + a.dataset.uid + ".js"
});
@@ -4564,6 +4733,7 @@
},
text: function(_arg) {
var file, files;
+
files = _arg.files;
for (file in files) {
if (files.hasOwnProperty(file)) {
@@ -4611,6 +4781,7 @@
regExp: /.*(?:pastebin.com\/(?!u\/))([^#\&\?]*).*/,
el: function(a) {
var div;
+
return div = $.el('iframe', {
src: "http://pastebin.com/embed_iframe.php?i=" + a.dataset.uid
});
@@ -4621,6 +4792,7 @@
style: 'height: auto; width: 500px; display: inline-block;',
el: function(a) {
var div;
+
div = $.el('div', {
className: "soundcloud",
name: "soundcloud"
@@ -4646,6 +4818,7 @@
style: "border: none; width: 640px; height: 360px;",
el: function(a) {
var channel, chapter, result, _;
+
if (result = /(\w+)\/(?:[a-z]\/)?(\d+)/i.exec(a.dataset.uid)) {
_ = result[0], channel = result[1], chapter = result[2];
return $.el('object', {
@@ -4717,6 +4890,7 @@
QR = {
init: function() {
var sc;
+
if (!Conf['Quick Reply']) {
return;
}
@@ -4763,6 +4937,7 @@
},
initReady: function() {
var link;
+
QR.postingIsEnabled = !!$.id('postForm');
if (!QR.postingIsEnabled) {
return;
@@ -4782,11 +4957,13 @@
$.before($.id('postForm'), link);
$.on(d, 'QRGetSelectedPost', function(_arg) {
var cb;
+
cb = _arg.detail;
return cb(QR.selected);
});
$.on(d, 'QRAddPreSubmitHook', function(_arg) {
var cb;
+
cb = _arg.detail;
return QR.preSubmitHooks.push(cb);
});
@@ -4816,6 +4993,7 @@
},
open: function() {
var err;
+
if (QR.nodes) {
QR.nodes.el.hidden = false;
QR.unhide();
@@ -4834,6 +5012,7 @@
},
close: function() {
var post, _i, _len, _ref;
+
if (QR.req) {
QR.abort();
return;
@@ -4881,6 +5060,7 @@
},
error: function(err) {
var el;
+
QR.open();
if (typeof err === 'string') {
el = $.tn(err);
@@ -4908,6 +5088,7 @@
notifications: [],
cleanNotifications: function() {
var notification, _i, _len, _ref;
+
_ref = QR.notifications;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
notification = _ref[_i];
@@ -4917,6 +5098,7 @@
},
status: function() {
var disabled, status, thread, value;
+
if (!QR.nodes) {
return;
}
@@ -4938,6 +5120,7 @@
QR.persona.getPassword();
return $.get('QR.personas', Conf['QR.personas'], function(_arg) {
var arr, item, personas, type, types, _i, _len, _ref;
+
personas = _arg['QR.personas'];
types = {
name: [],
@@ -4957,6 +5140,7 @@
},
parseItem: function(item, types) {
var boards, match, type, val, _ref, _ref1;
+
if (item[0] === '#') {
return;
}
@@ -4985,6 +5169,7 @@
},
loadPersonas: function(type, arr) {
var list, val, _i, _len;
+
list = $("#list-" + type, QR.nodes.el);
for (_i = 0, _len = arr.length; _i < _len; _i++) {
val = arr[_i];
@@ -4997,6 +5182,7 @@
},
getPassword: function() {
var input, m;
+
if (!QR.persona.pwd) {
QR.persona.pwd = (m = d.cookie.match(/4chan_pass=([^;]+)/)) ? decodeURIComponent(m[1]) : (input = $.id('postPassword')) ? input.value : $.id('delPassword').value;
}
@@ -5005,6 +5191,7 @@
get: function(cb) {
return $.get('QR.persona', {}, function(_arg) {
var persona;
+
persona = _arg['QR.persona'];
return cb(persona);
});
@@ -5012,6 +5199,7 @@
set: function(post) {
return $.get('QR.persona', {}, function(_arg) {
var persona;
+
persona = _arg['QR.persona'];
persona = {
name: post.name,
@@ -5025,6 +5213,7 @@
cooldown: {
init: function() {
var board;
+
if (!Conf['Cooldown']) {
return;
}
@@ -5066,6 +5255,7 @@
},
sync: function(cooldowns) {
var id;
+
for (id in cooldowns) {
QR.cooldown.cooldowns[id] = cooldowns[id];
}
@@ -5073,6 +5263,7 @@
},
set: function(data) {
var cooldown, delay, hasFile, isReply, isSage, post, req, start, type, upSpd;
+
if (!Conf['Cooldown']) {
return;
}
@@ -5112,6 +5303,7 @@
},
count: function() {
var cooldown, cooldowns, elapsed, hasFile, isReply, isSage, now, post, seconds, start, type, types, upSpd, upSpdAccuracy, update, _ref;
+
if (!Object.keys(QR.cooldown.cooldowns).length) {
$["delete"]("" + g.BOARD + ".cooldown");
delete QR.cooldown.isCounting;
@@ -5165,6 +5357,7 @@
},
quote: function(e) {
var caretPos, com, index, post, range, s, sel, text, thread, _ref;
+
if (e != null) {
e.preventDefault();
}
@@ -5202,6 +5395,7 @@
},
characterCount: function() {
var count, counter;
+
counter = QR.nodes.charCount;
count = QR.nodes.com.textLength;
counter.textContent = count;
@@ -5210,6 +5404,7 @@
},
drag: function(e) {
var toggle;
+
toggle = e.type === 'dragstart' ? $.off : $.on;
toggle(d, 'dragover', QR.dragOver);
return toggle(d, 'drop', QR.dropFile);
@@ -5229,6 +5424,7 @@
},
paste: function(e) {
var blob, files, item, _i, _len, _ref;
+
files = [];
_ref = e.clipboardData.items;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
@@ -5255,8 +5451,19 @@
return QR.nodes.fileInput.click();
},
fileInput: function(files) {
- var file, length, max, post, _i, _len;
- if (files instanceof Event) {
+ var check, err, file, length, max, post, _i, _len;
+
+ try {
+ if (files instanceof Event) {
+ check = true;
+ }
+ } catch (_error) {
+ err = _error;
+ if (this instanceof Element) {
+ check = true;
+ }
+ }
+ if (check) {
files = __slice.call(this.files);
QR.nodes.fileInput.value = null;
}
@@ -5304,6 +5511,7 @@
function _Class(select) {
var el, event, prev, _i, _len, _ref,
_this = this;
+
el = $.el('a', {
className: 'qr-preview',
draggable: true,
@@ -5357,6 +5565,7 @@
_Class.prototype.rm = function() {
var index;
+
this["delete"]();
index = QR.posts.indexOf(this);
if (QR.posts.length === 1) {
@@ -5376,6 +5585,7 @@
_Class.prototype.lock = function(lock) {
var name, _i, _len, _ref;
+
if (lock == null) {
lock = true;
}
@@ -5400,6 +5610,7 @@
_Class.prototype.select = function() {
var rectEl, rectList;
+
if (QR.selected) {
QR.selected.nodes.el.id = null;
QR.selected.forceSave();
@@ -5416,6 +5627,7 @@
_Class.prototype.load = function() {
var name, _i, _len, _ref;
+
_ref = ['thread', 'name', 'email', 'sub', 'com'];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
name = _ref[_i];
@@ -5427,6 +5639,7 @@
_Class.prototype.save = function(input) {
var name, _ref;
+
if (input.type === 'checkbox') {
this.spoiler = input.checked;
return;
@@ -5447,6 +5660,7 @@
_Class.prototype.forceSave = function() {
var name, _i, _len, _ref;
+
if (this !== QR.selected) {
return;
}
@@ -5476,9 +5690,11 @@
_Class.prototype.setThumbnail = function() {
var fileURL, img,
_this = this;
+
img = $.el('img');
img.onload = function() {
var cv, height, s, width;
+
s = 90 * 2;
if (_this.file.type === 'image/gif') {
s *= 3;
@@ -5536,9 +5752,11 @@
_Class.prototype.pasteText = function(file) {
var reader,
_this = this;
+
reader = new FileReader();
reader.onload = function(e) {
var text;
+
text = e.target.result;
if (_this.com) {
_this.com += "\n" + text;
@@ -5576,6 +5794,7 @@
_Class.prototype.drop = function() {
var el, index, newIndex, oldIndex, post;
+
$.rmClass(this, 'over');
if (!this.draggable) {
return;
@@ -5610,6 +5829,7 @@
ready: function() {
var imgContainer, input, setLifetime,
_this = this;
+
setLifetime = function(e) {
return _this.lifetime = e.detail;
};
@@ -5646,6 +5866,7 @@
});
$.get('captchas', [], function(_arg) {
var captchas;
+
captchas = _arg.captchas;
return _this.sync(captchas);
});
@@ -5660,6 +5881,7 @@
},
getOne: function() {
var captcha, challenge, response;
+
this.clear();
if (captcha = this.captchas.shift()) {
challenge = captcha.challenge, response = captcha.response;
@@ -5684,6 +5906,7 @@
},
save: function() {
var response;
+
if (!(response = this.nodes.input.value.trim())) {
return;
}
@@ -5698,6 +5921,7 @@
},
clear: function() {
var captcha, i, now, _i, _len, _ref;
+
now = Date.now();
_ref = this.captchas;
for (i = _i = 0, _len = _ref.length; _i < _len; i = ++_i) {
@@ -5715,6 +5939,7 @@
},
load: function() {
var challenge;
+
if (!this.nodes.challenge.firstChild) {
return;
}
@@ -5727,6 +5952,7 @@
},
count: function() {
var count;
+
count = this.captchas.length;
this.nodes.input.placeholder = (function() {
switch (count) {
@@ -5759,6 +5985,7 @@
},
dialog: function() {
var dialog, i, items, mimeTypes, name, nodes, thread;
+
dialog = UI.dialog('qr', 'top:0;right:0;', " ");
QR.nodes = nodes = {
el: dialog,
@@ -5860,6 +6087,7 @@
preSubmitHooks: [],
submit: function(e) {
var challenge, err, extra, filetag, hook, options, post, postData, response, textOnly, thread, threadID, _i, _len, _ref, _ref1;
+
if (e != null) {
e.preventDefault();
}
@@ -5973,6 +6201,7 @@
},
response: function() {
var URL, ban, board, err, h1, isReply, m, post, postID, req, resDoc, threadID, _, _ref, _ref1;
+
req = QR.req;
delete QR.req;
post = QR.posts[0];
@@ -6070,6 +6299,7 @@
FappeTyme = {
init: function() {
var el, input;
+
if (!Conf['Fappe Tyme'] || g.VIEW === 'catalog' || g.BOARD === 'f') {
return;
}
@@ -6121,6 +6351,7 @@
},
node: function() {
var thumb, _ref;
+
if (!((_ref = this.file) != null ? _ref.isImage : void 0)) {
return;
}
@@ -6145,6 +6376,7 @@
},
toggleAll: function() {
var ID, file, func, post, _i, _len, _ref, _ref1;
+
$.event('CloseMenu');
if (ImageExpand.on = $.hasClass(ImageExpand.EAI, 'expand-all-shortcut')) {
ImageExpand.EAI.className = 'contract-all-shortcut';
@@ -6178,6 +6410,7 @@
},
toggle: function(post) {
var headRect, rect, root, thumb, x, y;
+
thumb = post.file.thumb;
if (!(post.file.isExpanded || $.hasClass(thumb, 'expanding'))) {
ImageExpand.expand(post);
@@ -6187,6 +6420,7 @@
root = post.nodes.root;
rect = (Conf['Advance on contract'] ? (function() {
var next;
+
next = root;
while (next = $.x("following::div[contains(@class,'postContainer')][1]", next)) {
if ($('.stub', next) || next.offsetHeight === 0) {
@@ -6217,6 +6451,7 @@
},
expand: function(post, src) {
var img, thumb;
+
thumb = post.file.thumb;
if (post.isHidden || post.file.isExpanded || $.hasClass(thumb, 'expanding')) {
return;
@@ -6244,6 +6479,7 @@
},
completeExpand: function(post) {
var prev, thumb;
+
thumb = post.file.thumb;
if (!$.hasClass(thumb, 'expanding')) {
return;
@@ -6257,6 +6493,7 @@
prev = post.nodes.root.getBoundingClientRect();
return $.queueTask(function() {
var curr;
+
$.addClass(post.nodes.root, 'expanded-image');
$.rmClass(post.file.thumb, 'expanding');
if (!(prev.top + prev.height <= 0)) {
@@ -6268,6 +6505,7 @@
},
error: function() {
var URL, post, src, timeoutID;
+
post = Get.postFromNode(this);
$.rm(this);
delete post.file.fullImage;
@@ -6293,6 +6531,7 @@
return $.ajax("//api.4chan.org/" + post.board + "/res/" + post.thread + ".json", {
onload: function() {
var postObj, _i, _len, _ref;
+
if (this.status !== 200) {
return;
}
@@ -6316,6 +6555,7 @@
menu: {
init: function() {
var conf, createSubEntry, el, name, subEntries, _ref;
+
if (g.VIEW === 'catalog' || !Conf['Image Expansion']) {
return;
}
@@ -6339,6 +6579,7 @@
},
createSubEntry: function(name, desc) {
var input, label;
+
label = $.el('label', {
innerHTML: " " + name,
title: desc
@@ -6372,6 +6613,7 @@
},
node: function() {
var _ref;
+
if (!((_ref = this.file) != null ? _ref.isImage : void 0)) {
return;
}
@@ -6379,6 +6621,7 @@
},
mouseover: function(e) {
var el, post;
+
post = Get.postFromNode(this);
el = $.el('img', {
id: 'ihover',
@@ -6400,6 +6643,7 @@
error: function() {
var URL, post, src, timeoutID,
_this = this;
+
if (!doc.contains(this)) {
return;
}
@@ -6424,6 +6668,7 @@
return $.ajax("//api.4chan.org/" + post.board + "/res/" + post.thread + ".json", {
onload: function() {
var postObj, _i, _len, _ref;
+
if (this.status !== 200) {
return;
}
@@ -6449,6 +6694,7 @@
ImageLoader = {
init: function() {
var prefetch;
+
if (g.VIEW === 'catalog') {
return;
}
@@ -6475,6 +6721,7 @@
},
node: function() {
var URL, img, string, style, thumb, type, _ref, _ref1;
+
if (this.isClone || this.isHidden || this.thread.isHidden || !((_ref = this.file) != null ? _ref.isImage : void 0)) {
return;
}
@@ -6496,6 +6743,7 @@
},
toggle: function() {
var enabled, id, post, _ref;
+
enabled = Conf['prefetch'] = this.checked;
if (enabled) {
_ref = g.threads["" + g.BOARD.ID + "." + g.THREADID].posts;
@@ -6519,6 +6767,7 @@
},
node: function() {
var thumb, _ref;
+
if (this.isClone || !((_ref = this.file) != null ? _ref.isSpoiler : void 0)) {
return;
}
@@ -6531,6 +6780,7 @@
Sauce = {
init: function() {
var err, link, links, _i, _len, _ref;
+
if (g.VIEW === 'catalog' || !Conf['Sauce']) {
return;
}
@@ -6560,6 +6810,7 @@
},
createSauceLink: function(link) {
var m, text;
+
link = link.replace(/%(T?URL|MD5|board)/ig, function(parameter) {
switch (parameter) {
case '%TURL':
@@ -6580,6 +6831,7 @@
},
node: function() {
var link, nodes, _i, _len, _ref;
+
if (this.isClone || !this.file) {
return;
}
@@ -6596,6 +6848,7 @@
ArchiveLink = {
init: function() {
var div, entry, type, _i, _len, _ref;
+
if (g.VIEW === 'catalog' || !Conf['Menu'] || !Conf['Archive Link']) {
return;
}
@@ -6608,6 +6861,7 @@
order: 90,
open: function(_arg) {
var ID, board, thread;
+
ID = _arg.ID, thread = _arg.thread, board = _arg.board;
return !!Redirect.to('thread', {
postID: ID,
@@ -6626,12 +6880,14 @@
},
createSubEntry: function(text, type) {
var el, open;
+
el = $.el('a', {
textContent: text,
target: '_blank'
});
open = type === 'post' ? function(_arg) {
var ID, board, thread;
+
ID = _arg.ID, thread = _arg.thread, board = _arg.board;
el.href = Redirect.to('thread', {
postID: ID,
@@ -6641,6 +6897,7 @@
return true;
} : function(post) {
var value;
+
value = Filter[type](post);
if (!value) {
return false;
@@ -6663,6 +6920,7 @@
DeleteLink = {
init: function() {
var div, fileEl, fileEntry, postEl, postEntry;
+
if (g.VIEW === 'catalog' || !Conf['Menu'] || !Conf['Delete Link']) {
return;
}
@@ -6690,6 +6948,7 @@
el: fileEl,
open: function(_arg) {
var file;
+
file = _arg.file;
if (!file || file.isDead) {
return false;
@@ -6705,6 +6964,7 @@
order: 40,
open: function(post) {
var node;
+
if (post.isDead || post.board.ID === 'q') {
return false;
}
@@ -6719,6 +6979,7 @@
},
"delete": function() {
var fileOnly, form, link, post;
+
post = DeleteLink.post;
if (DeleteLink.cooldown.counting === post) {
return;
@@ -6748,6 +7009,7 @@
},
load: function(link, post, fileOnly, resDoc) {
var msg, s;
+
if (resDoc.title === '4chan - Banned') {
s = 'Banned!';
} else if (msg = resDoc.getElementById('errmsg')) {
@@ -6768,6 +7030,7 @@
cooldown: {
start: function(post, node) {
var length, seconds, _ref;
+
if (!((_ref = QR.db) != null ? _ref.get({
boardID: post.board.ID,
threadID: post.thread.ID,
@@ -6801,6 +7064,7 @@
DownloadLink = {
init: function() {
var a;
+
if (g.VIEW === 'catalog' || !Conf['Menu'] || !Conf['Download Link']) {
return;
}
@@ -6814,6 +7078,7 @@
order: 100,
open: function(_arg) {
var file;
+
file = _arg.file;
if (!file) {
return false;
@@ -6846,6 +7111,7 @@
},
makeButton: (function() {
var a;
+
a = $.el('a', {
className: 'menu-button brackets-wrap',
innerHTML: '',
@@ -6853,6 +7119,7 @@
});
return function() {
var button;
+
button = a.cloneNode(true);
$.on(button, 'click', Menu.toggle);
return button;
@@ -6860,6 +7127,7 @@
})(),
toggle: function(e) {
var post;
+
post = Get.postFromNode(this);
return Menu.menu.toggle(e, this, post);
}
@@ -6868,6 +7136,7 @@
ReportLink = {
init: function() {
var a;
+
if (g.VIEW === 'catalog' || !Conf['Menu'] || !Conf['Report Link']) {
return;
}
@@ -6889,6 +7158,7 @@
},
report: function() {
var id, post, set, url;
+
post = ReportLink.post;
url = "//sys.4chan.org/" + post.board + "/imgboard.php?mode=report&no=" + post;
id = Date.now();
@@ -6901,6 +7171,7 @@
init: function() {
return $.ready(function() {
var href;
+
Favicon.el = $('link[rel="shortcut icon"]', d.head);
Favicon.el.type = 'image/x-icon';
href = Favicon.el.href;
@@ -6973,6 +7244,7 @@
init: function() {
var sc,
_this = this;
+
if (g.VIEW !== 'thread' || !Conf['Thread Stats']) {
return;
}
@@ -7001,6 +7273,7 @@
},
node: function() {
var ID, fileCount, post, postCount, _ref;
+
postCount = 0;
fileCount = 0;
_ref = this.posts;
@@ -7018,6 +7291,7 @@
},
onUpdate: function(e) {
var fileCount, postCount, _ref;
+
if (e.detail[404]) {
return;
}
@@ -7026,6 +7300,7 @@
},
update: function(postCount, fileCount) {
var fileCountEl, postCountEl, thread;
+
thread = ThreadStats.thread, postCountEl = ThreadStats.postCountEl, fileCountEl = ThreadStats.fileCountEl;
postCountEl.textContent = postCount;
fileCountEl.textContent = fileCount;
@@ -7050,6 +7325,7 @@
},
onThreadsLoad: function() {
var page, pages, thread, _i, _j, _len, _len1, _ref;
+
if (!(Conf["Page Count in Stats"] && this.status === 200)) {
return;
}
@@ -7073,6 +7349,7 @@
init: function() {
var checked, conf, el, input, name, sc, settings, subEntries, _ref,
_this = this;
+
if (g.VIEW !== 'thread' || !Conf['Thread Updater']) {
return;
}
@@ -7222,6 +7499,7 @@
},
interval: function() {
var val;
+
val = +this.value;
if (val < 1) {
val = 1;
@@ -7231,6 +7509,7 @@
},
load: function() {
var klass, req, text, _ref;
+
req = ThreadUpdater.req;
switch (req.status) {
case 200:
@@ -7263,6 +7542,7 @@
},
getInterval: function() {
var i, j;
+
i = ThreadUpdater.interval;
j = Math.min(ThreadUpdater.outdateCount, 10);
if (!d.hidden) {
@@ -7272,12 +7552,14 @@
},
intervalShortcut: function() {
var settings;
+
Settings.open('Advanced');
settings = $.id('fourchanx-settings');
return $('input[name=Interval]', settings).focus();
},
set: function(name, text, klass) {
var el, node;
+
el = ThreadUpdater[name];
if (node = el.firstChild) {
node.data = text;
@@ -7290,6 +7572,7 @@
},
timeout: function() {
var n;
+
ThreadUpdater.timeoutID = setTimeout(ThreadUpdater.timeout, 1000);
if (!(n = --ThreadUpdater.seconds)) {
return ThreadUpdater.update();
@@ -7302,6 +7585,7 @@
},
update: function() {
var url;
+
if (!ThreadUpdater.online) {
return;
}
@@ -7324,6 +7608,7 @@
},
updateThreadStatus: function(title, OP) {
var icon, message, root, titleLC;
+
titleLC = title.toLowerCase();
if (ThreadUpdater.thread["is" + title] === !!OP[titleLC]) {
return;
@@ -7350,6 +7635,7 @@
},
parse: function(postObjects) {
var ID, OP, count, deletedFiles, deletedPosts, files, index, key, node, num, post, postObject, posts, root, scroll, _i, _len, _ref;
+
OP = postObjects[0];
Build.spoilerRange[ThreadUpdater.thread.board] = OP.custom_spoiler;
ThreadUpdater.updateThreadStatus('Sticky', OP);
@@ -7435,6 +7721,7 @@
}
$.queueTask(function() {
var length, threadID;
+
threadID = ThreadUpdater.thread.ID;
length = $$('.thread > .postContainer', ThreadUpdater.root).length;
return Fourchan.parseThread(threadID, length - count, length);
@@ -7455,6 +7742,7 @@
ThreadWatcher = {
init: function() {
var now, sc;
+
if (!Conf['Thread Watcher']) {
return;
}
@@ -7487,6 +7775,7 @@
}
$.get('WatchedThreads', null, function(_arg) {
var WatchedThreads, boardID, data, threadID, threads, _ref;
+
WatchedThreads = _arg.WatchedThreads;
if (!WatchedThreads) {
return;
@@ -7512,6 +7801,7 @@
},
node: function() {
var toggler;
+
toggler = $.el('img', {
className: 'watch-thread-link'
});
@@ -7533,6 +7823,7 @@
}
return $.get('AutoWatch', 0, function(_arg) {
var AutoWatch, thread;
+
AutoWatch = _arg.AutoWatch;
if (!(thread = g.BOARD.threads[AutoWatch])) {
return;
@@ -7548,6 +7839,7 @@
cb: {
openAll: function() {
var a, _i, _len, _ref;
+
if ($.hasClass(this, 'disabled')) {
return;
}
@@ -7566,6 +7858,7 @@
},
pruneDeads: function() {
var boardID, data, threadID, _i, _len, _ref, _ref1;
+
if ($.hasClass(this, 'disabled')) {
return;
}
@@ -7589,11 +7882,13 @@
},
rm: function() {
var boardID, threadID, _ref;
+
_ref = this.parentNode.dataset.fullID.split('.'), boardID = _ref[0], threadID = _ref[1];
return ThreadWatcher.rm(boardID, +threadID);
},
post: function(e) {
var board, postID, threadID, _ref;
+
_ref = e.detail, board = _ref.board, postID = _ref.postID, threadID = _ref.threadID;
if (postID === threadID) {
if (Conf['Auto Watch']) {
@@ -7605,6 +7900,7 @@
},
threadUpdate: function(e) {
var thread;
+
thread = e.detail.thread;
if (!(e.detail[404] && ThreadWatcher.db.get({
boardID: thread.board.ID,
@@ -7621,6 +7917,7 @@
},
fetchAllStatus: function() {
var thread, threads, _i, _len;
+
if (!(threads = ThreadWatcher.getAll()).length) {
return;
}
@@ -7632,6 +7929,7 @@
},
fetchStatus: function(_arg) {
var boardID, data, fetchCount, threadID;
+
boardID = _arg.boardID, threadID = _arg.threadID, data = _arg.data;
if (data.isDead) {
return;
@@ -7641,6 +7939,7 @@
return $.ajax("//api.4chan.org/" + boardID + "/res/" + threadID + ".json", {
onloadend: function() {
var status;
+
fetchCount.fetched++;
if (fetchCount.fetched === fetchCount.fetching) {
fetchCount.fetched = 0;
@@ -7671,6 +7970,7 @@
},
getAll: function() {
var all, boardID, data, threadID, threads, _ref;
+
all = [];
_ref = ThreadWatcher.db.data.boards;
for (boardID in _ref) {
@@ -7691,6 +7991,7 @@
},
makeLine: function(boardID, threadID, data) {
var div, fullID, href, link, x;
+
x = $.el('a', {
textContent: '×',
href: 'javascript:;'
@@ -7721,6 +8022,7 @@
},
refresh: function() {
var boardID, data, list, nodes, refresher, thread, threadID, toggler, watched, _i, _j, _len, _len1, _ref, _ref1, _ref2, _ref3;
+
nodes = [];
_ref = ThreadWatcher.getAll();
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
@@ -7748,6 +8050,7 @@
},
toggle: function(thread) {
var boardID, threadID;
+
boardID = thread.board.ID;
threadID = thread.ID;
if (ThreadWatcher.db.get({
@@ -7761,6 +8064,7 @@
},
add: function(thread) {
var boardID, data, threadID;
+
data = {};
boardID = thread.board.ID;
threadID = thread.ID;
@@ -7791,6 +8095,7 @@
},
convert: function(oldFormat) {
var boardID, data, newFormat, threadID, threads;
+
newFormat = {};
for (boardID in oldFormat) {
threads = oldFormat[boardID];
@@ -7807,6 +8112,7 @@
refreshers: [],
init: function() {
var menu;
+
if (!Conf['Thread Watcher']) {
return;
}
@@ -7819,6 +8125,7 @@
},
addHeaderMenuEntry: function() {
var entryEl;
+
if (g.VIEW !== 'thread') {
return;
}
@@ -7835,6 +8142,7 @@
});
return this.refreshers.push(function() {
var addClass, rmClass, text, _ref;
+
_ref = $('.current', ThreadWatcher.list) ? ['unwatch-thread', 'watch-thread', 'Unwatch thread'] : ['watch-thread', 'unwatch-thread', 'Watch thread'], addClass = _ref[0], rmClass = _ref[1], text = _ref[2];
$.addClass(entryEl, addClass);
$.rmClass(entryEl, rmClass);
@@ -7843,6 +8151,7 @@
},
addMenuEntries: function() {
var cb, conf, entries, entry, name, refresh, subEntries, _i, _len, _ref, _ref1, _results;
+
entries = [];
entries.push({
cb: ThreadWatcher.cb.openAll,
@@ -7913,6 +8222,7 @@
},
createSubEntry: function(name, desc) {
var entry, input;
+
entry = {
type: 'thread watcher',
el: $.el('label', {
@@ -7964,6 +8274,7 @@
},
ready: function() {
var ID, post, posts, _ref;
+
$.off(d, '4chanXInitFinished', Unread.ready);
posts = [];
_ref = Unread.thread.posts;
@@ -7980,6 +8291,7 @@
},
scroll: function() {
var checkPosition, hash, onload, post, posts, root;
+
if ((hash = location.hash.match(/\d+/)) && hash[0] in Unread.thread.posts) {
return;
}
@@ -8009,6 +8321,7 @@
}
checkPosition = function(target) {
var height, top, _ref;
+
_ref = target.getBoundingClientRect(), top = _ref.top, height = _ref.height;
return top + height - doc.clientHeight > 0;
};
@@ -8016,6 +8329,7 @@
},
sync: function() {
var lastReadPost;
+
lastReadPost = Unread.db.get({
boardID: Unread.thread.board.ID,
threadID: Unread.thread.ID,
@@ -8032,6 +8346,7 @@
},
addPosts: function(posts) {
var ID, data, post, _i, _len;
+
for (_i = 0, _len = posts.length; _i < _len; _i++) {
post = posts[_i];
ID = post.ID;
@@ -8059,6 +8374,7 @@
},
addPostQuotingYou: function(post) {
var quotelink, _i, _len, _ref;
+
if (!QR.db) {
return;
}
@@ -8079,6 +8395,7 @@
},
readSinglePost: function(post) {
var i;
+
if ((i = Unread.posts.indexOf(post)) === -1) {
return;
}
@@ -8094,6 +8411,7 @@
},
readArray: function(arr) {
var i, post, _i, _len;
+
for (i = _i = 0, _len = arr.length; _i < _len; i = ++_i) {
post = arr[i];
if (post.ID > Unread.lastReadPost) {
@@ -8104,6 +8422,7 @@
},
read: $.debounce(50, function(e) {
var ID, bottom, height, i, post, posts;
+
if (d.hidden || !Unread.posts.length) {
return;
}
@@ -8159,6 +8478,7 @@
}),
setLine: function(force) {
var post, root;
+
if (!(d.hidden || force === true)) {
return;
}
@@ -8173,6 +8493,7 @@
},
update: function(dontrepeat) {
var count;
+
count = Unread.posts.length;
if (Conf['Unread Count']) {
d.title = "" + (Conf['Quoted Title'] && Unread.postsQuotingYou.length ? '(!) ' : '') + (count || !Conf['Hide Unread Count at (0)'] ? "(" + count + ") " : '') + (g.DEAD ? "/" + g.BOARD + "/ - 404" : "" + Unread.title);
@@ -8198,6 +8519,7 @@
},
init: function() {
var archive, boardID, boards, data, id, name, type, _i, _len, _ref, _ref1, _ref2;
+
_ref = Conf['selectedArchives'];
for (boardID in _ref) {
data = _ref[boardID];
@@ -8329,6 +8651,7 @@
},
to: function(dest, data) {
var archive;
+
archive = (dest === 'search' ? Redirect.data.thread : Redirect.data[dest])[data.boardID];
if (!archive) {
return '';
@@ -8337,6 +8660,7 @@
},
protocol: function(archive) {
var protocol;
+
protocol = location.protocol;
if (!archive[protocol.slice(0, -1)]) {
protocol = protocol === 'https:' ? 'http:' : 'https:';
@@ -8345,6 +8669,7 @@
},
thread: function(archive, _arg) {
var boardID, path, postID, threadID;
+
boardID = _arg.boardID, threadID = _arg.threadID, postID = _arg.postID;
path = threadID ? "" + boardID + "/thread/" + threadID : "" + boardID + "/post/" + postID;
if (archive.software === 'foolfuuka') {
@@ -8357,6 +8682,7 @@
},
post: function(archive, _arg) {
var URL, boardID, postID, protocol;
+
boardID = _arg.boardID, postID = _arg.postID;
protocol = Redirect.protocol(archive);
if (['Foolz', 'NSFW Foolz'].contains(archive.name)) {
@@ -8368,11 +8694,13 @@
},
file: function(archive, _arg) {
var boardID, filename;
+
boardID = _arg.boardID, filename = _arg.filename;
return "" + (Redirect.protocol(archive)) + archive.domain + "/" + boardID + "/full_image/" + filename;
},
search: function(archive, _arg) {
var boardID, path, type, value;
+
boardID = _arg.boardID, type = _arg.type, value = _arg.value;
type = type === 'name' ? 'username' : type === 'MD5' ? 'image' : type;
value = encodeURIComponent(value);
@@ -8391,6 +8719,7 @@
},
setup: function() {
var btn, entry, psa;
+
$.off(d, '4chanXInitFinished', PSAHiding.setup);
if (!(psa = $.id('globalMessage'))) {
$.rmClass(doc, 'hide-announcement');
@@ -8419,6 +8748,7 @@
$.on(btn, 'click', PSAHiding.toggle);
$.get('hiddenPSA', 0, function(_arg) {
var hiddenPSA;
+
hiddenPSA = _arg.hiddenPSA;
PSAHiding.sync(hiddenPSA);
$.before(psa, btn);
@@ -8428,6 +8758,7 @@
},
toggle: function(e) {
var UTC;
+
if ($.hasClass(this, 'hide-announcement')) {
UTC = +$.id('globalMessage').dataset.utc;
$.set('hiddenPSA', UTC);
@@ -8439,6 +8770,7 @@
},
sync: function(UTC) {
var hr, psa;
+
psa = $.id('globalMessage');
psa.hidden = PSAHiding.btn.hidden = UTC && UTC >= +psa.dataset.utc ? true : false;
if ((hr = psa.nextElementSibling) && hr.nodeName === 'HR') {
@@ -8450,6 +8782,7 @@
CatalogLinks = {
init: function() {
var el, input;
+
if (!Conf['Catalog Links']) {
return;
}
@@ -8473,12 +8806,14 @@
},
toggle: function() {
var useCatalog;
+
$.event('CloseMenu');
$.set('Header catalog links', useCatalog = this.checked);
return CatalogLinks.set(useCatalog);
},
set: function(useCatalog) {
var a, board, path, _i, _len, _ref;
+
path = useCatalog ? 'catalog' : '';
_ref = $$("#board-list a[href*=\"boards.4chan.org\"]:not(.catalog),\n#boardNavDesktopFoot a[href*=\"boards.4chan.org\"]");
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
@@ -8502,7 +8837,7 @@
IDColor = {
init: function() {
- if (g.VIEW === 'catalog' || !Conf['Color user IDs']) {
+ if (g.VIEW === 'catalog' || !Conf['Color User IDs']) {
return;
}
return Post.prototype.callbacks.push({
@@ -8512,6 +8847,7 @@
},
node: function() {
var str, uid;
+
if (this.isClone || !(str = this.info.uniqueID)) {
return;
}
@@ -8524,6 +8860,7 @@
ids: {},
compute: function(str) {
var hash, rgb;
+
hash = IDColor.hash(str);
rgb = [(hash >> 24) & 0xFF, (hash >> 16) & 0xFF, (hash >> 8) & 0xFF];
rgb[3] = ((rgb[0] * 0.299) + (rgb[1] * 0.587) + (rgb[2] * 0.114)) > 125;
@@ -8535,6 +8872,7 @@
},
hash: function(str) {
var i, j, msg;
+
msg = 0;
i = 0;
j = str.length;
@@ -8582,6 +8920,7 @@
},
node: function() {
var dicestats, roll, _ref;
+
if (this.isClone || !(dicestats = (_ref = this.info.email) != null ? _ref.match(/dice[+\s](\d+)d(\d+)/) : void 0)) {
return;
}
@@ -8593,6 +8932,7 @@
Emoji = {
init: function() {
var css, icon, name, pos, _ref;
+
if (!Conf['Emoji']) {
return;
}
@@ -8662,6 +9002,7 @@
},
node: function() {
var a;
+
if (a = $('.abbr > a:not([onclick])', this.nodes.comment)) {
return $.on(a, 'click', ExpandComment.cb);
}
@@ -8673,6 +9014,7 @@
},
expand: function(post) {
var a;
+
if (post.nodes.longComment && !post.nodes.longComment.parentNode) {
$.replace(post.nodes.shortComment, post.nodes.longComment);
post.nodes.comment = post.nodes.longComment;
@@ -8688,6 +9030,7 @@
},
contract: function(post) {
var a;
+
if (!post.nodes.shortComment) {
return;
}
@@ -8698,6 +9041,7 @@
},
parse: function(req, a, post) {
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)) {
a.textContent = "Error " + req.statusText + " (" + status + ")";
@@ -8760,6 +9104,7 @@
},
node: function() {
var a, files, posts, span, _ref;
+
if (!(span = $.x('following-sibling::span[contains(@class,"summary")][1]', this.OP.nodes.root))) {
return;
}
@@ -8780,6 +9125,7 @@
},
toggle: function(thread) {
var a, files, filesCount, inlined, num, post, posts, postsCount, reply, threadRoot, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2, _ref3, _ref4;
+
threadRoot = thread.OP.nodes.root.parentNode;
a = $('.summary', threadRoot);
switch (thread.isExpanded) {
@@ -8857,6 +9203,7 @@
},
parse: function(req, thread, a) {
var filesCount, link, post, posts, postsCount, postsObj, postsRoot, reply, root, spoilerRange, _i, _len;
+
if (a.textContent[0] === '+') {
return;
}
@@ -8920,6 +9267,7 @@
},
createFunc: function(format) {
var code;
+
code = format.replace(/%(.)/g, function(s, c) {
if (c in FileInfo.formatters) {
return "' + FileInfo.formatters." + c + ".call(post) + '";
@@ -8931,6 +9279,7 @@
},
convertUnit: function(size, unit) {
var i;
+
if (unit === 'B') {
return "" + (size.toFixed()) + " Bytes";
}
@@ -8961,6 +9310,7 @@
},
n: function() {
var fullname, shortname;
+
fullname = this.file.name;
shortname = Build.shortFilename(this.file.name, this.isReply);
if (fullname === shortname) {
@@ -9004,6 +9354,7 @@
Fourchan = {
init: function() {
var board;
+
if (g.VIEW === 'catalog') {
return;
}
@@ -9025,6 +9376,7 @@
},
code: function() {
var pre, _i, _len, _ref;
+
if (this.isClone) {
return;
}
@@ -9054,11 +9406,13 @@
Keybinds = {
init: function() {
var init;
+
if (g.VIEW === 'catalog' || !Conf['Keybinds']) {
return;
}
init = function() {
var node, _i, _len, _ref;
+
$.off(d, '4chanXInitFinished', init);
$.on(d, 'keydown', Keybinds.keydown);
_ref = $$('[accesskey]');
@@ -9071,6 +9425,7 @@
},
keydown: function(e) {
var form, key, notification, notifications, op, target, thread, threadRoot, _i, _len;
+
if (!(key = Keybinds.keyCode(e))) {
return;
}
@@ -9251,6 +9606,7 @@
},
keyCode: function(e) {
var kc, key;
+
key = (function() {
switch (kc = e.keyCode) {
case 8:
@@ -9306,6 +9662,7 @@
},
tags: function(tag, ta) {
var range, selEnd, selStart, value;
+
value = ta.value;
selStart = ta.selectionStart;
selEnd = ta.selectionEnd;
@@ -9316,11 +9673,13 @@
},
sage: function() {
var isSage;
+
isSage = /sage/i.test(QR.nodes.email.value);
return QR.nodes.email.value = isSage ? "" : "sage";
},
img: function(thread, all) {
var post;
+
if (all) {
return ImageExpand.cb.toggleAll();
} else {
@@ -9330,6 +9689,7 @@
},
open: function(thread, tab) {
var url;
+
if (g.VIEW !== 'index') {
return;
}
@@ -9342,6 +9702,7 @@
},
hl: function(delta, thread) {
var axe, headRect, next, postEl, rect, replies, reply, root, topMargin, _i, _len;
+
if (!delta) {
if (postEl = $('.reply.highlight', thread)) {
$.rmClass(postEl, 'highlight');
@@ -9401,6 +9762,7 @@
Nav = {
init: function() {
var append, next, prev, span;
+
switch (g.VIEW) {
case 'index':
if (!Conf['Index Navigation']) {
@@ -9451,6 +9813,7 @@
},
getThread: function(full) {
var headRect, i, rect, thread, threads, topMargin, _i, _len;
+
if (Conf['Bottom header'] || !Conf['Fixed Header']) {
topMargin = 0;
} else {
@@ -9476,6 +9839,7 @@
},
scroll: function(delta) {
var i, rect, thread, threads, top, topMargin, _ref, _ref1;
+
_ref = Nav.getThread(true), threads = _ref[0], thread = _ref[1], i = _ref[2], rect = _ref[3], topMargin = _ref[4];
top = rect.top - topMargin;
if ((delta === -1 && top > -5) || (delta === +1 && top < 5)) {
@@ -9500,6 +9864,7 @@
},
node: function() {
var dateEl;
+
if (this.isClone) {
return;
}
@@ -9509,6 +9874,7 @@
},
relative: function(diff, now, date) {
var days, months, number, rounded, unit, years;
+
unit = (number = diff / $.DAY) >= 1 ? (years = now.getYear() - date.getYear(), months = now.getMonth() - date.getMonth(), days = now.getDate() - date.getDate(), years > 1 ? (number = years - (months < 0 || months === 0 && days < 0), 'year') : years === 1 && (months > 0 || months === 0 && days >= 0) ? (number = years, 'year') : (months = (months + 12) % 12) > 1 ? (number = months - (days < 0), 'month') : months === 1 && days >= 0 ? (number = months, 'month') : 'day') : (number = diff / $.HOUR) >= 1 ? 'hour' : (number = diff / $.MINUTE) >= 1 ? 'minute' : (number = Math.max(0, diff) / $.SECOND, 'second');
rounded = Math.round(number);
if (rounded !== 1) {
@@ -9519,6 +9885,7 @@
stale: [],
flush: function() {
var now, update, _i, _len, _ref;
+
if (d.hidden) {
return;
}
@@ -9534,13 +9901,16 @@
},
setUpdate: function(post) {
var markStale, setOwnTimeout, update;
+
setOwnTimeout = function(diff) {
var delay;
+
delay = diff < $.MINUTE ? $.SECOND - (diff + $.SECOND / 2) % $.SECOND : diff < $.HOUR ? $.MINUTE - (diff + $.MINUTE / 2) % $.MINUTE : diff < $.DAY ? $.HOUR - (diff + $.HOUR / 2) % $.HOUR : $.DAY - (diff + $.DAY / 2) % $.DAY;
return setTimeout(markStale, delay);
};
update = function(now) {
var date, diff, relative, singlePost, _i, _len, _ref;
+
date = post.info.date;
diff = now - date;
relative = RelativeDates.relative(diff, now, date);
@@ -9581,6 +9951,7 @@
},
node: function(post) {
var spoiler, spoilers, _i, _len;
+
spoilers = $$('s', this.nodes.comment);
for (_i = 0, _len = spoilers.length; _i < _len; _i++) {
spoiler = spoilers[_i];
@@ -9600,6 +9971,7 @@
},
ready: function() {
var field;
+
field = $.id('recaptcha_response_field');
$.on(field, 'keydown', function(e) {
if (e.keyCode === 8 && !field.value) {
@@ -9608,6 +9980,7 @@
});
return $.on($('form'), 'submit', function(e) {
var response;
+
e.preventDefault();
response = field.value.trim();
if (!/\s/.test(response)) {
@@ -9637,6 +10010,7 @@
},
createFunc: function(format) {
var code;
+
code = format.replace(/%([A-Za-z])/g, function(s, c) {
if (c in Time.formatters) {
return "' + Time.formatters." + c + ".call(date) + '";
@@ -9721,6 +10095,7 @@
Settings = {
init: function() {
var link, settings;
+
link = $.el('a', {
className: 'settings-link',
textContent: 'Settings',
@@ -9730,6 +10105,7 @@
Header.addShortcut(link);
$.get('previousversion', null, function(item) {
var changelog, el, previous;
+
if (previous = item['previousversion']) {
if (previous === g.VERSION) {
return;
@@ -9764,6 +10140,7 @@
},
open: function(openSection) {
var dialog, html, link, links, overlay, section, sectionToOpen, _i, _len, _ref;
+
$.off(d, '4chanXInitFinished', Settings.open);
if (Settings.dialog) {
return;
@@ -9816,6 +10193,7 @@
sections: [],
addSection: function(title, open) {
var hyphenatedTitle, _ref;
+
if (typeof title !== 'string') {
_ref = title.detail, title = _ref.title, open = _ref.open;
}
@@ -9828,6 +10206,7 @@
},
openSection: function() {
var section, selected;
+
if (selected = $('.tab-selected', Settings.dialog)) {
$.rmClass(selected, 'tab-selected');
}
@@ -9841,6 +10220,7 @@
},
main: function(section) {
var arr, button, description, div, fs, hiddenNum, input, inputs, items, key, obj, _ref;
+
items = {};
inputs = {};
_ref = Config.main;
@@ -9865,6 +10245,7 @@
}
$.get(items, function(items) {
var val;
+
for (key in items) {
val = items[key];
inputs[key].checked = val;
@@ -9879,6 +10260,7 @@
boards: {}
}, function(item) {
var ID, board, thread, _ref1;
+
_ref1 = item.hiddenThreads.boards;
for (ID in _ref1) {
board = _ref1[ID];
@@ -9893,6 +10275,7 @@
boards: {}
}, function(item) {
var ID, board, post, thread, _ref1;
+
_ref1 = item.hiddenPosts.boards;
for (ID in _ref1) {
board = _ref1[ID];
@@ -9912,6 +10295,7 @@
boards: {}
}, function(item) {
var boardID;
+
for (boardID in item.hiddenThreads.boards) {
localStorage.removeItem("4chan-hide-t-" + boardID);
}
@@ -9922,6 +10306,7 @@
},
"export": function(now, data) {
var a, db, _i, _len;
+
if (typeof now !== 'number') {
now = Date.now();
data = {
@@ -9955,6 +10340,7 @@
},
onImport: function() {
var file, output, reader;
+
if (!(file = this.files[0])) {
return;
}
@@ -9966,6 +10352,7 @@
reader = new FileReader();
reader.onload = function(e) {
var data, err;
+
try {
data = JSON.parse(e.target.result);
Settings.loadSettings(data);
@@ -9982,6 +10369,7 @@
},
loadSettings: function(data) {
var key, val, version, _ref;
+
version = data.version.split('.');
if (version[0] === '2') {
data = Settings.convertSettings(data, {
@@ -10069,6 +10457,7 @@
},
convertSettings: function(data, map) {
var newKey, prevKey;
+
for (prevKey in map) {
newKey = map[prevKey];
if (newKey) {
@@ -10080,6 +10469,7 @@
},
filter: function(section) {
var select;
+
section.innerHTML = "";
select = $('select', section);
$.on(select, 'change', Settings.selectFilter);
@@ -10087,6 +10477,7 @@
},
selectFilter: function() {
var div, name, ta;
+
div = this.nextElementSibling;
if ((name = this.value) !== 'guide') {
$.rmAll(div);
@@ -10106,6 +10497,7 @@
},
sauce: function(section) {
var ta;
+
section.innerHTML = " Sauce is disabled.
Lines starting with a # will be ignored.
You can specify a display text by appending ;text:[text] to the URL.
These parameters will be replaced by their corresponding values:\n%TURL: Thumbnail URL.%URL: Full image URL.%MD5: MD5 hash.%board: Current board.
";
ta = $('textarea', section);
$.get('sauces', Conf['sauces'], function(item) {
@@ -10115,6 +10507,7 @@
},
advanced: function(section) {
var archive, boardID, boardOptions, boardSelect, boards, data, event, input, inputs, item, items, name, row, rows, ta, table, _i, _j, _k, _l, _len, _len1, _len2, _len3, _ref, _ref1, _ref2, _ref3, _ref4;
+
section.innerHTML = " ";
items = {};
inputs = {};
@@ -10134,6 +10527,7 @@
$.on(ta, 'change', $.cb.value);
$.get(items, function(items) {
var key, val;
+
for (key in items) {
val = items[key];
if (['emojiPos'].contains(key)) {
@@ -10204,6 +10598,7 @@
});
$.get('selectedArchives', Conf['selectedArchives'], function(_arg) {
var option, selectedArchives, type;
+
selectedArchives = _arg.selectedArchives;
for (boardID in selectedArchives) {
data = selectedArchives[boardID];
@@ -10218,6 +10613,7 @@
},
addArchiveCell: function(boardID, data, type) {
var archive, i, length, options, select, td;
+
length = data[type].length;
td = $.el('td', {
className: 'archive-cell'
@@ -10247,8 +10643,10 @@
},
saveSelectedArchive: function() {
var _this = this;
+
return $.get('selectedArchives', Conf['selectedArchives'], function(_arg) {
var selectedArchives, _name;
+
selectedArchives = _arg.selectedArchives;
(selectedArchives[_name = _this.dataset.boardid] || (selectedArchives[_name] = {}))[_this.dataset.type] = _this.value;
return $.set('selectedArchives', selectedArchives);
@@ -10259,6 +10657,7 @@
},
time: function() {
var funk;
+
funk = Time.createFunc(this.value);
return this.nextElementSibling.textContent = funk(Time, new Date());
},
@@ -10267,6 +10666,7 @@
},
fileInfo: function() {
var data, funk;
+
data = {
isReply: true,
file: {
@@ -10305,6 +10705,7 @@
},
keybinds: function(section) {
var arr, input, inputs, items, key, tbody, tr, _ref;
+
section.innerHTML = "Keybinds are disabled.
Allowed keys: a-z, 0-9, Ctrl, Shift, Alt, Meta, Enter, Esc, Up, Down, Right, Left.
Press Backspace to disable a keybind.
";
tbody = $('tbody', section);
items = {};
@@ -10325,6 +10726,7 @@
}
return $.get(items, function(items) {
var val;
+
for (key in items) {
val = items[key];
inputs[key].value = val;
@@ -10333,6 +10735,7 @@
},
keybind: function(e) {
var key;
+
if (e.keyCode === 9) {
return;
}
@@ -10349,8 +10752,10 @@
Main = {
init: function() {
var db, flatten, _i, _len;
+
flatten = function(parent, obj) {
var key, val;
+
if (obj instanceof Array) {
Conf[parent] = obj[0];
} else if (typeof obj === 'object') {
@@ -10391,6 +10796,7 @@
},
initFeatures: function() {
var init, pathname, _ref;
+
pathname = location.pathname.split('/');
g.BOARD = new Board(pathname[1]);
if ((_ref = g.BOARD.ID) === 'z' || _ref === 'fk') {
@@ -10418,6 +10824,7 @@
case 'images.4chan.org':
$.ready(function() {
var URL;
+
if (Conf['404 Redirect'] && ['4chan - Temporarily Offline', '4chan - 404 Not Found'].contains(d.title)) {
Redirect.init();
pathname = location.pathname.split('/');
@@ -10434,6 +10841,7 @@
}
init = function(features) {
var err, module, name;
+
for (name in features) {
module = features[name];
try {
@@ -10511,6 +10919,7 @@
},
initStyle: function() {
var mainStyleSheet, setStyle, style, styleSheets, _ref;
+
$.off(d, '4chanMainInit', Main.initStyle);
if (!Main.isThisPageLegit() || $.hasClass(doc, 'fourchan-x')) {
return;
@@ -10532,6 +10941,7 @@
styleSheets = $$('link[rel="alternate stylesheet"]', d.head);
setStyle = function() {
var styleSheet, _i, _len;
+
$.rmClass(doc, style);
for (_i = 0, _len = styleSheets.length; _i < _len; _i++) {
styleSheet = styleSheets[_i];
@@ -10553,6 +10963,7 @@
},
initReady: function() {
var board, err, errors, href, passLink, postRoot, posts, styleSelector, thread, threadRoot, threads, _i, _j, _len, _len1, _ref, _ref1;
+
if (['4chan - Temporarily Offline', '4chan - 404 Not Found'].contains(d.title)) {
if (Conf['404 Redirect'] && g.VIEW === 'thread') {
href = Redirect.to('thread', {
@@ -10619,6 +11030,7 @@
},
callbackNodes: function(klass, nodes) {
var callback, err, errors, i, len, node, _i, _len, _ref;
+
len = nodes.length;
_ref = klass.prototype.callbacks;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
@@ -10646,9 +11058,11 @@
},
callbackNodesDB: function(klass, nodes, cb) {
var errors, func, i, len, node, queue, softTask;
+
queue = [];
softTask = function() {
var args, func, task;
+
task = queue.shift();
func = task[0];
args = Array.prototype.slice.call(task, 1);
@@ -10667,6 +11081,7 @@
errors = null;
func = function(node, i) {
var callback, err, _i, _len, _ref;
+
_ref = klass.prototype.callbacks;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
callback = _ref[_i];
@@ -10700,6 +11115,7 @@
},
addCallback: function(e) {
var Klass, obj;
+
obj = e.detail;
if (typeof obj.callback.name !== 'string') {
throw new Error("Invalid callback name: " + obj.callback.name);
@@ -10719,6 +11135,7 @@
},
handleErrors: function(errors) {
var div, error, logs, _i, _len;
+
if (!(errors instanceof Array)) {
error = errors;
} else if (errors.length === 1) {
@@ -10733,6 +11150,7 @@
});
$.on(div.lastElementChild, 'click', function() {
var _ref;
+
return _ref = this.textContent === 'show' ? ['hide', false] : ['show', true], this.textContent = _ref[0], logs.hidden = _ref[1], _ref;
});
logs = $.el('div', {
@@ -10746,6 +11164,7 @@
},
parseError: function(data) {
var error, message;
+
Main.logError(data);
message = $.el('div', {
textContent: data.message
@@ -10762,6 +11181,7 @@
},
isThisPageLegit: function() {
var _ref;
+
if (!('thisPageIsLegit' in Main)) {
Main.thisPageIsLegit = location.hostname === 'boards.4chan.org' && !$('link[href*="favicon-status.ico"]', d.head) && ((_ref = d.title) !== '4chan - Temporarily Offline' && _ref !== '4chan - Error' && _ref !== '504 Gateway Time-out');
}
diff --git a/latest.js b/latest.js
index 2bc1a0dda..0af3ad794 100755
--- a/latest.js
+++ b/latest.js
@@ -1 +1 @@
-postMessage({version:'1.2.28'},'*')
+postMessage({version:'1.2.29'},'*')
diff --git a/package.json b/package.json
index 95bf2d050..fc84e2550 100755
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "4chan-X",
- "version": "1.2.28",
+ "version": "1.2.29",
"description": "Cross-browser userscript for maximum lurking on 4chan.",
"meta": {
diff --git a/src/Miscellaneous/ColorUserIDs.coffee b/src/Miscellaneous/ColorUserIDs.coffee
index 754dd5add..4bc8ed15c 100755
--- a/src/Miscellaneous/ColorUserIDs.coffee
+++ b/src/Miscellaneous/ColorUserIDs.coffee
@@ -1,6 +1,6 @@
IDColor =
init: ->
- return if g.VIEW is 'catalog' or !Conf['Color user IDs']
+ return if g.VIEW is 'catalog' or !Conf['Color User IDs']
Post::callbacks.push
name: 'Color User IDs'
diff --git a/src/Posting/QuickReply.coffee b/src/Posting/QuickReply.coffee
index d0dc911b5..be71207b9 100755
--- a/src/Posting/QuickReply.coffee
+++ b/src/Posting/QuickReply.coffee
@@ -443,7 +443,13 @@ QR =
QR.nodes.fileInput.click()
fileInput: (files) ->
- if files instanceof Event # file input
+ try
+ if files instanceof Event # file input
+ check = true
+ catch err
+ if @ instanceof Element # file input
+ check = true
+ if check
files = [@files...]
QR.nodes.fileInput.value = null # Don't hold the files from being modified on windows
{length} = files