there should be a copy button under this
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | const POST_DELAY_SECONDS = 5; // You can freely change this to whatever delay you want.
const timeoutMillis = POST_DELAY_SECONDS * 1000;
const PRE_DELETION_MAP = new Map();
document.addEventListener("threadsocketmessage", function(event) {
if (event.detail.action !== "delete") return;
for (const id of new Set(event.detail.target)) {
const postCell = document.getElementById(id.toString());
if(!postCell) PRE_DELETION_MAP.set(id, postCell);
}
});
oldThreadRefreshCallback = thread.refreshCallback;
const threadCallbackTimeout = function(postsToAdd, posts, receivedData) {
for (var i = 0; i < postsToAdd.length; i++) {
var [post, postCell] = postsToAdd[i];
if(!PRE_DELETION_MAP.delete(post.postId)) {
const linkSelf = postCell.querySelector(".linkSelf");
const existParse = posting.parseExistingPost(linkSelf);
posting.existingPosts.push(existParse);
if (typeof gallery !== 'undefined') gallery.addPost(post);
thread.divPosts.appendChild(postCell);
if (typeof posting !== "undefined" && posting.yous) {
if (posting.yous.indexOf(+post.postId) === -1) {
thread.unreadPosts++;
}
} else {
thread.unreadPosts++;
}
}
}
if (!thread.fullRefresh && thread.unreadPosts > 0) {
document.title = '(' + thread.unreadPosts + ') ' + thread.originalTitle;
}
var counts = posts.reduce((acc, post) => {
acc.files += post.files.length;
return acc;
}, {
files: 0
})
var postCount = document.getElementById('postCount')
postCount.textContent = posts.length;
document.getElementById('fileCount').textContent = counts.files;
document.getElementById('userCountLabel').textContent = receivedData.uniquePosters;
postCount.parentNode.style.display = "inherit";
};
thread.refreshCallback = function (error, receivedData) {
if ((api.mod && (error !== 'ok')) || (!api.mod && error)) {
return;
}
if (!api.mod) {
receivedData = JSON.parse(receivedData);
}
if (receivedData.threadId !== api.threadId) {
window.location.href = '/' + receivedData.boardUri + '/res/' + receivedData.threadId + '.html';
return;
}
if (thread.fullRefresh) {
thread.lastReplyId = 0;
thread.unreadPosts = 0;
while (thread.divPosts.firstChild) {
thread.divPosts.removeChild(thread.divPosts.firstChild);
}
document.title = thread.originalTitle;
}
thread.wsPort = receivedData.wsPort;
thread.wssPort = receivedData.wssPort;
if (!thread.socket || thread.socket.readyState > 1) { //still closed
thread.stopWs();
thread.startWs();
}
if (typeof tooltips !== "undefined") {
tooltips.cacheData(receivedData);
}
var posts = receivedData.posts;
var foundPosts = false;
var postsToAdd = [];
if (posts && posts.length) {
var lastReceivedPost = posts[posts.length - 1];
if (lastReceivedPost.postId > thread.lastReplyId) {
foundPosts = true;
for (var i = 0; i < posts.length; i++) {
var post = posts[i];
if (post.postId > thread.lastReplyId) {
if (thread.expectedPosts.indexOf(post.postId) >= 0) {
thread.expectedPosts.splice(thread.expectedPosts.indexOf(post.postId), 1);
}
var postCell = posting.addPost(post, api.boardUri, api.threadId, undefined, undefined, true);
postsToAdd.push([post, postCell]);
thread.lastPost = postCell;
thread.lastReplyId = post.postId;
}
}
setTimeout(function () { threadCallbackTimeout(postsToAdd, posts, receivedData); }, timeoutMillis);
}
if (thread.expectedPosts.length && !thread.retryTimer) {
thread.expectedPosts = [];
thread.retryTimer = setTimeout(function () {
delete thread.retryTimer;
if (!thread.refreshingThread) {
thread.refreshPosts();
}
}, 10000);
}
}
if (thread.autoRefresh && !(!JSON.parse(localStorage.noWs || 'false') && (thread.wsPort || thread.wssPort))) {
thread.startTimer(thread.manualRefresh || foundPosts ? 5 : thread.lastRefresh * 2);
}
};
Object.assign(thread.refreshCallback, oldThreadRefreshCallback);
|