Greasy Fork

来自缓存

Greasy Fork is available in English.

Xkcd Forums Edit Highlighter

Highlights posts edited after date

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

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