// ==UserScript==
// @name        em gigazine editorial ad
// @namespace   http://inasphere.net/
// @description Gigazineの「広告」カテゴリ記事を見分けやすくする
// @include     http://gigazine.net/index.php?/news/comments/*
// @author      inamenai
// @license     MIT License
// @version     0.1
// ==/UserScript==

(function() {

    var adFlag = false;

    var result = document.evaluate('//div[@class="posted"]', document, null, 7, null);
    var mainPosted = result.snapshotItem(0);
    var children = Array.slice(mainPosted.childNodes);
    for (var i = 0; i < children.length; i++) {

        if (children[i].tagName && children[i].tagName.toLowerCase() == "a") {
            if (children[i].childNodes[0].nodeValue == "広告") {
                adFlag = true;
                break;
            }
        }
    }

    if (adFlag) {
        var result = document.evaluate('//h2[@class="title"]', document, null, 7, null);
        var h2Title = result.snapshotItem(0);
        h2Title.innerHTML = "<span class=\"h2Ad\">[AD]</span>" + h2Title.childNodes[0].nodeValue + "<span class=\"h2Ad\">[AD]</span>";
        children[i].innerHTML = "<span class=\"adCategory\">広告</span>";

        GM_addStyle(
            "h2.title span.h2Ad {font-size: 30px !important; font-weight: bold !important; color: #ff0000 !important;} " +
            "div.posted span.adCategory {font-weight: bold !important; font-size: 60px !important; color: #ff0000 !important;}"
        );
    }
})();

