Skip to content

Instantly share code, notes, and snippets.

@kei-s
Created April 14, 2010 19:03
Show Gist options
  • Save kei-s/366189 to your computer and use it in GitHub Desktop.
Save kei-s/366189 to your computer and use it in GitHub Desktop.
Nicovideo username in mylist
// ==UserScript==
// @name Nicovideo username in mylist
// @namespace http://libelabo.jp/
// @include http://www.nicovideo.jp/openlist/*
// @require http://gist.github.com/3238.txt
// ==/UserScript==
(function(){
function addUserName(node) {
var lists = $X('.//strong',node);
lists.forEach(function(list){
var link = $X('.//a',list)[0];
GM_xmlhttpRequest({
method: "GET",
url: link.href,
onload: function(response){
var name = response.responseText.match(/nickname: "([^"]*)"/)[1];
var id = response.responseText.match(/user_id: (\w+),/)[1];
var a = document.createElement('a');
a.textContent = name;
a.setAttribute('href','http://www.nicovideo.jp/user/'+id);
a.setAttribute('style','padding-left: 5px;');
list.appendChild(a);
}
});
});
}
document.body.addEventListener('AutoPagerize_DOMNodeInserted',function(evt){
var node = evt.target;
var requestURL = evt.newValue;
var parentNode = evt.relatedNode;
addUserName(node);
},false);
addUserName($X('//table[@class="font12"]')[0]);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment