Forked from YungSang/patch.check.wedata.tbrl.js
Last active
December 28, 2015 09:39
-
-
Save taizooo/7480615 to your computer and use it in GitHub Desktop.
Taberareloo パッチ: wedata.net を3時間毎にチェックして Wedata.net is still down だったら "ハロー wedata.net ハロー、ハロー" してくれるやつ 改
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 and Tweet" | |
// , "description" : "Check availability of wedata.net every 3 hours and tweet it" | |
// , "include" : ["background"] | |
// , "version" : "0.3.1.4" | |
// , "downloadURL" : "https://gist.github.com/taizooo/7480615/raw/patch.check.wedata.tbrl.js" | |
// } | |
// ==/Taberareloo== | |
(function () { | |
var URL = 'http://wedata.net/'; | |
var timer = null; | |
var interval = 3 * 60 * 60 * 1000; | |
function randlen(x, l) { | |
var n = Math.floor(l * Math.random()); | |
var s = '' | |
for (var i = 0; i < n; i++) { | |
s += x; | |
} | |
return s; | |
} | |
var zerowidthspace =''; | |
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(); | |
} | |
}); | |
TBRL.Service.post({ | |
type: 'regular', | |
description: 'ウエルカム バック!!! wedata.net', | |
https: { | |
pageUrl: [false, URL] | |
} | |
}, Models['Twitter']); | |
}).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); | |
}); | |
zerowidthspace = randlen('\u200B',100); | |
TBRL.Service.post({ | |
type: 'regular', | |
description: 'ハロー wedata.net ハロー、ハロー' + zerowidthspace, | |
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