Skip to content

Instantly share code, notes, and snippets.

@jmcarbo
Created June 5, 2009 01:16
Show Gist options
  • Save jmcarbo/123983 to your computer and use it in GitHub Desktop.
Save jmcarbo/123983 to your computer and use it in GitHub Desktop.
function myText(textFormat) {
// get the active document in a secure way
var doc = CmdUtils.getDocument();
var commenters = "";
jQuery(doc.body).find('.comment-block h4 a').each(
function(i){
if(!/img/i.test(this.innerHTML)){
commenters += '@<b>' + this.innerHTML + '</b>: gràcies - gracias - thanks.';
if(textFormat) {
commenters += '\n\n';
}
else{
commenters += '<br/>\n';
}
}
}
);
return(commenters);
}
/* This is a template command. */
CmdUtils.CreateCommand({
name: "flickr-comment",
icon: "http://example.com/example.png",
homepage: "http://example.com/",
author: {name: "Joan Marc Carbo Arnau", email: "[email protected]"},
license: "GPL",
description: "Outputs flickr comment response to users",
help: "Just place your cursor in the comment box",
takes: {"input": /.*/},
preview: function(pblock, input) {
// find div.foo in the body of that document
pblock.innerHTML = myText(false);
},
execute: function(input) {
CmdUtils.setSelection(myText(false),{ text: myText(true)});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment