ffxiv.ariyala.com 小工具

ffxiv.ariyala.com 自动标记所选项 + 魔晶石镶嵌界面快速选择魔晶石功能

目前为 2019-12-30 提交的版本。查看 最新版本

// ==UserScript==
// @name           ffxiv.ariyala.com 小工具
// @name:en        ffxiv.ariyala.com Tool
// @description    ffxiv.ariyala.com 自动标记所选项 + 魔晶石镶嵌界面快速选择魔晶石功能
// @description:en ffxiv.ariyala.com Auto mark the selection + Quickly selection on Materia Melding
// @version        1.0.3
// @match          *://ffxiv.ariyala.com/*
// @run-at         document-start
// @grant          unsafeWindow
// @author         AnnAngela
// @namespace      https://gf.qytechs.cn/users/129402
// @mainpage       https://gf.qytechs.cn/zh-CN/scripts/394458
// @supportURL     https://gf.qytechs.cn/zh-CN/scripts/394458/feedback
// @license        GNU General Public License v3.0 or later
// @compatible     chrome
// ==/UserScript==
/* eslint-disable no-magic-numbers */
/* global unsafeWindow */
"use strict";
unsafeWindow.addEventListener("load", () => {
    function loop() {
        if (!unsafeWindow.toolkit || !unsafeWindow.toolkit.currentContentCallback || !unsafeWindow.toolkit.currentContentCallback.attributeNames || !Array.isArray(unsafeWindow.toolkit.currentContentCallback.attributeNames)) {
            return setTimeout(loop, 100);
        }
        const i18n = {
            CRT: "暴击",
            DHT: "直击",
            SPS: "咏唱",
            SKS: "技速",
            DET: "信念",
            TEN: "坚韧",
            PIE: "信仰",
            clear: "清空",
        };
        const attributes = unsafeWindow.toolkit.currentContentCallback.attributeNames.filter((n) => i18n.hasOwnProperty(n));
        const uiLangIsChinese = unsafeWindow.navigator.language.startsWith("zh");

        const doc = unsafeWindow.document;
        const style = doc.createElement("style");
        style.innerText = ".materiaQuicklySelect { text-align: left; } .materiaQuicklySelect a { margin-left: 1em; } .materiaQuicklySelect a:first-child, .materiaQuicklySelect br + a { margin-left: 0; }";
        doc.head.appendChild(style);
        function check() {
            if (!doc.querySelector(".markAllSelection")) {
                Array.from(doc.querySelectorAll('[id^="classJobsOptionsLine"]')).forEach((n) => {
                    const button = doc.createElement("a");
                    button.classList.add("markAllSelection");
                    button.classList.add("author");
                    button.innerText = "Mark ALL selection";
                    n.append(" • ");
                    n.appendChild(button);
                    button.addEventListener("click", () => {
                        Array.from(doc.querySelectorAll('#groupTables .inventoryCell[displaystate="inventory"]')).forEach((p) => {
                            const n = p.querySelector(".inventoryToggleButton");
                            if (p.classList.contains("selected") && !n.classList.contains("selected") || !p.classList.contains("selected") && n.classList.contains("selected")) {
                                n.click();
                            }
                        });
                    });
                });
            }
        }
        check();
        const observerForMarkAllSelection = new MutationObserver(check);
        observerForMarkAllSelection.observe(unsafeWindow.document.querySelector("#classJobsOptionsLineA"), {
            childList: true,
            characterData: true,
            subtree: true,
        });
        observerForMarkAllSelection.observe(unsafeWindow.document.querySelector("#classJobsOptionsLineB"), {
            childList: true,
            characterData: true,
            subtree: true,
        });
        if (doc.querySelector('[id^="materiaSelect"]')) {
            Array.from(doc.querySelectorAll('select[id^="materiaSelect"]')).forEach((n, i) => {
                const levels = i < 2 ? [8] : i === 2 ? [8, 6] : [8, 7];
                if (!n.parentElement.querySelector(".materiaQuicklySelect")) {
                    const div = doc.createElement("div");
                    div.classList.add("materiaQuicklySelect");
                    levels.forEach((level, index) => {
                        if (index !== 0) {
                            div.innerHTML += "<br>";
                        }
                        div.innerHTML += attributes.map((attr) => `<a href="javascript:void(0);" title="${uiLangIsChinese ? i18n[attr] : `${attr}:`}${level}" data-value="CRT:${level - 1}">${uiLangIsChinese ? i18n[attr] : `${attr}:`}${level}</a>`).join(" ");
                        if (index === levels.length - 1) {
                            div.innerHTML += ` <a href="javascript:void(0);" title="${uiLangIsChinese ? i18n.clear : "Clear"}" data-value="">${uiLangIsChinese ? i18n.clear : "Clear"}</a>`;
                        }
                    });
                    n.after(div);
                    Array.from(div.querySelectorAll("a")).forEach((ele) => {
                        ele.addEventListener("click", () => {
                            n.value = ele.dataset.value;
                            unsafeWindow.uiManager.currentOverlayWindow.updateMateriaWindowTable();
                        });
                    });
                }
            });
        }
        const observerForMateriaSelect = new MutationObserver(() => {
            Array.from(doc.querySelectorAll('select[id^="materiaSelect"]')).forEach((n) => {
                if (n.parentElement.querySelector(".materiaQuicklySelect")) {
                    n.parentElement.querySelector(".materiaQuicklySelect").style = `display: ${n.disabled ? "none" : "block"};`;
                }
            });
        });
        observerForMateriaSelect.observe(unsafeWindow.document.querySelector("#materiaWindow"), {
            attributes: true,
            attributeFilter: ["style"],
        });
    }
    loop();
});

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址