m.facebook.com sound notification

Play sound and vibrate your phone when a message comes.

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==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});