-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcode.js
More file actions
22 lines (20 loc) · 1.05 KB
/
code.js
File metadata and controls
22 lines (20 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
document.querySelector("#button_code").innerHTML = "" + document.querySelector("#button_code").innerHTML.replace(/ +(?= )/g, "");
document.querySelector("#toCopy").value = document.querySelector("#button_code").innerHTML;
document.querySelector("#username").addEventListener("input", function() {
document.querySelector("#button_code iframe").src = `https://yikuansun.github.io/patreonbutton/widget.html?username=${this.value}`;
document.querySelector("#toCopy").value = document.querySelector("#button_code").innerHTML;
});
document.querySelector("#copybutton").addEventListener("click", function() {
navigator.clipboard.writeText(document.querySelector("#toCopy").value);
document.querySelector("#toCopy").select();
this.innerText = "Copied";
this.style.color = "grey";
this.style.textDecoration = "none";
this.style.cursor = "default";
setTimeout(function() {
this.innerText = "Copy to clipboard";
this.style.color = "";
this.style.textDecoration = "";
this.style.cursor = "";
}.bind(this), 1650);
});