Something Awful Friends Highlight

Highlights posts of friends on Something Awful.

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name         Something Awful Friends Highlight
// @namespace    http://mathemaniac.org
// @version      1.0.1
// @description  Highlights posts of friends on Something Awful.
// @match        *://forums.somethingawful.com/usercp.php*
// @match        *://forums.somethingawful.com/showthread.php*
// @copyright    2012-2016, Sebastian Paaske Tørholm
// @require      http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js
// @grant        GM_setValue
// @grant        GM_getValue
// ==/UserScript==

var location = "" + document.location;

// Scrape buddy list from user control panel
if (location.match(/usercp\.php/) && $('#buddylist').length) {
    var buddies = [];
    $('#buddylist a[href *= "member.php"]').each(function () {
        buddies.push($(this).attr('title'));
    });

    GM_setValue("buddylist", buddies);
} else {
    var buddies = GM_getValue("buddylist", []);

    $(".post").each( function () {
        console.log("Post: ", this);
        var author = $("dt.author", this);
        if (author && $.inArray(author.first().text(), buddies) >= 0) {
            $("tr td", this).css( {
                "background-color": "lightgreen"
            } );
        }
    } );
}