我刚刚在 Google 上搜索有关 Hitbox 的一些信息时发现了您的帖子。你知道吗!?我刚刚在 30 分钟前制作了一个关注者警报应用程序。这是代码,实际上它非常简单。(hitbox_followeralert.js)
var followers = 0,
lastCheck = 0,
lastFollower = "",
sound = new Audio("AlertSound.ogg"),
channel = "MaitreChocobo";
function checkForNew(){
$.getJSON("http://api.hitbox.tv/user/"+channel, function(data){
followers = data.followers;
if(followers > lastCheck && lastCheck!=0){
sound.play();
$.getJSON("http://api.hitbox.tv/followers/user/"+channel+"?offset="+(followers-1), function(gata){
$("#new-follower").html(gata.followers[0].user_name);
$("#follower-alert .text").css("font-size", "45px");
$("#follower-alert").fadeIn("slow");
setTimeout(function(){
$("#follower-alert").fadeOut("slow");
}, 10000);
})
}
lastCheck = followers;
}).fail(function(){
console.log('An error occurred!');
});
}
setInterval(checkForNew, 5000);
因为我从 NightDev 的 Twitch Follower Alert 中获得灵感,所以我复制了他们的整个网页以使一切变得更简单。这是页面。(索引.html)
<html>
<head>
<meta charset="utf-8">
<title>Follower Alert</title>
<style>
body {
background-color: transparent;
color: white;
}
#follower-alert {
display: none;
position: absolute;
top: 0px;
left: 0px;
width: 580px;
height: 110px;
}
#follower-alert .text {
margin-left: 170px;
padding-top: 45px;
text-align: center;
width: 385px;
line-height: 45px;
vertical-align: middle;
font-size: 45px;
font-family: Impact;
text-shadow: 2px 2px 1px #000;
white-space: nowrap;
color: #ffffff;
}
</style>
<style type="text/css"></style></head>
<body>
<div id="follower-alert" style="background-image: url(template.png);">
<div class="text" id="new-follower" style="margin-left: 15px; width: 550px;"></div>
</div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="hitbox_followeralert.js"></script>
</body>
</html>
您只需更改顶部的频道变量以匹配您的用户名。如果不需要,也可以删除声音部分。我还在根文件夹中制作了一个名为template.png的简单背景。所以我有 4 个文件来制作这个小项目:index.html、hitbox_followeralert.js、AlertSound.ogg、template.png
然后将它添加到 OBS,我使用了名为 CLR Browser 的插件,你就可以开始了!
希望这可以帮助你,我回答你的问题还为时不晚。-Maitre陆行鸟