Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Andre Azzolini committed Sep 20, 2013
2 parents 13ef8ea + 337d988 commit 8abe5df
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 35 deletions.
Binary file added Icons/Angry/Grumpy Cat-grumpycat-grumpycatno.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion Rakefile
Expand Up @@ -81,7 +81,7 @@ namespace :build do
ri.dump_icons_to_folder('trollicons.AdiumEmoticonset')
Pathname.new('./build/trollicons.AdiumEmoticonset/Emoticons.plist').open('w'){|io| io << markup}
end

desc "Builds for Colloquy"
task :colloquy do
require 'builder'
Expand Down
9 changes: 6 additions & 3 deletions extension/trollicons/manifest.json
@@ -1,6 +1,8 @@
{
"manifest_version": 2,

"name": "Trollicons for Google Chrome™",
"version": "2.8",
"version": "2.9",
"description": "Parses trollicons in Facebook Chat",
"icons": {
"16": "icon16.png",
Expand All @@ -18,5 +20,6 @@
"trollicons.js"
]
}
]
}
],
"web_accessible_resources": ["img/*"]
}
62 changes: 31 additions & 31 deletions extension/trollicons/trollicons.js
@@ -1,60 +1,61 @@
(function() {
(function()
{
jQuery.noConflict();
var changing = false;
var nodes = {};

/* depending on where we are (fb or gmail) define a "replacement node" that we can just use later */
if (/facebook/.test(window.location.href)) {
var nodes = {};
nodes['div#fbDockChat'] = '.fbChatMessage'; // the docked chat window messages
//nodes['div#contentArea'] = '.storyContent'; // items in the feeds (this is buggy)
nodes['div#MessagingMessages'] = '.MessagingMessage'; // chat messages in the inbox
if (/facebook/.test(window.location.href))
{
nodes['div.conversation'] = '.fbChatConvItem .messages span'; // chat messages in the inbox
nodes['li.webMessengerMessageGroup'] = 'span'; // the docked chat window messages

var imgNode = (function(key, img) {
return "<span style=\"display:none\">" + key + "</span><img src=\"" + chrome.extension.getURL(img) + "\"/ style=\"background-position: 0px 0px\" alt=\":)\">";
});
var imgNode = (function(key, img)
{
return "<span style=\"display:none\">" + key + "</span><img src=\"" + chrome.extension.getURL(img) + "\"/ style=\"background-position: 0px 0px\" alt=\":)\">";
});
}
/*
* else if (/google/.test(window.location.href)) {
* console.debug('gmail plugin is experimental');
* var chatNode = 'div.nH.Hd';
* var messageNode = '.tReiP';
* var imgNode = (function(key, img) {
* return "<img src=\"" + chrome.extension.getURL(img) + "\" style=\"background-image: url(" + chrome.extension.getURL(img) + ");\"/ alt=\":)\">";
* });
* }
*/
else {
else
{
console.debug('not facebook');
}

/****
* now do the actual replacement of said node (defined above)
****/

/* now do the actual replacement of said node (defined above) */

// this is just going to match any simple strings wrapped in square brackets (ie. [balls] not [hello world])
// this is just going to match any lower case single word in square brackets (ie. [foo] not [hello world])
var re = new RegExp("\[[a-z]+\]", "g");

// go through the nodes we care about
jQuery.each(nodes, function(chatNode, messageNode) {
jQuery.each(nodes, function(chatNode, messageNode)
{
console.debug("### chatNode = " + chatNode);
console.debug("### messageNode = " + messageNode);

jQuery('body').delegate(chatNode, 'DOMNodeInserted', function(event) {

// When the DOM inserts a new node (message) under the chatNode node, do the icon filtering
jQuery('body').delegate(chatNode, 'DOMNodeInserted', function(event)
{
// we don't want to respond to the "change" event casued by our own replacement code
if (changing == false)
changing = true;
else
return;

// loop through all the messages in the chat window and replace the text with our icons
var messages = jQuery(messageNode);
jQuery.each(messages, function() {
var messages = jQuery(chatNode + " " + messageNode);

jQuery.each(messages, function()
{
var oldText = jQuery(this).html();
var newText = oldText;
var matches = oldText.match(re);
var message = this;
if (matches) {
jQuery.each(matches, function() {

if (matches)
{
jQuery.each(matches, function()
{
var key = this.substring(1, this.length-1);
var img = rages[key];

Expand All @@ -67,7 +68,6 @@
jQuery(message).html(newText);
}
});

changing = false;
});
});
Expand Down
9 changes: 9 additions & 0 deletions stats
Expand Up @@ -68,3 +68,12 @@ trollicons-ichat.pkg.zip, 1332792003, 18
trollicons-ichat-uninstaller.pkg.zip, 1332792003, 2
trollicons-digsby.zip, 1332792003, 17
trollicons-chrome.zip, 1332792003, 14
trollicons.colloquyEmoticons.zip, 1333301470, 20
trollicons.AdiumEmoticonset.zip, 1333301470, 232
trollicons-trillian.zip, 1333301470, 38
trollicons-pidgin.zip, 1333301470, 127
trollicons-miranda.zip, 1333301470, 31
trollicons-ichat.pkg.zip, 1333301470, 18
trollicons-ichat-uninstaller.pkg.zip, 1333301470, 2
trollicons-digsby.zip, 1333301470, 17
trollicons-chrome.zip, 1333301470, 15

0 comments on commit 8abe5df

Please sign in to comment.