there should be a copy button under this

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);
Edit

Pub: 11 Sep 2025 09:50 UTC

Edit: 11 Sep 2025 09:50 UTC

Views: 19