-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
executable file
·75 lines (51 loc) · 1.81 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
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
function setWebhookPath() {
let thread_id = document.getElementById("thread_id").value;
if (thread_id != ""){
let current_url = new URL(window.location.href);
let params = new URLSearchParams(current_url.search);
params.set("thread_id", thread_id);
// Set # + webhook + ? + params
window.location.hash = document.getElementById("webhook_url").value + "?" + params.toString();
} else {
// Set # + webhook
window.location.hash = document.getElementById("webhook_url").value;
}
console.log(window.location.href);
}
function sendMsg() {
if(window.location.hash) {
let webhook_url = window.location.hash.substring(1); //Puts hash in variable, and removes the # character
let content_text = document.getElementById("content_text").value;
let username_text = document.getElementById("username_text").value;
let avatar_text = document.getElementById("avatar_text").value;
// let params_url = (new URL(document.location)).searchParams;
// let token = params_url.get("token");
let request = new XMLHttpRequest();
request.open("POST", webhook_url);
request.setRequestHeader('Content-type', 'application/json');
// INFO 996100965650407424
// ERRO 996100568609210370
let params = {
avatar_url: avatar_text,
content: content_text,
username: username_text
}
console.log("sent to thread");
request.send(JSON.stringify(params));
} else {
console.log("URL not set")
}
}
// ## Button Clear Keys
function clearAllUrlFields(){
let str = "";
document.getElementById("webhook_url").value = str;
document.getElementById("thread_id").value = str;
}
// ## Button Clear Keys
function clearAllFormFields(){
let str = "";
document.getElementById("avatar_text").value = str;
document.getElementById("content_text").value = str;
document.getElementById("username_text").value = str;
}