Twitch Ban Checker - PullRequest
       35

Twitch Ban Checker

1 голос
/ 01 мая 2020

Можете ли вы помочь мне с моим Twitch Ban Checker

, он работал несколько месяцев go, но сейчас что-то не так, может быть, кто-то может дать мне совет, почему он больше не работает, я написал это Twitch Ban Checker, который после ввода имени пользователя дает ответ, был ли вы забанен на Twitch или нет

приложение также на codepen https://codepen.io/olthoffs/pen/zqxbWW

var check_user = function (user) {
            $(".description").fadeOut(20)

            $.getJSON('https://api.twitch.tv/kraken/users/' + encodeURIComponent(user) + '?callback=?').done(function (data) {
                if (/.+is unavailable$/.test(data.message)) { // Ban Check
                    var message = 'It looks like you were banned from twitch, please open a ticket via the '
                    message += '<a target="_blank" href="https://help.twitch.tv/customer/portal/emails/new?interaction[name]=' + user + '">official twitch support</a> '
                    message += 'site in order to see why you were banned.<br />'
                    message += '<span>TwitchTips cannot and will not help with your appeal</span>'
                    form_result('fail', message)
                } else if (/.+is not available on Twitch$/.test(data.message) || /.+does not exist$/.test(data.message)) { // JTV/Nonexistant Check
                    var message = 'That account is either not a Twitch account or it does not exist.'
                    form_result('warn', message)
                } else {
                    var message = 'The account provided does not seem to be banned on Twitch. '
                    message += 'If you\'re seeing a message telling you that you\'re blocked from Twitch, '
                    message += 'try disabling any VPN, proxy, or extension which re-routes traffic from your browser.<br/><br/>'
                    message += 'Got multiple accounts? Try checking those too because Twitch bans can be IP based.<br/><br/>'
                    message += 'If after doing so you are still getting the same error, '
                    message += 'your ISP may have provided your modem with a previously banned IP address. '
                    message += 'You can <a style="color: #fff" href="https://help.twitch.tv/customer/portal/emails/new?interaction[name]=' + user + '" target="_blank"><strong>open a ticket</strong></a> with Twitch to check.'
                    form_result('success', message)
                }
            }).fail(function () {
                form_result('warn', 'The Twitch API appears to have returned an invalid response. Twitch may be having issues at the moment.')
            })  
        }
        var form_result = function (type, message) {
            if (type === 'success') {
                var title = "All is well!"
            } else if (type === 'warn') {
                var title = "Hmm, That's not right!"
            } else {
                var title = "Oh dear!"
            }

            $('.result').attr('class', 'result')
            $('.result').html('<h3>' + title + '</h3>' + message)
            $('.result').addClass(type)
            $(".result").fadeIn()
        }

        $(document).ready(function () {
            $('#ban-check').submit(function (e) {
                e.preventDefault()
            })

            $('#ban-check').keyup(function (e) {
                if (e.keyCode !== 13) {
                    return
                }

                e.preventDefault()

                var user = $('#ban-check input').val()
            window.location.hash = '#' + user
            check_user(user)
            })
            var hash = location.hash
            if (hash) {
                var user = hash.substr(1)
                $('#ban-check input').val(user)
                check_user(user)
            }
        })

...