-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscript.js
More file actions
53 lines (46 loc) · 1.52 KB
/
Copy pathscript.js
File metadata and controls
53 lines (46 loc) · 1.52 KB
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
let codiceCompleto = '';
fetch('tracker.js')
.then(response => {
if (!response.ok) throw new Error('File tracker.js non trovato nella repository');
return response.text();
})
.then(testoCodice => {
codiceCompleto = testoCodice;
})
.catch(err => {
console.error('Errore nel caricamento di tracker.js:', err);
});
function copiaTestoNegliAppunti(testo) {
if (navigator.clipboard) {
return navigator.clipboard.writeText(testo);
} else {
const area = document.createElement('textarea');
area.value = testo;
area.style.position = 'fixed';
document.body.appendChild(area);
area.select();
document.execCommand('copy');
document.body.removeChild(area);
return Promise.resolve();
}
}
document.getElementById('copy-btn').addEventListener('click', function() {
if (!codiceCompleto) {
alert('Sto ancora scaricando il codice di tracker.js, attendi un istante...');
return;
}
copiaTestoNegliAppunti(codiceCompleto).then(() => {
const bottone = this;
const testoOriginale = bottone.innerText;
bottone.innerText = '✓ Copied!';
bottone.style.backgroundColor = '#34d399';
bottone.style.transform = 'scale(0.96)';
setTimeout(() => {
bottone.style.transform = 'scale(1)';
}, 100);
setTimeout(() => {
bottone.innerText = testoOriginale;
bottone.style.backgroundColor = '';
}, 2000);
});
});