Skip to content

Instantly share code, notes, and snippets.

@hcccc
Created June 3, 2017 05:20
Show Gist options
  • Save hcccc/c9b895cef3f990c7d544537ecd26037f to your computer and use it in GitHub Desktop.
Save hcccc/c9b895cef3f990c7d544537ecd26037f to your computer and use it in GitHub Desktop.
Interval example
(function () {
const messageList = [
'求手机!', '非常棒', '我要看大长腿', '小电视暗中观察', '为什么我还没中',
'我要当欧皇', '中了直播开机哦', '求奇迹出现', '呜呜呜不中啊']
const roomId = window.location.href.match(/\.com\/(\d+)/)[1];
const bilibiliSendDanmuPost = 'http://live.bilibili.com/msg/send';
setInterval(function () {
var message = messageList[parseInt(Math.random() * (messageList.length - 1))] || '小米很棒!!';
console.log('准备发送: ' + message);
$.post(bilibiliSendDanmuPost, {
color: 0xffffff.toString(),
fontsize: 25,
mode: 1,
msg: message,
rnd: window.DANMU_RND,
roomid: roomId,
}, (response) => {
var parsedResponse = JSON.parse(response);
if (parsedResponse.code == 0) {
var d = new Date();
console.info('发送成功: ' + d.toString());
}
})
}, 1000 * 60 * 5)
return '开始计时';
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment