-
-
Save modeverv/168310 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
Sites = { | |
'youtube' :"http://www.youtube.com/results?search_query=${word}", | |
'veoh' :"http://www.veoh.com/search/videos/q/${word}", | |
'niconico' :"http://www.nicovideo.jp/search/${word}", | |
}; | |
var noun_type_query ={ | |
_name: "query", | |
suggest: function( text, html ) { | |
var suggestions = []; | |
for ( var keyword in Sites ) { | |
suggestions.push(CmdUtils.makeSugg( html + " from " + keyword ) ); | |
} | |
return suggestions; | |
} | |
}; | |
function Parseniconico(p,doc,count){ | |
doc.find(".thumb_frm").each(function(){ | |
$(this).find(".TXT10,.vinfo_last_res").empty(); | |
$(this).find('a').each(function(){ | |
$(this).attr({ | |
href:"http://nicovideo.jp/" + $(this).attr("href")}); | |
}); | |
p.push($(this).html()); | |
count++; | |
}); | |
return [p,count]; | |
} | |
function Parseyoutube(p,doc,count){ | |
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,.hid quicklist-inlist").empty(); | |
t.find(".video-cell,playlist-cell,").each(function(){$(this).attr({style:"width:95%;"});}); | |
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(){ | |
count++; | |
p.push($(this).html());}); | |
}); | |
return [p,count]; | |
} | |
function Parseveoh(p,doc,count){ | |
doc.find("li").find(".thumbWrapper").each(function(){ | |
$(this).find('a[href]').each(function(){ | |
$(this).attr({ href:"http://www.veoh.com" + $(this).attr("href")});}); | |
$(this).find(".thumbLink,.thumbCat,.sp_info").empty(); | |
count++; | |
p.push($(this).html()); | |
}); | |
return [p,count]; | |
} | |
CmdUtils.CreateCommand({ | |
name: "vsearch", | |
icon: "http://nicovideo.jp/favicon.ico", | |
author: {name: "modeverv", email: "modeverv@gmail.com"}, | |
license: "GPL", | |
description: "video search", | |
help: "usage: \"vsearch 'word'\"<br/>" + | |
"then appear result suggestions. \n", | |
arguments: [ | |
{role: 'object', nountype: noun_type_query, label: 'querystrings'} | |
], | |
preview: function (pblock,args) { | |
var _args = args.object.text; | |
var _idx = _args.lastIndexOf(" from "); | |
var targ = _args.substr(_idx).replace(" from ",""); | |
var qstr = _args.substr(0,_idx); | |
var url = CmdUtils.renderTemplate(Sites[targ], {word: encodeURI(qstr)}); | |
var p =[]; | |
var count = 0; | |
pblock.innerHTML = "<h1>Now Searching from " + targ + " ...." | |
+ "</h1>" + "<h1>querystrings:" + qstr + "</h1>"; | |
var genPreview = function (data){ | |
[p,count] = eval("Parse" + targ + "(p,jQuery(data),count)"); | |
jQuery(pblock).empty().append("<pre>check:" + count) | |
.append(p.join('<hr/>')) | |
.append("<hr><h1><a href='" + this.url + "'>more....</a></h1>"); | |
}; | |
CmdUtils.previewGet(pblock, url, null,genPreview, "html"); | |
}, | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment