Fix type and build
This commit is contained in:
parent
3470929e05
commit
56387a7162
@ -22,7 +22,7 @@
|
||||
// ==/UserScript==
|
||||
|
||||
/*
|
||||
* 4chan X - Version 1.2.37 - 2013-09-12
|
||||
* 4chan X - Version 1.2.37 - 2013-09-19
|
||||
*
|
||||
* Licensed under the MIT license.
|
||||
* https://github.com/seaweedchan/4chan-x/blob/master/LICENSE
|
||||
@ -241,7 +241,7 @@
|
||||
uniqueID: "# Filter a specific ID:\n#/Txhvk1Tl/",
|
||||
tripcode: "# Filter any tripfag\n#/^!/",
|
||||
capcode: "# Set a custom class for mods:\n#/Mod$/;highlight:mod;op:yes\n# Set a custom class for moot:\n#/Admin$/;highlight:moot;op:yes",
|
||||
email: "# Filter any e-mails that are not `sage` on /a/ and /jp/:\n#/^(?!sage$)/;boards:a,jp",
|
||||
email: "",
|
||||
subject: "# Filter Generals on /v/:\n#/general/i;boards:v;op:only",
|
||||
comment: "# Filter Stallman copypasta on /g/:\n#/what you\'re refer+ing to as linux/i;boards:g",
|
||||
flag: '',
|
||||
@ -956,7 +956,7 @@
|
||||
|
||||
this.nodes.comment.normalize();
|
||||
bq = this.nodes.comment.cloneNode(true);
|
||||
nodes = $$('.abbr, .capcodeReplies, .exif, b', bq);
|
||||
nodes = $$('.abbr, .exif, b', bq);
|
||||
i = 0;
|
||||
while (node = nodes[i++]) {
|
||||
$.rm(node);
|
||||
@ -988,7 +988,7 @@
|
||||
return;
|
||||
}
|
||||
this.nodes.quotelinks.push(quotelink);
|
||||
if (this.isClone || !this.isReply && $.hasClass(quotelink.parentNode.parentNode, 'capcodeReplies')) {
|
||||
if (this.isClone) {
|
||||
return;
|
||||
}
|
||||
fullID = "" + match[1] + "." + match[2];
|
||||
@ -1931,7 +1931,6 @@
|
||||
date: data.now,
|
||||
dateUTC: data.time,
|
||||
comment: data.com,
|
||||
capcodeReplies: data.capcode_replies,
|
||||
isSticky: !!data.sticky,
|
||||
isClosed: !!data.closed
|
||||
};
|
||||
@ -1959,9 +1958,9 @@
|
||||
@license: https://github.com/4chan/4chan-JS/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
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;
|
||||
var a, boardID, capcode, capcodeClass, capcodeStart, closed, 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;
|
||||
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, file = o.file;
|
||||
isOP = postID === threadID;
|
||||
staticPath = '//static.4chan.org/image/';
|
||||
if (email) {
|
||||
@ -2049,47 +2048,7 @@
|
||||
}
|
||||
quote.href = "/" + boardID + "/res/" + href;
|
||||
}
|
||||
Build.capcodeReplies({
|
||||
boardID: boardID,
|
||||
threadID: threadID,
|
||||
root: container,
|
||||
capcodeReplies: capcodeReplies
|
||||
});
|
||||
return container;
|
||||
},
|
||||
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;
|
||||
}
|
||||
generateCapcodeReplies = function(capcodeType, array) {
|
||||
return "<span class=smaller><span class=bold>" + ((function() {
|
||||
switch (capcodeType) {
|
||||
case 'admin':
|
||||
return 'Administrator';
|
||||
case 'mod':
|
||||
return 'Moderator';
|
||||
case 'developer':
|
||||
return 'Developer';
|
||||
}
|
||||
})()) + " Repl" + (array.length > 1 ? 'ies' : 'y') + ":</span> " + (array.map(function(ID) {
|
||||
return "<a href='/" + boardID + "/res/" + threadID + "#p" + ID + "' class=quotelink>>>" + ID + "</a>";
|
||||
}).join(' ')) + "</span><br>";
|
||||
};
|
||||
html = [];
|
||||
for (capcodeType in capcodeReplies) {
|
||||
array = capcodeReplies[capcodeType];
|
||||
html.push(generateCapcodeReplies(capcodeType, array));
|
||||
}
|
||||
bq || (bq = $('blockquote', root));
|
||||
return $.add(bq, [
|
||||
$.el('br'), $.el('br'), $.el('span', {
|
||||
className: 'capcodeReplies',
|
||||
innerHTML: html.join('')
|
||||
})
|
||||
]);
|
||||
}
|
||||
};
|
||||
|
||||
@ -2825,12 +2784,8 @@
|
||||
delete this.nodes.tripcode;
|
||||
}
|
||||
if (this.info.email) {
|
||||
if (/sage/i.test(this.info.email)) {
|
||||
return email.href = 'mailto:sage';
|
||||
} else {
|
||||
$.replace(email, name);
|
||||
return delete this.nodes.email;
|
||||
}
|
||||
$.replace(email, name);
|
||||
return delete this.nodes.email;
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -5308,36 +5263,30 @@
|
||||
},
|
||||
cooldown: {
|
||||
init: function() {
|
||||
var board;
|
||||
var key, setTimers, type, _base,
|
||||
_this = this;
|
||||
|
||||
if (!Conf['Cooldown']) {
|
||||
return;
|
||||
}
|
||||
board = g.BOARD.ID;
|
||||
QR.cooldown.types = {
|
||||
thread: (function() {
|
||||
switch (board) {
|
||||
case 'q':
|
||||
return 86400;
|
||||
case 'b':
|
||||
case 'soc':
|
||||
case 'r9k':
|
||||
return 600;
|
||||
default:
|
||||
return 300;
|
||||
}
|
||||
})(),
|
||||
sage: board === 'q' ? 600 : 60,
|
||||
file: board === 'q' ? 300 : 30,
|
||||
post: board === 'q' ? 150 : 30
|
||||
setTimers = function(e) {
|
||||
return QR.cooldown.types = e.detail;
|
||||
};
|
||||
$.on(window, 'cooldown:timers', setTimers);
|
||||
$.globalEval('window.dispatchEvent(new CustomEvent("cooldown:timers", {detail: cooldowns}))');
|
||||
(_base = QR.cooldown).types || (_base.types = {});
|
||||
$.off(window, 'cooldown:timers', setTimers);
|
||||
for (type in QR.cooldown.types) {
|
||||
QR.cooldown.types[type] = +QR.cooldown.types[type];
|
||||
}
|
||||
QR.cooldown.upSpd = 0;
|
||||
QR.cooldown.upSpdAccuracy = .5;
|
||||
$.get("cooldown." + board, {}, function(item) {
|
||||
QR.cooldown.cooldowns = item["cooldown." + board];
|
||||
key = "cooldown." + g.BOARD;
|
||||
$.get(key, {}, function(item) {
|
||||
QR.cooldown.cooldowns = item[key];
|
||||
return QR.cooldown.start();
|
||||
});
|
||||
return $.sync("cooldown." + board, QR.cooldown.sync);
|
||||
return $.sync(key, QR.cooldown.sync);
|
||||
},
|
||||
start: function() {
|
||||
if (!Conf['Cooldown']) {
|
||||
@ -5358,12 +5307,12 @@
|
||||
return QR.cooldown.start();
|
||||
},
|
||||
set: function(data) {
|
||||
var cooldown, delay, hasFile, isReply, isSage, post, req, start, type, upSpd;
|
||||
var cooldown, delay, hasFile, isReply, post, req, start, threadID, upSpd;
|
||||
|
||||
if (!Conf['Cooldown']) {
|
||||
return;
|
||||
}
|
||||
req = data.req, post = data.post, isReply = data.isReply, delay = data.delay;
|
||||
req = data.req, post = data.post, isReply = data.isReply, threadID = data.threadID, delay = data.delay;
|
||||
start = req ? req.uploadEndTime : Date.now();
|
||||
if (delay) {
|
||||
cooldown = {
|
||||
@ -5371,18 +5320,15 @@
|
||||
};
|
||||
} else {
|
||||
if (post.file) {
|
||||
upSpd = post.file.size / ((req.uploadEndTime - req.uploadStartTime) / $.SECOND);
|
||||
upSpd = post.file.size / ((start - req.uploadStartTime) / $.SECOND);
|
||||
QR.cooldown.upSpdAccuracy = ((upSpd > QR.cooldown.upSpd * .9) + QR.cooldown.upSpdAccuracy) / 2;
|
||||
QR.cooldown.upSpd = upSpd;
|
||||
}
|
||||
isSage = /sage/i.test(post.email);
|
||||
hasFile = !!post.file;
|
||||
type = !isReply ? 'thread' : isSage ? 'sage' : hasFile ? 'file' : 'post';
|
||||
cooldown = {
|
||||
isReply: isReply,
|
||||
isSage: isSage,
|
||||
hasFile: hasFile,
|
||||
timeout: start + QR.cooldown.types[type] * $.SECOND
|
||||
threadID: threadID
|
||||
};
|
||||
}
|
||||
QR.cooldown.cooldowns[start] = cooldown;
|
||||
@ -5398,7 +5344,7 @@
|
||||
}
|
||||
},
|
||||
count: function() {
|
||||
var cooldown, cooldowns, elapsed, hasFile, isReply, isSage, now, post, seconds, start, type, types, upSpd, upSpdAccuracy, update, _ref;
|
||||
var cooldown, cooldowns, elapsed, hasFile, isReply, maxTimer, now, post, seconds, start, type, types, upSpd, upSpdAccuracy, update, _ref;
|
||||
|
||||
if (!Object.keys(QR.cooldown.cooldowns).length) {
|
||||
$["delete"]("" + g.BOARD + ".cooldown");
|
||||
@ -5407,11 +5353,11 @@
|
||||
QR.status();
|
||||
return;
|
||||
}
|
||||
setTimeout(QR.cooldown.count, $.SECOND);
|
||||
clearTimeout(QR.cooldown.timeout);
|
||||
QR.cooldown.timeout = setTimeout(QR.cooldown.count, $.SECOND);
|
||||
now = Date.now();
|
||||
post = QR.posts[0];
|
||||
isReply = post.thread !== 'new';
|
||||
isSage = /sage/i.test(post.email);
|
||||
hasFile = !!post.file;
|
||||
seconds = null;
|
||||
_ref = QR.cooldown, types = _ref.types, cooldowns = _ref.cooldowns, upSpd = _ref.upSpd, upSpdAccuracy = _ref.upSpdAccuracy;
|
||||
@ -5426,20 +5372,29 @@
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (isReply === cooldown.isReply) {
|
||||
type = !isReply ? 'thread' : isSage && cooldown.isSage ? 'sage' : hasFile && cooldown.hasFile ? 'file' : 'post';
|
||||
elapsed = Math.floor((now - start) / $.SECOND);
|
||||
if (elapsed >= 0) {
|
||||
seconds = Math.max(seconds, types[type] - elapsed);
|
||||
if (Conf['Cooldown Prediction'] && hasFile && upSpd) {
|
||||
seconds -= Math.floor(post.file.size / upSpd * upSpdAccuracy);
|
||||
seconds = Math.max(seconds, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!((start <= now && now <= cooldown.timeout))) {
|
||||
if ('timeout' in cooldown) {
|
||||
QR.cooldown.unset(start);
|
||||
continue;
|
||||
}
|
||||
if (isReply === cooldown.isReply) {
|
||||
elapsed = Math.floor((now - start) / $.SECOND);
|
||||
if (elapsed < 0) {
|
||||
continue;
|
||||
}
|
||||
type = !isReply ? 'thread' : hasFile ? 'image' : 'reply';
|
||||
maxTimer = Math.max(types[type] || 0, types[type + '_intra'] || 0);
|
||||
if (!((start <= now && now <= start + maxTimer * $.SECOND))) {
|
||||
QR.cooldown.unset(start);
|
||||
}
|
||||
if (isReply && +post.thread === cooldown.threadID) {
|
||||
type += '_intra';
|
||||
}
|
||||
seconds = Math.max(seconds, types[type] - elapsed);
|
||||
}
|
||||
}
|
||||
if (seconds && Conf['Cooldown Prediction'] && hasFile && upSpd) {
|
||||
seconds -= Math.floor(post.file.size / upSpd * upSpdAccuracy);
|
||||
seconds = Math.max(seconds, 0);
|
||||
}
|
||||
update = seconds !== null || !!QR.cooldown.seconds;
|
||||
QR.cooldown.seconds = seconds;
|
||||
@ -6269,7 +6224,7 @@
|
||||
thread = g.BOARD.threads[threadID];
|
||||
if (threadID === 'new') {
|
||||
threadID = null;
|
||||
if (['vg', 'q'].contains(g.BOARD.ID) && !post.sub) {
|
||||
if (g.BOARD.ID === 'vg' && !post.sub) {
|
||||
err = 'New threads require a subject.';
|
||||
} else if (!(post.file || (textOnly = !!$('input[name=textonly]', $.id('postForm'))))) {
|
||||
err = 'No file selected.';
|
||||
@ -6448,7 +6403,8 @@
|
||||
QR.cooldown.set({
|
||||
req: req,
|
||||
post: post,
|
||||
isReply: isReply
|
||||
isReply: isReply,
|
||||
threadID: threadID
|
||||
});
|
||||
URL = threadID === postID ? "/" + g.BOARD + "/res/" + threadID : g.VIEW === 'index' && !QR.cooldown.auto && Conf['Open Post in New Tab'] ? "/" + g.BOARD + "/res/" + threadID + "#p" + postID : void 0;
|
||||
if (URL) {
|
||||
@ -7462,7 +7418,7 @@
|
||||
open: function(post) {
|
||||
var node;
|
||||
|
||||
if (post.isDead || post.board.ID === 'q') {
|
||||
if (post.isDead) {
|
||||
return false;
|
||||
}
|
||||
DeleteLink.post = post;
|
||||
@ -9697,12 +9653,6 @@
|
||||
}
|
||||
quote.href = "/" + post.board + "/res/" + href;
|
||||
}
|
||||
Build.capcodeReplies({
|
||||
boardID: post.board.ID,
|
||||
threadID: post.thread.ID,
|
||||
bq: clone,
|
||||
capcodeReplies: postObj.capcode_replies
|
||||
});
|
||||
post.nodes.shortComment = comment;
|
||||
$.replace(comment, clone);
|
||||
post.nodes.comment = post.nodes.longComment = clone;
|
||||
@ -9788,7 +9738,6 @@
|
||||
switch (g.BOARD.ID) {
|
||||
case 'b':
|
||||
case 'vg':
|
||||
case 'q':
|
||||
return 3;
|
||||
case 't':
|
||||
return 1;
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
// Generated by CoffeeScript
|
||||
/*
|
||||
* 4chan X - Version 1.2.37 - 2013-09-12
|
||||
* 4chan X - Version 1.2.37 - 2013-09-19
|
||||
*
|
||||
* Licensed under the MIT license.
|
||||
* https://github.com/seaweedchan/4chan-x/blob/master/LICENSE
|
||||
@ -220,7 +220,7 @@
|
||||
uniqueID: "# Filter a specific ID:\n#/Txhvk1Tl/",
|
||||
tripcode: "# Filter any tripfag\n#/^!/",
|
||||
capcode: "# Set a custom class for mods:\n#/Mod$/;highlight:mod;op:yes\n# Set a custom class for moot:\n#/Admin$/;highlight:moot;op:yes",
|
||||
email: "# Filter any e-mails that are not `sage` on /a/ and /jp/:\n#/^(?!sage$)/;boards:a,jp",
|
||||
email: "",
|
||||
subject: "# Filter Generals on /v/:\n#/general/i;boards:v;op:only",
|
||||
comment: "# Filter Stallman copypasta on /g/:\n#/what you\'re refer+ing to as linux/i;boards:g",
|
||||
flag: '',
|
||||
@ -965,7 +965,7 @@
|
||||
|
||||
this.nodes.comment.normalize();
|
||||
bq = this.nodes.comment.cloneNode(true);
|
||||
nodes = $$('.abbr, .capcodeReplies, .exif, b', bq);
|
||||
nodes = $$('.abbr, .exif, b', bq);
|
||||
i = 0;
|
||||
while (node = nodes[i++]) {
|
||||
$.rm(node);
|
||||
@ -997,7 +997,7 @@
|
||||
return;
|
||||
}
|
||||
this.nodes.quotelinks.push(quotelink);
|
||||
if (this.isClone || !this.isReply && $.hasClass(quotelink.parentNode.parentNode, 'capcodeReplies')) {
|
||||
if (this.isClone) {
|
||||
return;
|
||||
}
|
||||
fullID = "" + match[1] + "." + match[2];
|
||||
@ -1945,7 +1945,6 @@
|
||||
date: data.now,
|
||||
dateUTC: data.time,
|
||||
comment: data.com,
|
||||
capcodeReplies: data.capcode_replies,
|
||||
isSticky: !!data.sticky,
|
||||
isClosed: !!data.closed
|
||||
};
|
||||
@ -1973,9 +1972,9 @@
|
||||
@license: https://github.com/4chan/4chan-JS/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
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;
|
||||
var a, boardID, capcode, capcodeClass, capcodeStart, closed, 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;
|
||||
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, file = o.file;
|
||||
isOP = postID === threadID;
|
||||
staticPath = '//static.4chan.org/image/';
|
||||
if (email) {
|
||||
@ -2063,47 +2062,7 @@
|
||||
}
|
||||
quote.href = "/" + boardID + "/res/" + href;
|
||||
}
|
||||
Build.capcodeReplies({
|
||||
boardID: boardID,
|
||||
threadID: threadID,
|
||||
root: container,
|
||||
capcodeReplies: capcodeReplies
|
||||
});
|
||||
return container;
|
||||
},
|
||||
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;
|
||||
}
|
||||
generateCapcodeReplies = function(capcodeType, array) {
|
||||
return "<span class=smaller><span class=bold>" + ((function() {
|
||||
switch (capcodeType) {
|
||||
case 'admin':
|
||||
return 'Administrator';
|
||||
case 'mod':
|
||||
return 'Moderator';
|
||||
case 'developer':
|
||||
return 'Developer';
|
||||
}
|
||||
})()) + " Repl" + (array.length > 1 ? 'ies' : 'y') + ":</span> " + (array.map(function(ID) {
|
||||
return "<a href='/" + boardID + "/res/" + threadID + "#p" + ID + "' class=quotelink>>>" + ID + "</a>";
|
||||
}).join(' ')) + "</span><br>";
|
||||
};
|
||||
html = [];
|
||||
for (capcodeType in capcodeReplies) {
|
||||
array = capcodeReplies[capcodeType];
|
||||
html.push(generateCapcodeReplies(capcodeType, array));
|
||||
}
|
||||
bq || (bq = $('blockquote', root));
|
||||
return $.add(bq, [
|
||||
$.el('br'), $.el('br'), $.el('span', {
|
||||
className: 'capcodeReplies',
|
||||
innerHTML: html.join('')
|
||||
})
|
||||
]);
|
||||
}
|
||||
};
|
||||
|
||||
@ -2832,12 +2791,8 @@
|
||||
delete this.nodes.tripcode;
|
||||
}
|
||||
if (this.info.email) {
|
||||
if (/sage/i.test(this.info.email)) {
|
||||
return email.href = 'mailto:sage';
|
||||
} else {
|
||||
$.replace(email, name);
|
||||
return delete this.nodes.email;
|
||||
}
|
||||
$.replace(email, name);
|
||||
return delete this.nodes.email;
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -5318,36 +5273,30 @@
|
||||
},
|
||||
cooldown: {
|
||||
init: function() {
|
||||
var board;
|
||||
var key, setTimers, type, _base,
|
||||
_this = this;
|
||||
|
||||
if (!Conf['Cooldown']) {
|
||||
return;
|
||||
}
|
||||
board = g.BOARD.ID;
|
||||
QR.cooldown.types = {
|
||||
thread: (function() {
|
||||
switch (board) {
|
||||
case 'q':
|
||||
return 86400;
|
||||
case 'b':
|
||||
case 'soc':
|
||||
case 'r9k':
|
||||
return 600;
|
||||
default:
|
||||
return 300;
|
||||
}
|
||||
})(),
|
||||
sage: board === 'q' ? 600 : 60,
|
||||
file: board === 'q' ? 300 : 30,
|
||||
post: board === 'q' ? 150 : 30
|
||||
setTimers = function(e) {
|
||||
return QR.cooldown.types = e.detail;
|
||||
};
|
||||
$.on(window, 'cooldown:timers', setTimers);
|
||||
$.globalEval('window.dispatchEvent(new CustomEvent("cooldown:timers", {detail: cooldowns}))');
|
||||
(_base = QR.cooldown).types || (_base.types = {});
|
||||
$.off(window, 'cooldown:timers', setTimers);
|
||||
for (type in QR.cooldown.types) {
|
||||
QR.cooldown.types[type] = +QR.cooldown.types[type];
|
||||
}
|
||||
QR.cooldown.upSpd = 0;
|
||||
QR.cooldown.upSpdAccuracy = .5;
|
||||
$.get("cooldown." + board, {}, function(item) {
|
||||
QR.cooldown.cooldowns = item["cooldown." + board];
|
||||
key = "cooldown." + g.BOARD;
|
||||
$.get(key, {}, function(item) {
|
||||
QR.cooldown.cooldowns = item[key];
|
||||
return QR.cooldown.start();
|
||||
});
|
||||
return $.sync("cooldown." + board, QR.cooldown.sync);
|
||||
return $.sync(key, QR.cooldown.sync);
|
||||
},
|
||||
start: function() {
|
||||
if (!Conf['Cooldown']) {
|
||||
@ -5368,12 +5317,12 @@
|
||||
return QR.cooldown.start();
|
||||
},
|
||||
set: function(data) {
|
||||
var cooldown, delay, hasFile, isReply, isSage, post, req, start, type, upSpd;
|
||||
var cooldown, delay, hasFile, isReply, post, req, start, threadID, upSpd;
|
||||
|
||||
if (!Conf['Cooldown']) {
|
||||
return;
|
||||
}
|
||||
req = data.req, post = data.post, isReply = data.isReply, delay = data.delay;
|
||||
req = data.req, post = data.post, isReply = data.isReply, threadID = data.threadID, delay = data.delay;
|
||||
start = req ? req.uploadEndTime : Date.now();
|
||||
if (delay) {
|
||||
cooldown = {
|
||||
@ -5381,18 +5330,15 @@
|
||||
};
|
||||
} else {
|
||||
if (post.file) {
|
||||
upSpd = post.file.size / ((req.uploadEndTime - req.uploadStartTime) / $.SECOND);
|
||||
upSpd = post.file.size / ((start - req.uploadStartTime) / $.SECOND);
|
||||
QR.cooldown.upSpdAccuracy = ((upSpd > QR.cooldown.upSpd * .9) + QR.cooldown.upSpdAccuracy) / 2;
|
||||
QR.cooldown.upSpd = upSpd;
|
||||
}
|
||||
isSage = /sage/i.test(post.email);
|
||||
hasFile = !!post.file;
|
||||
type = !isReply ? 'thread' : isSage ? 'sage' : hasFile ? 'file' : 'post';
|
||||
cooldown = {
|
||||
isReply: isReply,
|
||||
isSage: isSage,
|
||||
hasFile: hasFile,
|
||||
timeout: start + QR.cooldown.types[type] * $.SECOND
|
||||
threadID: threadID
|
||||
};
|
||||
}
|
||||
QR.cooldown.cooldowns[start] = cooldown;
|
||||
@ -5408,7 +5354,7 @@
|
||||
}
|
||||
},
|
||||
count: function() {
|
||||
var cooldown, cooldowns, elapsed, hasFile, isReply, isSage, now, post, seconds, start, type, types, upSpd, upSpdAccuracy, update, _ref;
|
||||
var cooldown, cooldowns, elapsed, hasFile, isReply, maxTimer, now, post, seconds, start, type, types, upSpd, upSpdAccuracy, update, _ref;
|
||||
|
||||
if (!Object.keys(QR.cooldown.cooldowns).length) {
|
||||
$["delete"]("" + g.BOARD + ".cooldown");
|
||||
@ -5417,11 +5363,11 @@
|
||||
QR.status();
|
||||
return;
|
||||
}
|
||||
setTimeout(QR.cooldown.count, $.SECOND);
|
||||
clearTimeout(QR.cooldown.timeout);
|
||||
QR.cooldown.timeout = setTimeout(QR.cooldown.count, $.SECOND);
|
||||
now = Date.now();
|
||||
post = QR.posts[0];
|
||||
isReply = post.thread !== 'new';
|
||||
isSage = /sage/i.test(post.email);
|
||||
hasFile = !!post.file;
|
||||
seconds = null;
|
||||
_ref = QR.cooldown, types = _ref.types, cooldowns = _ref.cooldowns, upSpd = _ref.upSpd, upSpdAccuracy = _ref.upSpdAccuracy;
|
||||
@ -5436,20 +5382,29 @@
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (isReply === cooldown.isReply) {
|
||||
type = !isReply ? 'thread' : isSage && cooldown.isSage ? 'sage' : hasFile && cooldown.hasFile ? 'file' : 'post';
|
||||
elapsed = Math.floor((now - start) / $.SECOND);
|
||||
if (elapsed >= 0) {
|
||||
seconds = Math.max(seconds, types[type] - elapsed);
|
||||
if (Conf['Cooldown Prediction'] && hasFile && upSpd) {
|
||||
seconds -= Math.floor(post.file.size / upSpd * upSpdAccuracy);
|
||||
seconds = Math.max(seconds, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!((start <= now && now <= cooldown.timeout))) {
|
||||
if ('timeout' in cooldown) {
|
||||
QR.cooldown.unset(start);
|
||||
continue;
|
||||
}
|
||||
if (isReply === cooldown.isReply) {
|
||||
elapsed = Math.floor((now - start) / $.SECOND);
|
||||
if (elapsed < 0) {
|
||||
continue;
|
||||
}
|
||||
type = !isReply ? 'thread' : hasFile ? 'image' : 'reply';
|
||||
maxTimer = Math.max(types[type] || 0, types[type + '_intra'] || 0);
|
||||
if (!((start <= now && now <= start + maxTimer * $.SECOND))) {
|
||||
QR.cooldown.unset(start);
|
||||
}
|
||||
if (isReply && +post.thread === cooldown.threadID) {
|
||||
type += '_intra';
|
||||
}
|
||||
seconds = Math.max(seconds, types[type] - elapsed);
|
||||
}
|
||||
}
|
||||
if (seconds && Conf['Cooldown Prediction'] && hasFile && upSpd) {
|
||||
seconds -= Math.floor(post.file.size / upSpd * upSpdAccuracy);
|
||||
seconds = Math.max(seconds, 0);
|
||||
}
|
||||
update = seconds !== null || !!QR.cooldown.seconds;
|
||||
QR.cooldown.seconds = seconds;
|
||||
@ -6254,7 +6209,7 @@
|
||||
thread = g.BOARD.threads[threadID];
|
||||
if (threadID === 'new') {
|
||||
threadID = null;
|
||||
if (['vg', 'q'].contains(g.BOARD.ID) && !post.sub) {
|
||||
if (g.BOARD.ID === 'vg' && !post.sub) {
|
||||
err = 'New threads require a subject.';
|
||||
} else if (!(post.file || (textOnly = !!$('input[name=textonly]', $.id('postForm'))))) {
|
||||
err = 'No file selected.';
|
||||
@ -6433,7 +6388,8 @@
|
||||
QR.cooldown.set({
|
||||
req: req,
|
||||
post: post,
|
||||
isReply: isReply
|
||||
isReply: isReply,
|
||||
threadID: threadID
|
||||
});
|
||||
URL = threadID === postID ? "/" + g.BOARD + "/res/" + threadID : g.VIEW === 'index' && !QR.cooldown.auto && Conf['Open Post in New Tab'] ? "/" + g.BOARD + "/res/" + threadID + "#p" + postID : void 0;
|
||||
if (URL) {
|
||||
@ -7447,7 +7403,7 @@
|
||||
open: function(post) {
|
||||
var node;
|
||||
|
||||
if (post.isDead || post.board.ID === 'q') {
|
||||
if (post.isDead) {
|
||||
return false;
|
||||
}
|
||||
DeleteLink.post = post;
|
||||
@ -9688,12 +9644,6 @@
|
||||
}
|
||||
quote.href = "/" + post.board + "/res/" + href;
|
||||
}
|
||||
Build.capcodeReplies({
|
||||
boardID: post.board.ID,
|
||||
threadID: post.thread.ID,
|
||||
bq: clone,
|
||||
capcodeReplies: postObj.capcode_replies
|
||||
});
|
||||
post.nodes.shortComment = comment;
|
||||
$.replace(comment, clone);
|
||||
post.nodes.comment = post.nodes.longComment = clone;
|
||||
@ -9779,7 +9729,6 @@
|
||||
switch (g.BOARD.ID) {
|
||||
case 'b':
|
||||
case 'vg':
|
||||
case 'q':
|
||||
return 3;
|
||||
case 't':
|
||||
return 1;
|
||||
|
||||
@ -898,7 +898,7 @@ QR =
|
||||
form: 'form'
|
||||
dumpButton: '#dump-button'
|
||||
name: '[data-name=name]'
|
||||
email: '[data-'q'=email]'
|
||||
email: '[data-name=email]'
|
||||
sub: '[data-name=sub]'
|
||||
com: '[data-name=com]'
|
||||
dumpList: '#dump-list'
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user