m.facebook.com sound notification

Play sound and vibrate your phone when a message comes.

目前為 2020-01-06 提交的版本,檢視 最新版本

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

//For some reason, this procedure is must to make Yandex Browser use this script stably.
var initialization = new Audio('https://raw.githubusercontent.com/psyblade12/Notification-in-m.facebook.com/master/Initialization.mp3');
initialization.play();

//Add event listener to element #5 of classes named "_59tg". Event will fire if the web browser detects changes in inner HTML of that element.

document.getElementsByClassName("_59tg")[2].addEventListener("DOMNodeInserted", function(){
   if(document.getElementsByClassName("_59tg")[2].innerHTML != "0")
   {
	 var audio = new Audio('https://raw.githubusercontent.com/psyblade12/Notification-in-m.facebook.com/master/FBMessSound.ogg');
                audio.play();
               //Vibrate the phone.
                window.navigator.vibrate(500);
   }
});