Last active
December 28, 2015 06:59
-
-
Save YungSang/7461087 to your computer and use it in GitHub Desktop.
Taberareloo 用パッチ:wedata.net を1時間毎にチェックしてお知らせしてくれるやつ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==Taberareloo== | |
// { | |
// "name" : "Check availability of wedata.net" | |
// , "description" : "Check availability of wedata.net" | |
// , "include" : ["background"] | |
// , "version" : "0.2.0" | |
// , "downloadURL" : "https://gist.github.com/YungSang/7461087/raw/patch.check.wedata.tbrl.js" | |
// } | |
// ==/Taberareloo== | |
(function() { | |
var URL = 'http://wedata.net/'; | |
var timer = null; | |
var interval = 60 * 60 * 1000; | |
function check_wedata() { | |
if (timer) { | |
clearTimeout(timer); | |
timer = null; | |
} | |
request(URL).addCallback(function (res) { | |
TBRL.Notification.notify({ | |
title : 'ハロー wedata.net', | |
message : 'Wedata.net is up!', | |
onclick : function() { | |
chrome.tabs.create({ | |
url : URL | |
}); | |
this.close(); | |
} | |
}); | |
}).addErrback(function (res) { | |
TBRL.Notification.notify({ | |
title : 'ハロー wedata.net', | |
message : 'Wedata.net is still down.', | |
onclick : function() { | |
chrome.tabs.create({ | |
url : URL | |
}); | |
this.close(); | |
} | |
}).addCallback(function (n) { | |
setTimeout(function () { | |
n.close(); | |
}, 5 * 1000); | |
}); | |
timer = setTimeout(check_wedata, interval); | |
}); | |
} | |
check_wedata(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment