Nico Nickname

うp主のニックネームを調べるスクリプト

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           Nico Nickname
// @namespace      http://web.zgo.jp/
// @description    うp主のニックネームを調べるスクリプト
// @include        http://www.nicovideo.jp/watch/*
// @version 0.0.1.20140518104259
// ==/UserScript==

(function() {

    // var video_id = location.href.match(/watch\/[sn]m(\d+)/)[1];
    var videoTitle = document.getElementsByClassName('video_title')[0];
    var owner = document.getElementsByClassName("img_sq48")[0];
    if (!videoTitle && !owner) return;
    var nickname = owner.alt;//Alt要素

    // var svlink = 'http://www.smilevideo.jp/allegation/allegation/' + video_id + '/';
    //    GM_xmlhttpRequest({
    //        method: 'GET',
    //        url: svlink,
    //        headers: { "User-Agent": "Mozilla/5.0" },
    //        onload: function(res) {
    //            nickname = 'no name'; // can't get nickname
    //            if (/<strong(?:\s*[^>]*|)>(.*?)<\/strong>.*?が投稿/.test(res.responseText)) {
    //                nickname = decodeURIComponent(RegExp.$1);
    //            }
    //            window.gm_nicoNickname = nickname;
    //            var span = document.createElement('span');
    //            //p.setAttribute('class', 'TXT12');
    //            span.style.cssText = 'font-size:small; margin-top:4px; line-height:1.25;';
    //            //cssのスタイルを変える。
    //            span.innerHTML = ' うp主:<a href="http://www.nicochart.jp/name/' + nickname + '" title ="' + nickname + '">' + nickname + '</a>';
    //            videoTitle.appendChild(span); // insert position
    //        },
    //        //nextをfirstにするとタイトル前に表示
    //        onerror: function(res) {
    //            GM_log(res.status + ':' + res.statusText);
    //        }
    //    });

    window.gm_nicoNickname = nickname;
    var span = document.createElement('span');
    //p.setAttribute('class', 'TXT12');
    span.style.cssText = 'font-size:small; margin-top:4px; line-height:1.25;';
    //cssのスタイルを変える。
    span.innerHTML = ' うp主:<a href="http://www.nicochart.jp/name/' + nickname + '" title ="' + nickname + '">' + nickname + '</a>';
    videoTitle.appendChild(span);
})();