NoPaste

tampermonkey: dfde-necroviz

von TRex
SNIPPET_DESC:
hebt alte threads hervor
SNIPPET_CREATION_TIME:
01.05.2018 02:14:15
SNIPPET_PRUNE_TIME:
Unendlich

SNIPPET_TEXT:
  1. // ==UserScript==
  2. // @name         dfde-necroviz
  3. // @namespace    http://tampermonkey.net/
  4. // @version      0.1
  5. // @description  try to take over the world!
  6. // @author       You
  7. // @match        https://debianforum.de/forum/search.php*
  8. // @grant        none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12.     'use strict';
  13.  
  14.     function parseDate(datestring) {
  15.         const components = datestring.split(', ');
  16.         const dmY = components[0].split('.');
  17.         const hm = components[1];
  18.         return new Date(dmY.reverse().join('-') + "T" + hm + ":00.000Z");
  19.     }
  20.  
  21.     function daysBetween(d0, d1) {
  22.         return Math.floor((d1 - d0) / 1000 / 60 / 60 / 24);
  23.     }
  24.  
  25.     const pattern = /(?:([0-9]{2})\.([0-9]{2})\.([0-9]{4,4}), ([0-9]{2}):([0-9]{2}))/g;
  26.     let threads = document.querySelectorAll('dl.row-item');
  27.     threads.forEach(function (row) {
  28.         if (! row.innerText) { console.log(row); return; }
  29.         let dates = row.innerText.match(pattern);
  30.         if (! dates) { return; }
  31.         let days = daysBetween(parseDate(dates[0]), parseDate(dates[1]));
  32.         if (days > 100) {
  33.             row.style.color = 'red';
  34.         }
  35.     });
  36. })();

Quellcode

Hier kannst du den Code kopieren und ihn in deinen bevorzugten Editor einfügen. PASTEBIN_DOWNLOAD_SNIPPET_EXPLAIN