-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
cobalt.js
31 lines (27 loc) · 829 Bytes
/
cobalt.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
'use strict';
let getCobaltCookie = document.getElementById('CobaltCookie');
const getCobaltSessionToken = () => {
return new Promise((resolve, reject) => {
const filter = {
name: "CobaltSession",
domain: ".dndbeyond.com",
};
chrome.cookies.getAll(filter, function (cookies) {
if (cookies.length > 0) resolve(cookies[0].value);
else reject(null);
});
});
};
getCobaltCookie.onclick = function(element) {
// try to get an existing session cookie
getCobaltSessionToken().then((result) => {
navigator.clipboard.writeText(result).then(() => {
//clipboard successfully set
}, () => {
console.log("Clipboard access failed!");
});
})
.catch((error) => {
console.log("No Cobalt Session cookie found yet");
});
};