Skip to content

Instantly share code, notes, and snippets.

@qgustavor
Created May 30, 2023 20:12
Show Gist options
  • Save qgustavor/de531afe515d1438fcc8ce0cb05a0bd3 to your computer and use it in GitHub Desktop.
Save qgustavor/de531afe515d1438fcc8ce0cb05a0bd3 to your computer and use it in GitHub Desktop.
// ==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'
})
})()
@qgustavor
Copy link
Author

You should know that it may show false positives on popular non-creative comments (e.g. "Holy hell!").

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment