JVCare Transform

JVCare Transform nodes list

此腳本不應該直接安裝,它是一個供其他腳本使用的函式庫。欲使用本函式庫,請在腳本 metadata 寫上: // @require https://update.greasyfork.org/scripts/572639/1791073/JVCare%20Transform.js

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)




/* 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;
    }
}
*/