-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauth.html
252 lines (206 loc) · 8.45 KB
/
auth.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
<html>
<head>
<title>Login - Chatterino</title>
<script src="https://code.jquery.com/jquery-3.6.1.min.js" integrity="sha256-o88AwQnZB+VDvE9tvIXrMQaPlFFSUTR+nldQm1LuPXQ=" crossorigin="anonymous"></script>
<style>
#credentials {
display: none;
}
#loading {
display: none;
}
body {
margin: 0;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
text-align: center;
}
body,
button {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
font-size: 22px;
}
button{
box-shadow: 0px 5px 15px rgba(0,0,0,0.2);
padding: 2px 10px 2px 10px;
}
div.hcenter {
display: flex;
justify-content: center;
flex-direction: row;
}
.title {
display: flex;
align-items: center;
font-size: 44px;
margin-bottom: 0.2em;
}
.title>img {
margin-right: 22px;
height: 40px;
width: 40px;
}
p,
.title,
button {
margin: 16px 0;
}
.data {
width: 400px;
min-height: 100px;
}
@media (prefers-color-scheme: light) {
body, button, a {
color: #555;
}
}
@media (prefers-color-scheme: dark) {
body, a {
color: #ddd;
background-color: #191919;
}
}
</style>
</head>
<body>
<div class="title">
<img src="https://fourtf.com/img/chatterino-icon-64.png">Chatterino</div>
<div id="loginForm">
<p>Press the button below to log in.</p>
<div class="hcenter">
<button onclick="doRedirect();">Log in (!! do not show on stream !!)</button>
</div>
<p style="color: #999; font-size: 14px; display: none">This will show your login token.</p>
</div>
<div id="loading">
<p>Loading username and user id</p>
<p class="error"></p>
</div>
<div id="credentials">
<p>Click the 'copy text' button or manually copy the text below and<br>press the "Paste login info" button in Chatterino</p>
<textarea class="data"></textarea>
<div class="hcenter">
<button id="copy-credentials">Copy text</button>
</div>
</div>
<script type="text/javascript">
const clientID = 'j5yz8r03c4rbjsumbdnhqz5sn74st1';
const redirectURI = 'https://braize.pajlada.com/chatterino-login/auth.html';
const scopes = [
"channel:moderate", // for seeing automod & which moderator banned/unbanned a user (felanbird unbanned weeb123)
"channel:read:redemptions", // for getting the list of channel point redemptions (not currently used)
"chat:edit", // for sending messages in chat
"chat:read", // for viewing messages in chat
"whispers:read", // for viewing recieved whispers
// https://dev.twitch.tv/docs/api/reference#start-commercial
"channel:edit:commercial", // for /commercial api
// https://dev.twitch.tv/docs/api/reference#create-clip
"clips:edit", // for /clip creation
// https://dev.twitch.tv/docs/api/reference#create-stream-marker
// https://dev.twitch.tv/docs/api/reference#modify-channel-information
"channel:manage:broadcast", // for creating stream markers with /marker command, and for the /settitle and /setgame commands
// https://dev.twitch.tv/docs/api/reference#get-user-block-list
"user:read:blocked_users", // for getting list of blocked users
// https://dev.twitch.tv/docs/api/reference#block-user
// https://dev.twitch.tv/docs/api/reference#unblock-user
"user:manage:blocked_users", // for blocking/unblocking other users
// https://dev.twitch.tv/docs/api/reference#manage-held-automod-messages
"moderator:manage:automod", // for approving/denying automod messages
// https://dev.twitch.tv/docs/api/reference#start-a-raid
// https://dev.twitch.tv/docs/api/reference#cancel-a-raid
"channel:manage:raids", // for starting/canceling raids
// https://dev.twitch.tv/docs/api/reference#create-poll
// https://dev.twitch.tv/docs/api/reference#end-poll
"channel:manage:polls", // for creating & ending polls (not currently used)
// https://dev.twitch.tv/docs/api/reference#get-polls
"channel:read:polls", // for reading broadcaster poll status (not currently used)
// https://dev.twitch.tv/docs/api/reference#create-prediction
// https://dev.twitch.tv/docs/api/reference#end-prediction
"channel:manage:predictions", // for creating & ending predictions (not currently used)
// https://dev.twitch.tv/docs/api/reference#get-predictions
"channel:read:predictions", // for reading broadcaster prediction status (not currently used)
// https://dev.twitch.tv/docs/api/reference#send-chat-announcement
"moderator:manage:announcements", // for /announce api
// https://dev.twitch.tv/docs/api/reference#send-whisper
"user:manage:whispers", // for whispers api
// https://dev.twitch.tv/docs/api/reference#ban-user
// https://dev.twitch.tv/docs/api/reference#unban-user
"moderator:manage:banned_users", // for ban/unban/timeout/untimeout api
// https://dev.twitch.tv/docs/api/reference#delete-chat-messages
"moderator:manage:chat_messages", // for delete message api (/delete, /clear)
// https://dev.twitch.tv/docs/api/reference#update-user-chat-color
"user:manage:chat_color", // for update user color api (/color coral)
// https://dev.twitch.tv/docs/api/reference#get-chat-settings
"moderator:manage:chat_settings", // for roomstate api (/followersonly, /uniquechat, /slow)
// https://dev.twitch.tv/docs/api/reference#get-moderators
// https://dev.twitch.tv/docs/api/reference#add-channel-moderator
// https://dev.twitch.tv/docs/api/reference#remove-channel-vip
"channel:manage:moderators", // for add/remove/view mod api
// https://dev.twitch.tv/docs/api/reference#add-channel-vip
// https://dev.twitch.tv/docs/api/reference#remove-channel-vip
// https://dev.twitch.tv/docs/api/reference#get-vips
"channel:manage:vips", // for add/remove/view vip api
// https://dev.twitch.tv/docs/api/reference#get-chatters
"moderator:read:chatters", // for get chatters api
// https://dev.twitch.tv/docs/api/reference#get-shield-mode-status
// https://dev.twitch.tv/docs/api/reference#update-shield-mode-status
"moderator:manage:shield_mode", // for reading/managing the channel's shield-mode status
// https://dev.twitch.tv/docs/api/reference/#send-a-shoutout
"moderator:manage:shoutouts", // for reading/managing the channel's shoutouts (not currently used)
];
function doRedirect() {
const scopeString = scopes.join(' ');
const url = 'https://id.twitch.tv/oauth2/authorize?response_type=token&client_id=' +
clientID + '&redirect_uri=' + redirectURI + '&scope=' + encodeURIComponent(
scopeString);
document.location = url;
}
const oauthHash = location.hash.substr(1);
const oauthToken = oauthHash.substr(oauthHash.indexOf('access_token=')).split('&')[0].split('=')[1];
if (oauthToken) {
history.replaceState(null, null, ' ');
}
$(document).ready(function() {
if (oauthToken) {
$('#loginForm').hide();
$('#loading').show();
const userIDURL = 'https://api.twitch.tv/helix/users';
$.ajax({
dataType: 'json',
url: userIDURL,
headers: {
'Client-ID': clientID,
'Authorization': 'Bearer ' + oauthToken,
},
success: function(data) {
console.log('hehe');
console.log(data);
data = data.data[0];
userID = data.id;
username = data.login;
const dataString = 'oauth_token=' + oauthToken + ';username=' + username +
';user_id=' + userID + ';client_id=' + clientID;
$('#credentials .data').text(dataString);
$('#loading').hide();
$('#credentials').show();
$('.data').select();
},
error: function(xhr, textStatus, error) {
console.log('asdasd');
console.log(textStatus);
console.log(error);
$('#loading .error').text('Error getting user ID. Refresh and try again');
}
});
}
});
$("#copy-credentials").click(function(){
$(".data").select();
document.execCommand('copy');
console.log('copied data to clickboard xd');
});
</script>
</body>
</html>