-
Notifications
You must be signed in to change notification settings - Fork 0
/
userscript.js
38 lines (31 loc) · 1.2 KB
/
userscript.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
// ==UserScript==
// @name Reddit Submission Limiter report linkifier
// @namespace Violentmonkey Scripts
// @match https://reddit.com/r/*
// @grant none
// @version 1.0
// @author Jack Webb
// @description 04/02/2024, 13:39:46
// ==/UserScript==
(function() {
'use strict';
const BOT_USERNAME = 'PUT YOUR BOT USERNAME HERE';
function linkifyReportReason(text) {
const idRegex = /'([a-zA-Z0-9]{7})'/g;
return text.replace(idRegex, (match, id) => `<a href="https://reddit.com/${id}">${id}</a>`);
}
function processReportReasons() {
const reportReasons = document.querySelectorAll('.report-reason-text');
reportReasons.forEach(reason => {
const lines = reason.textContent.split('\n');
lines.forEach(line => {
if (line.trim().startsWith(BOT_USERNAME)) {
const updatedLine = linkifyReportReason(line);
reason.innerHTML = reason.innerHTML.replace(line, updatedLine);
}
});
});
}
window.addEventListener('load', processReportReasons);
setInterval(processReportReasons, 1000);
})();