-
Notifications
You must be signed in to change notification settings - Fork 0
/
Hide Bump Posts in topics of RipperStore Forum.js
81 lines (68 loc) · 2.41 KB
/
Hide Bump Posts in topics of RipperStore Forum.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// ==UserScript==
// @name Hide Bump posts on RipperStore Forum
// @namespace http://tampermonkey.net/
// @version 1.3
// @description Hide containing various bump texts on the RipperStore forum.
// @author Louis_45
// @match https://forum.ripper.store/topic/*
// @updateURL https://raw.githubusercontent.com/Luois45/RipperStoreScripts/main/Hide%20Bump%20Posts%20in%20topics%20of%20RipperStore%20Forum.js
// @downloadURL https://raw.githubusercontent.com/Luois45/RipperStoreScripts/main/Hide%20Bump%20Posts%20in%20topics%20of%20RipperStore%20Forum.js
// @grant none
// ==/UserScript==
(function () {
"use strict";
// Fetch the username from the HTML
var currentUser = document
.getElementById("user-header-name")
.textContent.trim();
function hideBumpPosts() {
// List of bump text patterns
var bumpPatterns = [
/^(holy\s*)?[bn]+u+m+p+[oa]*s*i*n*g*$/, // Matches 'bump', 'buump', 'bumpo', 'bumps', 'holy bump', 'Holy buumping', 'bumping', 'nump', 'numpiiing', etc.
/^1+$/, // Matches '1', '11', '111', etc.
// Add other patterns here as needed
];
$('li[component="post"]').each(function () {
var postContent = $(this)
.find('[component="post/content"]')
.text()
.replace(/[!+* ~.^?<>']/g, "")
.trim()
.toLowerCase();
var posterName = $(this).attr("data-username");
if (posterName === currentUser) {
return true; // Continue to the next iteration
}
var isBump = bumpPatterns.some((pattern) =>
pattern.test(postContent)
);
if (isBump) {
$(this).hide();
}
});
}
// Function to start the observer
function startObserver() {
// Select the node that will be observed for mutations
var targetNode = document.querySelector("body");
// Options for the observer (which mutations to observe)
var config = { childList: true, subtree: true };
// Callback function to execute when mutations are observed
var callback = function (mutationsList, observer) {
for (let mutation of mutationsList) {
if (mutation.type === "childList") {
hideBumpPosts();
}
}
};
// Create an observer instance linked to the callback function
var observer = new MutationObserver(callback);
// Start observing the target node for configured mutations
observer.observe(targetNode, config);
}
// Start the initial function and the observer
$(document).ready(function () {
hideBumpPosts();
startObserver();
});
})();