Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- javascript:(function(){
- jQuery.fn.checkMessage = function(pat) {
- function innerMessage(node, pat) {
- var skip = 0;
- if (node.nodeType == 3) {
- var pos = node.data.toUpperCase().indexOf(pat);
- if (pos >= 0) {
- alert(pat+' was mentioned in chat!');
- skip = 1;
- }
- }
- else if (node.nodeType == 1 && node.childNodes && !/(script|style)/i.test(node.tagName)) {
- for (var i = 0; i < node.childNodes.length; ++i) {
- i += innerMessage(node.childNodes[i], pat);
- }
- }
- return skip;
- }
- return this.each(function() {
- innerMessage(this, pat.toUpperCase());
- });
- };
- var b=$('<div><a id="p" style="color:#fff;" href="#">Alert me for chat</a> <span style="color:#fff;">|</span> <a id="s" style="color:#fff;" href="#">Stop all alerts</a></div>'),f;
- b.css({'position':'fixed','bottom':20,'left':0,'z-index':9999,'color':'#fff'});
- $('body').append(b);
- $('#p').click(function(e){
- e.preventDefault();
- var test = prompt('Alert On:');
- $('.chat-container').bind('DOMSubtreeModified',{msg: test}, function(event) {
- $('.message').last().children('.text').checkMessage(event.data.msg);
- });
- });
- $('#s').click(function(e){
- e.preventDefault();
- $('.chat-container').unbind();
- });
- }());
Add Comment
Please, Sign In to add comment