-
-
Save modeverv/168306 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CmdUtils.CreateCommand({ | |
name: "nico-youtube-search", | |
icon: "http://nicovideo.jp/favicon.ico", | |
author: {name: "modeverv", email: "modeverv@ジーメイル"}, | |
license: "GPL", | |
description: "nico-youtube-search:\n" + " nico-youtube-search <keyword> \n", | |
help: "niconico youtube search", | |
takes: {"input": noun_arb_text}, | |
preview: function (pblock, input) { | |
var url = this._url(input); | |
var url2 = this._url2(input); | |
if (input.text.length == 0) { | |
pblock.innerHTML = "<pre>" + this.description +"<br/>"+ url + "</pre>"; | |
return; | |
} | |
pblock.innerHTML = ""; | |
var embed_content = function (data) { | |
var p = []; | |
var t = []; | |
var doc = jQuery(data); | |
p.push('<h1>ニコニコ動画検索結果:</h1>'); | |
doc.find(".thumb_frm").each(function(){ | |
$(this).find('a').each(function(){ | |
$(this).attr({ | |
href:"http://nicovideo.jp/" + $(this).attr("href") | |
}); | |
}); | |
p.push($(this).html()) | |
}); | |
doc.find(".pagelink").eq(0).each(function(){ | |
t.push($(this).html()); | |
}); | |
jQuery(pblock) | |
.append(p.join('<hr/>')) | |
.append("<h1>" + t.join('') + "</h1>"); | |
}; | |
var embed_content2 = function (data) { | |
var p = []; | |
var t = []; | |
var doc = jQuery(data); | |
p.push('<h1>youtube検索結果:</h1>'); | |
doc.find(".list-view").each(function(){ | |
var t = $(this); | |
//適当に要素を削る | |
t.find(".yt-uix-hovercard-content,.hid,.video-facets,.video-short-title,.video-translation-links,.video-username,.video-translation-links").empty(); | |
t.find(".video-cell,playlist-cell,").each(function(){$(this).attr({ | |
style:"width:95%;"}); | |
}); | |
t.find(".hid quicklist-inlist").empty(); | |
t.find('a[href]').each(function(){ | |
$(this).attr({ | |
href:"http://www.youtube.com/" + $(this).attr("href") | |
}); | |
}); | |
t.find("div.video-cell,div.playlist-cell,div.channel-cell").each(function(){p.push($(this).html());}); | |
}); | |
t.push(doc.find(".pagingDiv").eq(0).html()); | |
jQuery(pblock) | |
.append(p.join('<hr/>')) | |
.append("<h1>" + t.join('') + "</h1>"); | |
}; | |
CmdUtils.previewGet(pblock, url, null, embed_content, "html"); | |
CmdUtils.previewGet(pblock, url2, null, embed_content2, "html"); | |
}, | |
execute: function (input) { | |
//機能無し | |
}, | |
_url : function (input) { | |
var template = "http://www.nicovideo.jp/search/${word}"; | |
return CmdUtils.renderTemplate(template, {word: encodeURI(input.text)}); | |
}, | |
_url2:function(input){ | |
var template = "http://www.youtube.com/results?search_query=${word}"; | |
return CmdUtils.renderTemplate(template, {word: encodeURI(input.text)}); | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment