Skip to content

Instantly share code, notes, and snippets.

@aoikishu
Created April 5, 2009 07:36
Show Gist options
  • Select an option

  • Save aoikishu/90397 to your computer and use it in GitHub Desktop.

Select an option

Save aoikishu/90397 to your computer and use it in GitHub Desktop.
// Commands I'm testing will go here
// Testing anime search for genres
// genres works but you can't do more than one modifier (score, type, genre, etc. ) at one time. I'll try to work it out.
CmdUtils.CreateCommand({
name: "anime-search2",
takes: {"name": noun_arb_text},
modifiers: {"type": noun_arb_text, "score": noun_arb_text, "genre": noun_arb_text},
preview: function( pblock, name, mods ) {
var msg = 'Searching for: "${nameText}" Type: ${typeText} Score: ${scoreText} Genre: ${genreText}. Please type in lowercase';
var subs = {nameText: name.text, typeText: mods["type"].text, scoreText: mods["score"].text, genreText: mods["genre"].text };
var details = 'Please type in lowercase'
pblock.innerHTML = CmdUtils.renderTemplate( msg, subs, details );
},
/*
*/
execute: function( name, mods ) {
var name = name.text;
if (mods["type"].text == "tv") {
var type = "1";
};
if (mods["type"].text == "ova") {
var type = "2";
};
if (mods["type"].text == "movie") {
var type = "3";
};
if (mods["type"].text == "special") {
var type = "4";
};
if (mods["type"].text == "ona") {
var type = "5";
};
var score = mods["score"].text;
if (mods["genre"].text == "action") {
var genre = "1";
};
if (mods["genre"].text == "adventure") {
var genre = "2";
};
if (mods["genre"].text == "cars") {
var genre = "3";
};
if (mods["genre"].text == "comedy") {
var genre = "4";
};
if (mods["genre"].text == "dementia") {
var genre = "5";
};
var url = "http://myanimelist.net/anime.php?q=" + name + "&type=" + type + "&score=" + score + "&genre[]=" + genre;
Utils.openUrlInBrowser( url );
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment