inital commit
This commit is contained in:
26
assets/javascripts/application.js
Normal file
26
assets/javascripts/application.js
Normal file
@@ -0,0 +1,26 @@
|
||||
$(function() {
|
||||
|
||||
const firstElement = document.getElementsByClassName('int_cf cf_4 attribute')[0].children[1];
|
||||
console.log(firstElement);
|
||||
if (firstElement) { // Check if the element exists
|
||||
firstElement.addEventListener('click', function() {
|
||||
console.log('The first element was clicked!');
|
||||
try {
|
||||
const text = firstElement.innerText;
|
||||
console.log(text);
|
||||
navigator.clipboard.writeText(text);
|
||||
|
||||
firstElement.innerHTML = "<b>Copied!</b>";
|
||||
firstElement.style.color = "#4CAF50"; // Turn green
|
||||
|
||||
setTimeout(() => {
|
||||
firstElement.innerText = text;
|
||||
firstElement.style.color = "";
|
||||
}, 2000);
|
||||
|
||||
} catch (err) {
|
||||
console.error('Unable to copy', err);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user