Hi! I would like to copy the title and/or author from the slider on this URL (for example, Dialoghi con Leucò by Cesare Pavese).
I’m using this userscript, but when I select text, the slider moves, and I have to double-click to highlight the text. Is there a way to prevent this behavior?
I am not sure if it this you want but here you go…
(function setupCopyFunctionality() {
document.querySelectorAll('.cc-slide').forEach(link => {
let info = link.children[0].innerText
// console.log(info);
let values = info.split("\n")
let title = values[0]
let author = values[1].split("di")[1]
let cost = values[2]
console.log("Author: " + author)
console.log("Title: " + title)
console.log("\n")
// Crea un nuovo elemento span che sostituisce il link
const span = document.createElement('span');
span.textContent = title;
span.style.cursor = 'text';
span.onclick = () => {
// Utilizza il template literal per concatenare il titolo e autore
navigator.clipboard.writeText(`${title} - ${author}`)
.catch(console.error); // Non mostra alcun popup
};
// Sostituzione del link con lo span
link.replaceWith(span);
});
})()
No, thanks, the formatting is completely distorted, as shown in the screenshot. The initial userscript is fine for the result, but the slider carousel should not move when I select and copy the title and author.