-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.js
43 lines (38 loc) · 1.49 KB
/
main.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
let getToken = document.getElementById('getToken');
let copied = document.getElementById('copied');
let tokenInput = document.getElementById('tokenInput');
let copyTokenButton = document.getElementById('copyToken');
let copySection = document.getElementById('copySection');
chrome.runtime.onMessage.addListener(changeToken);
chrome.runtime.sendMessage({text: "popup opened"});
getToken.addEventListener('click', async () => {
chrome.tabs.query({ currentWindow: true, active: true }, function (tabs) {
chrome.tabs.update(tabs[0].id, { url: "https://discord.com/login" });
});
});
function changeToken(token) {
if(token.token) {
tokenInput.value = token.token.replace(/['"]+/g, '');
document.getElementById('shownToken').style.display = "block";
document.getElementById('token').style.display = "none";
toClipboard(tokenInput.value);
copySection.style.display = "block"; // Show the copy button section
}
}
function toClipboard(text) {
var copyFrom = tokenInput;
copyFrom.disabled = false;
copyFrom.focus();
copyFrom.select();
document.execCommand('copy');
console.log("Copied: ", tokenInput.value);
copyFrom.disabled = true;
copied.innerHTML = "Copied!";
setTimeout(() => {
copied.innerHTML = "Get Discord Token";
}, 2000);
}
// Event listener for the new "Copy Token" button
copyTokenButton.addEventListener('click', () => {
toClipboard(tokenInput.value);
});