>>98998
Make sure you change the UserScript later.
//
UserScript
// @name IDFilterBlur
// @version 1.4
// @grant unsafeWindow
// @include
https://8chan.moe/v/res/*
// @include
https://8chan.se/v/res/*
// @run-at document-idle
// @license AGPL
// @description Blur images in posts by IDs with less than X posts, excluding your own and only works on /bag/
// @namespace
https://greasyfork.org/users/1461466
//
/UserScript
// Check for the thread subject
if (!/^bag\/|\/bag\/|Blue Archive|BIue Archive/.test(document?.querySelector('.postInfo.desktop .subject, .opHead .labelSubject')?.textContent?.trim() ?? '')) return;
//MIN_POSTS to change the threshold ID. So if it's at 3 the filter will only activate on IDs 1 and 2. If it's at 4 only on 3, 2 and 1 etc...
//BLUR_STRENGTH to change the blur
const MIN_POSTS = 3;
const BLUR_STRENGTH = 10;
// Doesn't filter your own posts
function isOwnPost(post) {
return post.querySelector('.youName') !== null;
}
function shouldBlurPost(id) {
const idsRelation = unsafeWindow?.posting?.idsRelation;
if (!idsRelation || !id) return false;
const posts = idsRelation[id];
return posts && posts.length < MIN_POSTS;
}
function blurImages(post) {
const images = post.querySelectorAll('img');
images.forEach(img => {
img.style.filter = `blur(${BLUR_STRENGTH}px)`;
img.style.transition = 'filter 0.3s';
});
}
function unblurImages(post) {
const images = post.querySelectorAll('img');
images.forEach(img => {
img.style.filter = '';
});
[Expand Post]
}
function handlePost(post) {
const idLabel = post.querySelector('.labelId');
if (!idLabel) return;
const id = idLabel.innerText.trim();
if (isOwnPost(post)) {
unblurImages(post);
} else if (shouldBlurPost(id)) {
blurImages(post);
} else {
unblurImages(post);
}
}
// Initial processing
function processAllPosts() {
document.querySelectorAll('.postCell').forEach(post => handlePost(post));
}
// Watch for new posts
const thread = document.getElementById('threadList');
if (thread) {
const observer = new MutationObserver(mutations => {
for (const mutation of mutations) {
for (const node of mutation.addedNodes) {
if (node.nodeType === 1 && node.classList.contains('postCell')) {
handlePost(node);
}
}
}
});
observer.observe(thread, { childList: true, subtree: true });
}
// Run once on page load
processAllPosts();