Skip to content

Instantly share code, notes, and snippets.

@azu
Created October 22, 2008 05:54
Show Gist options
  • Save azu/18550 to your computer and use it in GitHub Desktop.
Save azu/18550 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Nico Nickname
// @namespace http://web.zgo.jp/
// @description うp主のニックネームを調べるスクリプト http://script41self.seesaa.net/さんで公開されているものを勝手に改造したものです。
// @include http://www.nicovideo.jp/watch/*
// @updated 2008-02-18 19:45:00
// ==/UserScript==
(function(){
var video_id = location.href.match(/watch\/[sn]m(\d+)/)[1];
var h1 = document.getElementsByTagName('h1')[0];
if(!h1) return;
// smilevideo link
var svlink = 'http://www.smilevideo.jp/allegation/allegation/'+ video_id+'/';
//alert(svlink);
GM_xmlhttpRequest({
method: 'GET',
url: svlink,
headers: { "User-Agent": "Mozilla/5.0" },
onload: function(res){
var nickname = 'no name'; // can't get nickname
if(/<strong(?:\s*[^>]*|)>(.*?)<\/strong>.*?が投稿/.test(res.responseText)) {
nickname = decodeURIComponent(RegExp.$1);
}
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>';
h1.insertBefore(span, h1.nextChild); // insert position
},
//nextをfirstにするとタイトル前に表示
onerror: function(res){ GM_log(res.status + ':' + res.statusText); }
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment