-
Notifications
You must be signed in to change notification settings - Fork 95
Open
Description
Please show
'(posted 1y 2mo 3h 0m after account creation)' in forum first post moderation, like this:
Userscript workaround:
// ==UserScript==
// @name Freesound Forum Moderation Post Delay
// @namespace http://tampermonkey.net/
// @version 2026-03-04
// @match https://freesound.org/forum/moderate/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
function parseTimeAgo(text) {
const map = {
y: 525600,
mo: 43200,
w: 10080,
d: 1440,
h: 60,
m: 1
};
let minutes = 0;
Object.entries(map).forEach(([unit, value]) => {
const regex = new RegExp('(\\d+)\\s*' + unit);
const match = text.match(regex);
if (match) minutes += parseInt(match[1]) * value;
});
return minutes;
}
function formatDuration(minutes) {
const units = [
['y', 525600],
['mo', 43200],
['d', 1440],
['h', 60],
['m', 1]
];
let result = [];
for (const [label, value] of units) {
const amount = Math.floor(minutes / value);
if (amount > 0) {
result.push(amount + label);
minutes -= amount * value;
}
}
return result.join(' ');
}
function processPost(post) {
const meta = post.querySelector('.bw-post__meta');
if (!meta) return;
// prevent duplicates
if (meta.querySelector('.tm-post-delay')) return;
const timeSpan = meta.querySelector('span');
if (!timeSpan) return;
const postMinutes = parseTimeAgo(timeSpan.textContent);
const accountNode = [...post.querySelectorAll('.text-grey.no-margins')]
.find(el => el.textContent.includes('Account age'));
if (!accountNode) return;
const accountMinutes = parseTimeAgo(accountNode.textContent);
const diff = accountMinutes - postMinutes;
if (diff < 0) return;
const label = document.createElement('span');
label.className = "tm-post-delay";
label.textContent = ` (posted ${formatDuration(diff)} after account creation)`;
label.style.padding = "1px 4px";
if (diff < 60) {
label.style.background = "yellow";
}
meta.appendChild(label);
}
document.querySelectorAll('.bw-post').forEach(processPost);
})();
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
