0

有一个叫hitbox的网站。它类似于 twitch,但据我所知,api 是相当不同的!我试图采取抽搐追随者警报并稍微更改代码以使其与hitbox一起使用,但没有运气。我不想创建一个完整的程序,因为那会花费很多时间。我只想制作一个网页并在那里显示最新的关注者。hitbox api 可以在这里找到。如果您认为在 mIRC 中做类似的事情会更容易,那么就这样做,但我认为用网页做会更容易。在编程方面,我完全是 n00b,所以如果你能向我解释一切我会很感激(我想开始学习编码,但我真的不知道从哪里开始。至少我还很年轻( 14)所以我有足够的时间去做)

谢谢你 - 安德鲁

4

1 回答 1

3

我刚刚在 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陆行鸟

于 2014-07-14T01:00:53.053 回答