-
-
Save mjpieters/47363 to your computer and use it in GitHub Desktop.
Urban Dictionary ubiquity search command
This file contains hidden or 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
(function($) { | |
makeSearchCommand({ | |
name: "urban-dictionary", | |
author: {name: "Martijn Pieters", email: "[email protected]"}, | |
description: "Looks up definition in the Urban Dictionary", | |
icon: "http://www.urbandictionary.com/favicon.ico", | |
url:"http://www.urbandictionary.com/define.php?term={QUERY}", | |
preview: function(pblock, search) { | |
if (search.text.length < 1) { | |
$(pblock).html("Definition from the <b>Urban Dictionary</b>"); | |
return; | |
} | |
CmdUtils.previewGet( | |
pblock, | |
this.url.replace("{QUERY}", escape(search.text)), | |
function(doc) { | |
doc = $(doc.replace(/<script(.|\s)*?\/script>/g, "")); | |
$(pblock).empty(); | |
$(pblock).append( | |
$('<div/>') | |
.addClass('definition') | |
.append(doc.find('td.text:first div.definition') | |
) | |
); | |
$(pblock).append('<br/>'); | |
$(pblock).append( | |
$('<div/>') | |
.addClass('example').css('font-style', 'italic') | |
.append(doc.find('td.text:first div.example')) | |
); | |
} | |
); | |
}, | |
previewDelay: 10, | |
}); | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment