Xkcd Forums Edit Highlighter

Highlights posts edited after date

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

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

(I already have a user script manager, let me install it!)

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.

(I already have a user style manager, let me install it!)

// ==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);