Created
May 30, 2023 20:12
-
-
Save qgustavor/de531afe515d1438fcc8ce0cb05a0bd3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Detect Reddit Copy Bot Comments | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description Detect copied comments in Old Reddit. | |
// @author qgustavor | |
// @match https://*.reddit.com/* | |
// @icon https://icons.duckduckgo.com/ip2/reddit.com.ico | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
const comments = Array.from(document.querySelectorAll('.comment:not(.deleted) > .entry > .usertext > .usertext-body')).map(e => { | |
const text = e.textContent.trim() || e.innerHTML | |
const timestampEl = e.parentNode.parentNode.querySelector('.live-timestamp') | |
const timestamp = timestampEl && new Date(timestampEl.getAttribute('datetime')).getTime() | |
return [text, timestamp, e] | |
}).filter(e => e[1]).sort((a, b) => a[1] - b[1]) | |
const duplicatedComments = comments.filter((needle, i) => ( | |
comments.some(e => needle[1] > e[1] && e[0] === needle[0]) || | |
(needle[0].length > 20 && comments.some(e => needle[1] > e[1] && e[0].includes(needle[0]))) | |
)) | |
duplicatedComments.forEach(e => { | |
e[2].style.background = 'red' | |
}) | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You should know that it may show false positives on popular non-creative comments (e.g. "Holy hell!").