Greasy Fork

Greasy Fork is available in English.

Ikariam desktop notifications

Runs when you have ikariam open and provides push notifications when the advisors lights up.

当前为 2016-06-13 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Ikariam desktop notifications
// @namespace    Danielv123
// @version      1.0
// @description  Runs when you have ikariam open and provides push notifications when the advisors lights up.
// @author       Danielv123
// @match        *.ikariam.gameforge.com/*
// @grant        none
// ==/UserScript==

// request permission on page load
document.addEventListener('DOMContentLoaded', function () {
    if (Notification.permission !== "granted") {
        Notification.requestPermission();
    }
});

setInterval(function() {
    if ($('#js_GlobalMenu_cities')[0].className == "normalactive") {
        console.log('Ding!');
        notifyMe("Ikariam", "Something happened in one of your towns!");
    }
    if ($('#js_GlobalMenu_diplomacy')[0].className == "normalactive") {
        console.log('Ding!');
        notifyMe("Ikariam", "Someone sent you a message!");
    }
    if ($('#js_GlobalMenu_military')[0].className == "normalactive") {
        console.log('Ding!');
        notifyMe("Ikariam", "Your militaryadvisor is trying to tell you something!");
    }
    if ($('#js_GlobalMenu_research')[0].className == "normalactive") {
        console.log('Ding!');
        notifyMe("Ikariam", "New research aviable!");
    }
},60000);


function notifyMe(title, message) {
    if (!Notification) {
        alert('Desktop notifications not available in your browser. Try Chromium.'); 
        return;
    }

    if (Notification.permission !== "granted")
        Notification.requestPermission();
    else {
        var notification = new Notification(title, {
            icon: 'http://cdn.sstatic.net/stackexchange/img/logos/so/so-icon.png',
            body: message,
        });

        notification.onclick = function () {
            window.open("http://http://s28-en.ikariam.gameforge.com/index.php");
        };
    }
}