Yahoo! new mail alert

This script will play the classic "Yahoo! Mail" voice wav file when it detects you have new unread mail in your mailbox

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name        Yahoo! new mail alert
// @namespace   https://github.com/mjremijan
// @include     https://*.mail.yahoo.com/*
// @version     1
// @grant       none
// @description This script will play the classic "Yahoo! Mail" voice wav file when it detects you have new unread mail in your mailbox
// ==/UserScript==
 
var unread = -1;

function checkForUnread() {
	// (xx unread) ....
	var t = document.title;
	var p = -1;
	if (t.charAt(0) == "(") {
		p = parseInt(t.substring(1, t.indexOf(" ")));
		//alert("p = ["+p+"]");
	}
	
	var play = false;
	if (unread == -1) {
		unread = p;
		play = (unread > 0);
	} else {
		if (p > unread) {
			play = true;
		}
		unread = p;
	}
	
	if (play) 
	{
		var wavFile = "https://www.dropbox.com/s/bsmsmccug65vdtd/yahoomail.wav?dl=1";
	
		var src1 = document.createElement('SOURCE');
		src1.type= 'audio/wav';
		src1.src= wavFile;

		var e = document.createElement('AUDIO');
		e.appendChild(src1);
		e.play();
	}
}

setInterval(checkForUnread, 60 * 1000); // 60 * 1000 ms