tomcss / Custom Web Skype Emoticons

// ==UserScript==
// @name        Custom Web Skype Emoticons
// @namespace   dodgy.website
// @description use custom emoticons in web Skype
// @include     /https:\/\/web\.skype\.com\/(nl|en|sp)\/*/
// @version     1
// @grant       none
// ==/UserScript==

var hist,bubbles,lastLength;

function checkUp() {
  bubbles = hist.getElementsByClassName('bubble');
  while( lastLength<(bubbles.length-1)) {
    lastLength++;
    var p=bubbles[lastLength].querySelector('[id^=msg_] > p');
    if( p !== undefined)
      p.innerHTML = p.innerHTML.replace(/_([\w]+\.gif)/g, "<img src='http://i.imgur.com/$1'>");
  }
}

function init() {
  hist = document.getElementsByClassName('messageHistory')[0];
  bubbles = hist.getElementsByClassName('bubble');
  lastLength = 0;

  setInterval( checkUp, 1000);   
}

setTimeout( init, 10000);