From: Thorsten Date: Wed, 16 Dec 2020 19:25:05 +0000 (+0100) Subject: init X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=HEAD;p=dfde%2Fnecroviz-userscript.git init --- 6c224f080cdf2031a237fc161277efd9460b9100 diff --git a/dfde-necroviz.user.js b/dfde-necroviz.user.js new file mode 100755 index 0000000..57d7141 --- /dev/null +++ b/dfde-necroviz.user.js @@ -0,0 +1,36 @@ +// ==UserScript== +// @name dfde-necroviz +// @namespace http://tampermonkey.net/ +// @version 0.1 +// @description try to take over the world! +// @author You +// @match https://debianforum.de/forum/search.php* +// @grant none +// ==/UserScript== + +(function() { + 'use strict'; + + function parseDate(datestring) { + const components = datestring.split(', '); + const dmY = components[0].split('.'); + const hm = components[1]; + return new Date(dmY.reverse().join('-') + "T" + hm + ":00.000Z"); + } + + function daysBetween(d0, d1) { + return Math.floor((d1 - d0) / 1000 / 60 / 60 / 24); + } + + const pattern = /(?:([0-9]{2})\.([0-9]{2})\.([0-9]{4,4}), ([0-9]{2}):([0-9]{2}))/g; + let threads = document.querySelectorAll('dl.row-item'); + threads.forEach(function (row) { + if (! row.innerText) { console.log(row); return; } + let dates = row.innerText.match(pattern); + if (! dates) { return; } + let days = daysBetween(parseDate(dates[0]), parseDate(dates[1])); + if (days > 100) { + row.style.color = 'red'; + } + }); +})(); \ No newline at end of file