Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name kys for 4chanX
- // @namespace kys-4chanX
- // @match https://boards.4channel.org/*/thread/*
- // @match https://boards.4chan.org/*/thread/*
- // @grant none
- // @run-at document-start
- // @version 1.0
- // @author -
- // @description 6/25/2022, 5:41:23 PM
- // ==/UserScript==
- (function () {
- const regex = [
- /\bk+y+s+\b/gi,
- ];
- document.addEventListener("4chanXInitFinished", function (e) {
- const thread = document.querySelector(".thread"),
- posts = thread.querySelectorAll(".postContainer");
- kys(posts); // init
- document.addEventListener("ThreadUpdate", function (e) {
- if (!e.detail[404]) {
- if (e.detail.newPosts.length > 0) {
- kys(e.detail.newPosts);
- }
- }
- });
- function kys(list) {
- let post, id;
- for (const item of list) {
- if (Array.isArray(list)) {
- // new posts
- id = item;
- post = thread.querySelector(`.postContainer[id$="${id.split(".").pop()}"]`);
- } else {
- // thread init
- post = item;
- id = post.getAttribute("data-full-i-d");
- }
- const comment = post.querySelector(".post.reply > blockquote");
- for (const rule of regex) {
- if (comment && rule.test(comment.textContent)) {
- // console.debug(id, comment);
- comment.innerHTML = comment.innerHTML.replace(regex[0], "kiss your sister");
- break;
- }
- }
- }
- }
- });
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement