]> git.aero2k.de Git - dfde/necroviz-userscript.git/commitdiff
init master
authorThorsten <mail@aero2k.de>
Wed, 16 Dec 2020 19:25:05 +0000 (20:25 +0100)
committerThorsten <mail@aero2k.de>
Wed, 16 Dec 2020 19:25:05 +0000 (20:25 +0100)
dfde-necroviz.user.js [new file with mode: 0755]

diff --git a/dfde-necroviz.user.js b/dfde-necroviz.user.js
new file mode 100755 (executable)
index 0000000..57d7141
--- /dev/null
@@ -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