Anonymous ID: 5e0d7f May 12, 2025, 8:34 p.m. No.23027322   ๐Ÿ—„๏ธ.is ๐Ÿ”—kun   >>7324 >>7330 >>7331 >>7347

>>23027299

//UserScript

// @name Block Mr. Pig and Meme Format on 8kun

// @namespace http://tampermonkey.net/

// @version 1.0

// @description Blocks posts by Mr. Pig and memes with white cat format on 8kun

// @author Grok

// @match ://8kun.top/

// @grant none

///UserScript

 

(function() {

'use strict';

 

// Function to block posts by Mr. Pig and detect meme format

function blockMrPigAndMemes() {

// Select all posts on the page

const posts = document.querySelectorAll('div.post');

 

posts.forEach(post ={

// Check for Mr. Pig's name in the post

const nameElement = post.querySelector('span.name');

const hasMrPig = nameElement && nameElement.textContent.trim() === 'Mr. Pig';

 

// Check for meme format: look for images and specific text patterns

const image = post.querySelector('img.post-image');

const postText = post.querySelector('div.post-message');

const hasMemeText = postText && /WELL ANGRY INCH|APPARENTLY MAKE|AMERICA WINNING/i.test(postText.textContent);

 

// If the post is by Mr. Pig or matches the meme format, hide it

if (hasMrPig || (image && hasMemeText)) {

post.style.display = 'none';

console.log('Blocked a post by Mr. Pig or matching meme format');

}

});

}

 

// Run the function on page load

blockMrPigAndMemes();

 

// Observe for dynamically loaded posts (e.g., when scrolling or new replies)

const observer = new MutationObserver((mutations) ={

mutations.forEach(() ={

blockMrPigAndMemes();

});

});

 

// Start observing the document for changes

observer.observe(document.body, { childList: true, subtree: true });

})();

Anonymous ID: 5e0d7f May 12, 2025, 8:53 p.m. No.23027373   ๐Ÿ—„๏ธ.is ๐Ÿ”—kun   >>7375

Will the Script Work in "User JS"?

Yes, the script I provided can work in the "User JS" section, but it needs a slight modification to remove the userscript metadata (e.g., // @match) since this isnโ€™t running through a userscript manager like Tampermonkey. The "User JS" section on 8kun will automatically run the script on the site, so the core logic will work.

Hereโ€™s the modified script for 8kunโ€™s "User JS" section:

javascript

Anonymous ID: 5e0d7f May 12, 2025, 8:53 p.m. No.23027375   ๐Ÿ—„๏ธ.is ๐Ÿ”—kun

>>23027373

(function() {

'use strict';

 

// Function to block posts by Mr. Pig and detect meme format

function blockMrPigAndMemes() {

// Select all posts on the page

const posts = document.querySelectorAll('div.post');

 

posts.forEach(post ={

// Check for Mr. Pig's name in the post

const nameElement = post.querySelector('span.name');

const hasMrPig = nameElement && nameElement.textContent.trim() === 'Mr. Pig';

 

// Check for meme format: look for images and specific text patterns

const image = post.querySelector('img.post-image');

const postText = post.querySelector('div.post-message');

const hasMemeText = postText && /WELL ANGRY INCH|APPARENTLY MAKE|AMERICA WINNING/i.test(postText.textContent);

 

// If the post is by Mr. Pig or matches the meme format, hide it

if (hasMrPig || (image && hasMemeText)) {

post.style.display = 'none';

console.log('Blocked a post by Mr. Pig or matching meme format');

}

});

}

 

// Run the function on page load

blockMrPigAndMemes();

 

// Observe for dynamically loaded posts (e.g., when scrolling or new replies)

const observer = new MutationObserver((mutations) ={

mutations.forEach(() ={

blockMrPigAndMemes();

});

});

 

// Start observing the document for changes

observer.observe(document.body, { childList: true, subtree: true });

})();