To fix individual post hiding in Options -> User JS:
[code]
(() => {
const pcid2tid = (board, pcid) => {
const n = document.querySelector ('[data-board="' + board + '"].thread > div#' + pcid)
return n == null ? null : n.parentNode.getAttribute ('id').replace ('thread_', '')
}
const merge = (have, posts) => {
let changed = false
for (p of posts) {
if (!have.some (e => e.post === p.post)) {
have.push (p)
changed = true
}
}
return changed
}
const fixids = () => {
let lspf = JSON.parse (localStorage.postFilter)
let changed = false
for (const [board, threads] of Object.entries (lspf.postFilter)) {
for (const [id, posts] of Object.entries (threads)) {
if (!id.startsWith ('pc')) { continue; }
const tid = pcid2tid (board, id)
if (tid == null) { continue; }
if (tid in threads) {
const have = threads [tid]
if (merge (have, posts)) { changed = true; }
} else {
threads [tid] = posts
changed = true
}
delete threads [id]
}
}
if (changed) {
lspf = JSON.stringify (lspf)
localStorage.postFilter = lspf
$(document).trigger('filter_page')
}
}
fixids ()
$(document).on('filter_page', fixids)
// post-filter.js
const removepost = function (boardId, threadId, postId) {
const list = JSON.parse (localStorage.postFilter)
const filter = list.postFilter
// thread already pruned
if (typeof filter[boardId]
== 'undefined' || typeof filter[boardId][threadId]
== 'undefined') return;
for (var i=0; i<filter[boardId][threadId].length; i++) {
if (filter[boardId][threadId][i].post == postId) {
filter[boardId][threadId].splice(i, 1);
break;
}
}
if ($.isEmptyObject(filter[boardId][threadId])) {
delete filter[boardId][threadId];
delete list.nextPurge[boardId][threadId];
if ($.isEmptyObject(filter[boardId])) {
delete filter[boardId];
delete list.nextPurge[boardId];
}
}
localStorage.postFilter = JSON.stringify (list)
}
Menu.onclick(function (e, $buffer) {
var ele = e.target.parentElement.parentElement;
var $ele = $(ele);
var threadId = $ele.parents('.thread').attr('id').replace('thread_', '');
var boardId = $ele.parent().data('board');
var postId = $ele.find('.post_no').not('[id]').text();
if ($ele.data('hidden')) {
$buffer.find('#filter-menu-unhide').click(function () {
removepost(boardId, threadId, postId)
$(document).trigger('filter_page')
})
}
})
})()
[/code]
The price is that the page is filtered twice, once with the wrong pcN IDs from post-filter.js, then with the correct thread IDs. The backend fix
>>>/leftypol_archive/1822 doesn't have this double filtering.
Options -> User JS quick reply spoiler fix
>>>/leftypol_archive/1801Options -> User JS catalog links in div.boardlist
>>>/leftypol_archive/1803Options -> User JS thread stats and Unique IPs
>>6744