ageverification.dev — Abbreviation Helper

Document is almost unreadable with all its acronyms and abbreviations

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         ageverification.dev — Abbreviation Helper
// @namespace    fabulous.cupcake.jp.net
// @version      2025.07.27.3
// @description  Document is almost unreadable with all its acronyms and abbreviations
// @author       FabulousCupcake
// @match        https://ageverification.dev/*
// @grant        none
// ==/UserScript==

const ABBREVS = [
    ["AP", "Attestation Provider"],
    ["ARF", "Architecture and Reference Framework"],
    ["AV app", "Age Verification App"],
    ["AVI", "Age Verification App Instance"],
    ["AVAP", "Age Verification App Provider"],
    ["CA", "Certificate Authority"],
    ["DG CNECT", "Directorate General Network, Content and Technology"],
    ["eIDAS", "Electronic Identification, Authentication and Trust Services"],
    ["EU", "European Union"],
    ["EUDI", "European Digital Identity"],
    ["EUDIW /EUDI Wallet", "European Digital Identity Wallet"],
    ["LoA", "Level of Assurance"],
    ["U", "User"],
    ["RP", "Relying Party"],
    ["T-Scy", "Scytáles & T-Systems Age consortium"],
    ["WB", "Web Browser (or web app)"],
    ["ZKP", "Zero Knowledge Proof"],

    ["ETSI", "European Telecommunications Standards Institute"],
];

const applyAbbreviationHints = (string) => {
    let result = string;
    ABBREVS.forEach(a => {
        const [abbr, title] = a;
        const el = `<abbr title="${title}">${abbr}</abbr>`;
        const pattern = new RegExp(`([ (])${abbr}(s?[ .,;?!)])`, "g");
        result = result.replaceAll(pattern, `$1${el}$2`);
    });

    return result;
}

const processAllParagraphs = () => {
    const paragraphs = document.querySelectorAll(`article p`);
    paragraphs.forEach(p => {
        const walker = document.createTreeWalker(p, NodeFilter.SHOW_TEXT);
        while (true) {
            const node = walker.nextNode();
            if (!node) break;

            const el = applyAbbreviationHints(node.nodeValue);
            node.parentNode.insertAdjacentHTML("afterbegin", el);
            node.remove();
        }
    });
}

const main = () => {
    processAllParagraphs();
}

main();