I’m having trouble with my Twitch account status verification tool. It was working fine several months back but now it seems to be broken. I built this tool to check if a Twitch username has been banned or suspended from the platform.
var verify_account = function (username) {
$(".info-text").fadeOut(30)
$.getJSON('https://api.twitch.tv/kraken/users/' + encodeURIComponent(username) + '?callback=?').done(function (response) {
if (/.+is unavailable$/.test(response.message)) {
var msg = 'This account appears to be suspended from Twitch. Contact ';
msg += 'Twitch support through their official channels to understand the reason. ';
msg += 'We cannot assist with ban appeals.';
display_result('error', msg);
} else if (/.+is not available on Twitch$/.test(response.message) || /.+does not exist$/.test(response.message)) {
var msg = 'This username either does not exist or is not a valid Twitch account.';
display_result('warning', msg);
} else {
var msg = 'This account does not appear to have any restrictions. ';
msg += 'If you are experiencing access issues, check your network connection ';
msg += 'or disable any VPN services that might interfere with Twitch.';
display_result('ok', msg);
}
}).fail(function () {
display_result('warning', 'API request failed. Twitch servers might be experiencing problems.');
});
};
var display_result = function (status, text) {
var header_text = status === 'ok' ? 'No Issues Found' : status === 'warning' ? 'Something is Wrong' : 'Account Suspended';
$('.output').attr('class', 'output');
$('.output').html('<h4>' + header_text + '</h4>' + text);
$('.output').addClass(status);
$('.output').fadeIn();
};
$(document).ready(function () {
$('#username-form').on('keypress', function (event) {
if (event.which === 13) {
event.preventDefault();
var input_name = $('#username-input').val();
verify_account(input_name);
}
});
});
Can anyone help me figure out what might be causing this to stop working? Any suggestions would be really helpful.