Skip to content

Instantly share code, notes, and snippets.

@YungSang
Forked from YungSang/patch.check.wedata.tbrl.js
Last active December 28, 2015 09:19
Show Gist options
  • Save YungSang/7477631 to your computer and use it in GitHub Desktop.
Save YungSang/7477631 to your computer and use it in GitHub Desktop.
Taberareloo パッチ: wedata.net を3時間毎にチェックして Wedata.net is still down だったら "ハロー wedata.net ハロー、ハロー" してくれるやつ
// ==Taberareloo==
// {
// "name" : "Check availability of wedata.net and Tweet"
// , "description" : "Check availability of wedata.net every 3 hours and tweet it"
// , "include" : ["background"]
// , "version" : "0.3.1"
// , "downloadURL" : "https://gist.github.com/YungSang/7477631/raw/patch.check.wedata.tbrl.js"
// }
// ==/Taberareloo==
(function() {
var URL = 'http://wedata.net/';
var timer = null;
var interval = 3 * 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);
});
TBRL.Service.post({
type : 'regular',
description : 'ハロー wedata.net ハロー、ハロー',
https : {
pageUrl : [false, URL]
}
}, Models['Twitter']);
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