-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
35 lines (28 loc) · 1.15 KB
/
script.js
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
const copyButton = document.getElementById("copy")
function copy() {
let el = document.getElementById("access-token")
navigator.clipboard.writeText(el.value)
copyButton.innerText = "Скопировано"
setTimeout(() => copyButton.innerText = "Скопировать", 3000)
}
function auth() {
let scopesElements = document.getElementsByClassName("scope")
let scopes = []
for (let el of scopesElements) {
if (el.checked) {
scopes.push(el.id)
}
}
scopes = scopes.join("%20")
let redirect_uri = "https://declider.github.io/donationalerts-auth/" // обязательно с '/' в конце
let client_id = "10715"
let url = `https://www.donationalerts.com/oauth/authorize?client_id=${client_id}&redirect_uri=${redirect_uri}&response_type=token&scope=${scopes}&force_verify=true`
window.open(url,"_self")
}
window.onload = () => {
let hash = window.location.hash
if (!hash) { return }
let token = hash.split("access_token=")[1].split("&",1)[0]
document.getElementById("access-token").value = token
copyButton.disabled = false
}