-
-
Save IntendedConsequence/120366 to your computer and use it in GitHub Desktop.
A Firefox Ubiquity Parser 2 compatible version of MyAnimeList.net anime and character search command
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
// anime and character searches for MyAnimeList.net | |
// An advanced search command for MyAnimeList.net | |
CmdUtils.CreateCommand({ | |
names: [ "mal-search", "anime-search" ], //mal as in MyAnimeList.net 8) | |
author: { name: "aoikishu"}, | |
contributors: [ "Irwin1138" ], | |
description: "Searches anime on MyAnimeList.net", | |
help: "You can specify a type (ova, tv, movie, special or ona) and a score", | |
/// Parser 2 incompatible old format | |
//takes: {"name": noun_arb_text}, | |
//modifiers: {"type": noun_arb_text, "score": noun_arb_text}, | |
// Parser 2 compatible :) | |
arguments: [{role: "object", | |
nountype: noun_arb_text, | |
label: "name"}, | |
{role: "format", | |
nountype: noun_arb_text, | |
label: "type"}, | |
{role: "instrument", | |
nountype: noun_arb_text, | |
label: "score"}], | |
preview: function( pblock, arguments ) { | |
// args contains .with and .in, both of which are input objects. | |
var msg = 'Searching for: "${nameText}" Type: ${typeText} Score: ${scoreText}.'; | |
var subs = {nameText: arguments.object.text, | |
typeText: arguments.format.text, | |
scoreText: arguments.instrument.text}; | |
pblock.innerHTML = CmdUtils.renderTemplate( msg, subs); | |
}, | |
execute: function( arguments ) { | |
var as = arguments.format.text.toLowerCase(); | |
var type = "0"; | |
if (as == "tv") { | |
type = "1"; | |
} | |
else if (as == "ova") { | |
type = "2"; | |
} | |
else if (as == "movie") { | |
type = "3"; | |
} | |
else if (as == "special") { | |
type = "4"; | |
} | |
else if (as == "ona") { | |
type = "5"; | |
} | |
var name = arguments.object.text; | |
var score = arguments.instrument.text; | |
var url = "http://myanimelist.net/anime.php?q=" + name + "&type=" + type + "&score=" + score; | |
Utils.openUrlInBrowser( url ); | |
} | |
}); | |
CmdUtils.CreateCommand({ | |
names: ["character-search"], | |
author: { name: "aoikishu"}, | |
contributors: [ "Irwin1138" ], | |
description: "Searches characters on MyAnimeList.net", | |
help: "Simply type a character name to search in on MAL.net", | |
//takes: {"Site": noun_arb_text}, | |
arguments: [{role: "object", | |
nountype: noun_arb_text, | |
label: "name"}], | |
preview: function( pblock, arguments ) { | |
pblock.innerHTML = "Searches Characters in MAL"; | |
}, | |
execute: function( arguments ) { | |
var url = "http://myanimelist.net/character.php?q=" + arguments.object.text; | |
Utils.openUrlInBrowser( url ); | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment