JVCare Transform nodes list
Script này sẽ không được không được cài đặt trực tiếp. Nó là một thư viện cho các script khác để bao gồm các chỉ thị meta
// @require https://update.greasyfork.org/scripts/572639/1791073/JVCare%20Transform.js
/* TEST INJECT
document.body.insertAdjacentHTML("beforeend", `
<button
class="JvCare 45CBCBC0C22D1F1FCCCCCC194D43C3C5C4464B434F19424F4E1F simpleButton stretched-link"
data-foo="bar"
tabindex="0"
title="Profil"
style="position:fixed;bottom:24px;right:24px;z-index:99999;padding:10px 20px;cursor:pointer;">
<span>Mon profil</span>
</button>
`);
*/
function jvCake(cls) {
let base16 = '0A12B34C56D78E9F', lien = '', s = cls.split(' ')[1];
for (let i = 0; i < s.length; i += 2) {
lien += String.fromCharCode(base16.indexOf(s.charAt(i)) * 16 + base16.indexOf(s.charAt(i + 1)));
}
return lien;
}
function fixMessage(nodes) {
for (const spanJvcare of nodes.querySelectorAll(".JvCare")) {
const a = document.createElement("a");
for (const attr of spanJvcare.attributes) {
a.setAttribute(attr.name, attr.value);
}
a.setAttribute("href", jvCake(spanJvcare.className));
a.className = "xXx " + spanJvcare.className.split(" ").slice(2).join(" ");
a.append(...spanJvcare.childNodes);
spanJvcare.replaceWith(a);
}
}
//fixMessage(document.body);
/* VERSION outerHTML - fallback si replaceWith pose souci
function fixMessage(nodes) {
for (const spanJvcare of nodes.querySelectorAll(".JvCare")) {
const a = document.createElement("a");
for (const attr of spanJvcare.attributes) {
a.setAttribute(attr.name, attr.value);
}
a.setAttribute("href", jvCake(spanJvcare.className));
a.className = "xXx " + spanJvcare.className.split(" ").slice(2).join(" ");
a.innerHTML = spanJvcare.innerHTML;
spanJvcare.outerHTML = a.outerHTML;
}
}
*/