Free javascript Hosting


getcopartcardescription.js

Uploaded on Jan 15 2022 16:18 by victor.pivnenko

(() => {
const getNodeValue = (selector) => {
const node = document.querySelector(selector);
if (node) {
return node.textContent.replace(/\n/g, "").trim();
}

return "n/a";
};

const copyToClipboard = (text) => {
const hiddenInput = document.createElement("textarea");
hiddenInput.style = "position: absolute; opacity: 0; pointer-events: none;";
hiddenInput.tabIndex = "-1";
hiddenInput.setAttribute("aria-hidden", "true");
hiddenInput.value = text;
document.body.appendChild(hiddenInput);
hiddenInput.select();
document.execCommand("copy");
document.body.removeChild(hiddenInput);
};

const join = (arr, delimiter) => arr.filter((item) => item).join(delimiter);

const stats = [];

// Car model
stats.push(getNodeValue(".lot-details-heading .title"));
// Odometer
stats.push(getNodeValue("[data-uname='lotdetailOdometervalue']"));
// Damage
stats.push(
join(
[
getNodeValue("[data-uname='lotdetailPrimarydamagevalue']"),
getNodeValue("[data-uname='lotdetailSecondarydamagevalue']"),
],
" | "
)
);
// Color
stats.push(getNodeValue("[data-uname='lotdetailColorvalue']"));
// Estimated retail value
stats.push(getNodeValue("[data-uname='lotdetailEstimatedretailvalue']"));

copyToClipboard(stats.join("\n"));
})();

Back to list