Created
January 19, 2010 03:15
-
-
Save BrunoCaimar/280627 to your computer and use it in GitHub Desktop.
JetMeme
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
// @name JetMeme | |
// | |
// @author Bruno Caimar <bruno.caimarATgmail.com/> | |
// http://twitter.com/brunocaimar | |
// http://meme.yahoo.com/brunocaimar | |
// | |
// @description (en-US) Add a context menu on images and selection to post it to Yahoo! Meme | |
// Menu item will open a new tab to post the selected content to Yahoo! Meme | |
// | |
// (pt-BR) Adiciona um menu de contexto em imagens e seleções para facilitar a | |
// postagem disso no Yahoo! Meme | |
// O menu irá abrir uma nova aba para a postagem no Yahoo! Meme | |
// | |
// @license http://www.opensource.org/licenses/bsd-license.php | |
// @version 0.1.0_20100130 | |
// History: | |
// 0.0.1_20091201 - Initial Version - Only images | |
// 0.0.2_20100115 - Images and Selections | |
// 0.0.3_20100119 - Images and Selections / pt-br support added | |
// 0.1.0_20100130 - Rolling back pt-br support / first public release | |
// Todo: | |
// | |
// Feedback is welcome! Feedback é bem vindo! | |
jetpack.future.import("menu"); | |
jetpack.future.import('selection'); | |
var JetMeme = function (t) { | |
return { | |
label: "Send this to Yahoo! Meme", | |
icon: "http://l.yimg.com/cc/img/global/1257504392/favicon.ico", | |
notificationTitle: "Yahoo! Meme Jetpack add-on", | |
notificationBody: "New tab opened to post the selected content to Yahoo! Meme", | |
version: " 0.1.0_20100130", | |
via: " (JetMeme)", | |
command: function () { | |
var captionParam = "&caption="; | |
var captionText = "Source: " + | |
"<a href='" + t.document.location.href + "'>" + | |
t.document.title + "</a>"; | |
var rootURL = "http://meme.yahoo.com/dashboard/"; | |
var photo = "?photo=" + t.node.src; | |
var text = "?text=" + jetpack.selection.text + "\n\n" + captionText; | |
var content = t.node.nodeName.toLowerCase() === "img" ? photo : text; | |
var memeUrl = rootURL + | |
content + | |
captionParam + | |
captionText; | |
jetpack.tabs.open(encodeURI(memeUrl)); | |
jetpack.notifications.show({title: this.notificationTitle, | |
body: this.notificationBody, | |
icon: this.icon}); | |
} | |
}; | |
}; | |
jetpack.menu.context.page.on("img").set(function (target) (JetMeme(target))); | |
jetpack.menu.context.page.beforeShow = function (menu, context) { | |
menu.reset(); | |
var text = jetpack.selection.text; | |
if (text && | |
text.length > 0 && | |
context.node.nodeName.toLowerCase() !== "img") | |
{ | |
jetpack.menu.context.page.set(function (target)( JetMeme(target))); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment