-
Notifications
You must be signed in to change notification settings - Fork 0
/
Auto-check Bump Posts in unread of RipperStore Forum.js
83 lines (73 loc) · 2.65 KB
/
Auto-check Bump Posts in unread 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
82
83
// ==UserScript==
// @name Auto-check Bump Posts in the unread tab of the RipperStore Forum
// @namespace http://tampermonkey.net/
// @version 1.3
// @description Automatically checks topics with Bump replies on RipperStore Forum
// @author Louis_45
// @match https://forum.ripper.store/unread
// @grant none
// @updateURL https://raw.githubusercontent.com/Luois45/RipperStoreScripts/main/Auto-check%20Bump%20Posts%20in%20unread%20of%20RipperStore%20Forum.js
// @downloadURL https://raw.githubusercontent.com/Luois45/RipperStoreScripts/main/Auto-check%20Bump%20Posts%20in%20unread%20of%20RipperStore%20Forum.js
// ==/UserScript==
(function () {
"use strict";
function checkBumpPosts() {
const 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
];
document
.querySelectorAll('li[component="category/topic"]')
.forEach((topic) => {
let replyElement = topic.querySelector(
'div.post-content p[dir="auto"]'
);
if (replyElement) {
let replyText = replyElement.textContent
.replace(/[!+* ~.^?<>']/g, "")
.trim()
.toLowerCase();
for (let pattern of bumpPatterns) {
if (pattern.test(replyText)) {
// Adjust the checkbox icon to appear "checked"
let checkboxIcon = topic.querySelector(
'i[component="topic/select"]'
);
if (checkboxIcon) {
checkboxIcon.classList.remove("fa-square-o");
checkboxIcon.classList.add("fa-check-square-o");
}
// Add 'selected' class to the li element
topic.classList.add("selected");
break;
}
}
}
});
}
// 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") {
checkBumpPosts();
}
}
};
// 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 () {
checkBumpPosts();
startObserver();
});
})();