I was just trying code in Tampermonkey that makes a sound when a type of message appears in a chat.
The problem is that this script works only on the first message and I want to make it work every time.
I have been looking through internet and I found that maybe is because something called 'iFrames'??
The script:
// ==UserScript==
// @name New Userscript
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Sound when chat message
// @author You
// @include *
// @grant none
// ==/UserScript==
var exist = false;
var notified = false;
mCoinSound = new Audio("https://dl.dropbox.com/u/7079101/coin.mp3");
setInterval(getRain, 2000);
function getRain() {
var rain = document.getElementsByClassName('rain-message');
exist = rain.length === 0 ? false : true;
notified = (exist && notified);
if (exist && !notified) {
mCoinSound.play();
notified = true;
}
}