m.facebook.com sound notification

Play sound and vibrate your phone when a message comes.

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         m.facebook.com sound notification
// @namespace    http://tampermonkey.net/
// @version      3.0
// @description  Play sound and vibrate your phone when a message comes.
// @author       Psyblade
// @match        https://m.facebook.com/*
// @grant        none
// ==/UserScript==

var jewelElem = document.getElementById("mJewelNav").childNodes[2].getElementsByClassName("_59tg")[0]
var observer = new MutationObserver(function(mutationsList, observer) {
    if(jewelElem.innerHTML != "0")
   {
	 var audio = new Audio('https://raw.githubusercontent.com/psyblade12/Notification-in-m.facebook.com/master/FBMessSound.ogg');
                audio.play();
                window.navigator.vibrate(500);
   }
});

observer.observe(jewelElem, {characterData: false, childList: true, attributes: false});