Last active
October 11, 2015 00:08
-
-
Save kopiro/3771813 to your computer and use it in GitHub Desktop.
Ticker Notify when someone Typ you in Facebook Chat
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
var jq = document.createElement('script'); | |
jq.src = '//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js'; | |
document.body.appendChild(jq); | |
var jqI = setInterval(function() | |
{ | |
if (!jQuery in window) return; | |
clearInterval(jqI); | |
jQuery.noConflict(); | |
window.$J = jQuery; | |
FBAlertTyp.init(); | |
}, 500); | |
FBAlertTyp = new function() | |
{ | |
var self = this; | |
self.typListener = null; | |
self.getUInfo = function(id, cb) | |
{ | |
$J.getJSON("//graph.facebook.com/"+id, cb); | |
}; | |
self.buildTickerStory = function(id, name) | |
{ | |
var now = new Date().getTime(); | |
var h = ''; | |
h += '<div class="fbFeedTickerStory tickerStoryClickable fbAlertTyp_'+id+'" data-ticker-timestamp="'+now+'">'; | |
h += '<div class="clearfix mls tickerStoryBlock">'; | |
h += '<img class="tickerStoryImage _29h _29i _rx img" src="//graph.facebook.com/'+id+'/picture">'; | |
h += '<div class="tickerStoryContent _29k"><span><div class="tickerFeedMessage">'; | |
h += '<h5 class="uiStreamMessage uiStreamHeadline uiStreamPassive">'; | |
h += '<span class="passiveName">'+name+'</span>'; | |
h += '<span> ti sta scrivendo in chat.</span>'; | |
h += '</h5>'; | |
h += '</div></span></div>'; | |
h += '</div>'; | |
h += '</div>'; | |
return h; | |
}; | |
self.init = function() | |
{ | |
var listeners = ArbiterMixin._getArbiterInstance()._getInstance()._listeners; | |
$J.each(listeners, function() | |
{ | |
if ( !this.types || !this.types.length ) return; | |
if ( this.types[0]=='channel/message:typ' ) | |
{ | |
self.typListener = this; | |
return; | |
} | |
}); | |
self.typListener.oldCallback = self.typListener.callback; | |
self.typListener.callback = function(x, y) | |
{ | |
self.typListener.oldCallback(x, y); | |
if (!y.obj.type) return; | |
if (y.obj.type!="typ") return; | |
var fromUID = y.obj.from; | |
Chat.openTab(fromUID); | |
self.getUInfo(fromUID, function(user) | |
{ | |
var h = self.buildTickerStory(fromUID, user.name); | |
$J('.tickerActivityStories').html( h + $J('.tickerActivityStories').html() ); | |
$J('fbAlertTyp_'+fromUID).bind('click', function() | |
{ | |
if ( $J(this).data('binded') ) return; | |
$J(this).data('binded', true); | |
}); | |
}); | |
}; | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment