Outlook Notification

Send desktop notification from Outlook Web Application

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Outlook Notification
// @namespace    http://tampermonkey.net/
// @version      0.4
// @description  Send desktop notification from Outlook Web Application
// @author       Wenxuan Zhao
// @match        https://outlook.office.com/mail/inbox
// @iconURL      http://ow2.res.office365.com/owamail/2019031801.04/resources/images/favicons/mail-seen.ico
// @grant        GM_notification
// ==/UserScript==

(function() {
  'use strict';
  var sentSet = new Set();
  console.log('[Outlook Notification] UserScript loaded')

  setInterval(function () {
    var reminders = Array.from(document.querySelector('.ms-Layer').firstChild.firstChild.lastChild.lastChild.firstChild.children)
    reminders.forEach(function (reminder) {
      if (sentSet.has(reminder)) return;
      sentSet.add(reminder)

      var event = reminder.querySelector('.ms-Button-flexContainer').lastChild

      var message = event.firstChild.firstChild.textContent
      var time = event.lastChild.firstChild.textContent
      var location = event.lastChild.lastChild.textContent

      var title = 'Outlook Notification'
      var text = message + " / " + time + " @ " + location

      console.log('[Outlook Notification] Send notification: ', message, time, location)
      GM_notification(text, title, 'http://ow2.res.office365.com/owamail/2019031801.04/resources/images/favicons/mail-seen.ico')
    })
  }, 1000);
})();