2021-07-24 02:02:36 +02:00
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>Login - Chatterino</title>
|
2021-07-24 14:08:44 +02:00
|
|
|
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans&display=swap" rel="stylesheet">
|
|
|
|
<link rel="icon" href="https://chatterino.com/logo.png">
|
|
|
|
<style>
|
|
|
|
body {
|
|
|
|
font-family: 'Noto Sans', sans-serif;
|
|
|
|
color: #efefef;
|
|
|
|
background-color: #1f1f1f;
|
|
|
|
font-size: 1.1em;
|
|
|
|
|
|
|
|
margin: 0;
|
|
|
|
display: flex;
|
|
|
|
justify-content: center;
|
|
|
|
align-items: center;
|
|
|
|
flex-direction: column;
|
|
|
|
text-align: center;
|
|
|
|
}
|
|
|
|
.title {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
font-size: 44px;
|
|
|
|
font-weight: bolder;
|
|
|
|
margin: 16px 0;
|
|
|
|
margin-bottom: 0.2em;
|
|
|
|
}
|
|
|
|
.title > img {
|
|
|
|
margin-right: 22px;
|
|
|
|
height: 40px;
|
|
|
|
width: 40px;
|
|
|
|
}
|
|
|
|
p {
|
|
|
|
margin: 6px 0;
|
|
|
|
text-decoration: none;
|
|
|
|
font-size: 1.5em;
|
|
|
|
max-width: 960px;
|
|
|
|
}
|
|
|
|
</style>
|
2021-07-24 02:02:36 +02:00
|
|
|
</head>
|
2021-07-24 13:36:06 +02:00
|
|
|
<body>
|
2021-07-24 14:08:44 +02:00
|
|
|
<div class="title">
|
|
|
|
<img src="https://chatterino.com/logo.png">Chatterino
|
|
|
|
</div>
|
2021-07-24 02:02:36 +02:00
|
|
|
<noscript>
|
2021-07-24 14:08:44 +02:00
|
|
|
<style>
|
|
|
|
#status {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
<p>This page requires Javascript to run
|
|
|
|
<br>
|
|
|
|
<br>Alternatively, copy your access token from the URL
|
2021-07-25 12:53:33 +02:00
|
|
|
<br>and click "Paste token from clipboard" button in Chatterino
|
2021-07-24 14:08:44 +02:00
|
|
|
</p>
|
2021-07-24 02:02:36 +02:00
|
|
|
</noscript>
|
|
|
|
<p id="status">Loading...</p>
|
|
|
|
<script>
|
2021-07-24 13:36:06 +02:00
|
|
|
(function() {
|
2021-07-24 02:02:36 +02:00
|
|
|
// Address of local Chatterino's http server
|
|
|
|
const address = "localhost";
|
|
|
|
const port = 52107;
|
|
|
|
|
|
|
|
// Retrieve hash with token and hide it immidiatelly
|
|
|
|
const fragment = location.hash.substring(1);
|
|
|
|
history.replaceState(null, null, " ");
|
|
|
|
|
|
|
|
// Find token in the hash
|
2021-07-24 13:36:06 +02:00
|
|
|
const token = new URLSearchParams(fragment).get("access_token");
|
2021-07-24 02:02:36 +02:00
|
|
|
|
|
|
|
let status = document.getElementById("status");
|
|
|
|
|
|
|
|
// Return if no token was found
|
2021-07-24 13:36:06 +02:00
|
|
|
if (!token) {
|
2021-07-24 02:02:36 +02:00
|
|
|
status.innerHTML = "Bad request";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Call Chatterino's http server
|
|
|
|
status.innerHTML = "Sending your credentials to Chatterino...";
|
|
|
|
|
|
|
|
fetch(`http://${address}:${port}/token`, {
|
2021-07-24 13:36:06 +02:00
|
|
|
method: "PUT",
|
2021-07-24 02:02:36 +02:00
|
|
|
headers: {
|
|
|
|
"X-Access-Token": token
|
|
|
|
}
|
|
|
|
}).then(resp => {
|
|
|
|
// Failure
|
|
|
|
if (resp.status !== 200) {
|
|
|
|
status.innerHTML = `Chatterino refused your credentials, error ${resp.status}`;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// Success
|
|
|
|
status.innerHTML = "Chatterino added your account successfully!<br>You can close this tab now.";
|
|
|
|
}).catch(err => {
|
|
|
|
// Unexpected the unexpectable
|
|
|
|
console.log(err);
|
|
|
|
status.innerHTML = "Something went wrong, check console for details";
|
|
|
|
});
|
2021-07-24 13:36:06 +02:00
|
|
|
})();
|
2021-07-24 02:02:36 +02:00
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|