Xkcd Forums Edit Highlighter

Highlights posts edited after date

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         Xkcd Forums Edit Highlighter
// @version      0.1
// @description  Highlights posts edited after date
// @author       faubi
// @match        http://forums.xkcd.com/viewtopic.php*
// @match        http://fora.xkcd.com/viewtopic.php*
// @match        http://forums3.xkcd.com/viewtopic.php*
// @match        http://echochamber.me/viewtopic.php*
// @namespace    FaubiScripts
// @grant        none
// ==/UserScript==

div = document.createElement('div');
div.style['margin-left'] = '30px';
div.style['margin-top'] = '3px';
div.style.float = 'left';

label = document.createElement('span');
label.textContent = 'Highlight new edits: ';
div.appendChild(label);

date = document.createElement('input');
date.type = 'date';
date.valueAsDate = Date.now();
div.appendChild(date);

button = document.createElement('input');
button.type = 'button';
button.value = 'Highlight';
button.addEventListener('click', function() {
    if (!date.valueAsDate) {
        return;
    }
    console.log('j');
    notices = document.getElementsByClassName('notice');
    for(var i=0;i<notices.length;i++) {
        var notice = notices[i];
        var post = notice.parentNode.parentNode.parentNode;
        if (new Date(/on (.*) [A-Z]{3},/.exec(notice.textContent)[1]) > date.valueAsDate) {
            post.style['background-color']='#2E7';
        } else {
            post.style['background-color']='';
        }
    }
});
button.classList.add('button2');
button.style['font-size'] = '1em';
div.appendChild(button);



search = document.getElementsByClassName('search-box')[0];
search.parentNode.insertBefore(div, search.nextSibling);