-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
28 lines (25 loc) · 798 Bytes
/
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
function copyToClipboard(element) {
const textToCopy = element.textContent;
console.log(textToCopy);
let re = /.*/;
let match = re.exec(textToCopy);
let emailStr = '';
if (match) {
emailStr = match[0];
} else {
console.log('No match found');
return
}
navigator.clipboard.writeText(emailStr)
.then(() => {
console.log('Text copied to clipboard');
const tooltip = document.getElementById('tooltip');
tooltip.classList.add('show');
setTimeout(() => {
tooltip.classList.remove('show');
}, 1000); // Hide the tooltip after 1 second
})
.catch((error) => {
console.error('Failed to copy text to clipboard:', error);
});
}