Greasy Fork

Greasy Fork is available in English.

Axure分享页面汉化脚本

Axure网页汉化

当前为 2023-09-14 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Axure分享页面汉化脚本
// @namespace    http://tampermonkey.net/
// @version      1.0.0
// @description  Axure网页汉化
// @author       alone
// @license MIT
// @match        *://*.axshare.com/*
// @grant        GM_addStyle
// @run-at       document-end
// @require http://greasyfork.icu/scripts/475259-elementgetter-alone/code/ElementGetter_Alone.js?version=1250106
// ==/UserScript==

var messages = {
    ".feedback-panel-empty-state__title": "无评论",
    ".feedback-panel-empty-state > div:nth-child(2)":
    "添加评论以反馈,提出疑问或改动建议。",
    ".feedback-item-confirm-delete-popup > .feedback-item-confirm-delete-popup__actions > button[type=button]":
    "取消",
    ".feedback-item-confirm-delete-popup > .feedback-item-confirm-delete-popup__actions > button[type=submit]":
    "删除",
    "#coreContents > div > div.form-title": "项目正在生成中...",
    "div.feedback-reply-container > div.ax-reply.feedback-thread-reply-container.ax-reply--editable > div > div > p":
    "",
    ".feedback-item-submit-edit > button[type=button]": "取消",
    ".feedback-item-submit-edit > button[type=submit]": "保存",
    ".feedback-panel-header-row__mark-as-read-button": "全部已读",
    "#interfaceControlFrameRight > div.ax-menu.share-button-container > div > button":
    "分享",
    "#interfaceControlFrameRight > div.ax-menu.share-button-container > div.ax-menu__content.ax-menu__content.share-button-dialog > div.toggle-current-page > span":
    "连接到本页面",
    "#interfaceControlFrameRight > div.ax-menu.share-button-container > div.ax-menu__content.ax-menu__content.share-button-dialog > div:nth-child(3) > div.share-url > div":
    "分享链接",
    "#interfaceControlFrameRight > div.ax-menu.share-button-container > div.ax-menu__content.ax-menu__content.share-button-dialog > div:nth-child(4) > div.share-url > div":
    "分享并打开页面和评论",
    ".ax-copy-to-clipboard > button": "复制",
    "#pageNotesEmptyState > div.emptyStateTitle": "本页面没有备注",
    "#pageNotesEmptyState > div.emptyStateContent":
    "在Axure RP中添加的备注会在这里展示",
    "#feedbackHost > div > div.feedback-panel-header > div > div.feedback-panel-header__mode > div > div.ax-menu__content.ax-menu__content.filter-content > div.filter-inner-content > div:nth-child(1) > label > span":
    "仅本页面",
    "#feedbackHost > div > div.feedback-panel-header > div > div.feedback-panel-header__mode > div > div.ax-menu__content.ax-menu__content.filter-content > div.filter-inner-content > div:nth-child(2) > label > span":
    "未读",
    "#feedbackHost > div > div.feedback-panel-header > div > div.feedback-panel-header__mode > div > div.ax-menu__content.ax-menu__content.filter-content > div.filter-inner-content > div:nth-child(3) > label > span":
    "已处理",
    "#feedbackHost > div > div.feedback-panel-header > div > div.feedback-panel-header__mode > div > div.ax-menu__content.ax-menu__content.filter-content > div.ax-feedback-pin-color-picker.filter-colors > div > button:nth-child(1)":
    "全",
};
var replace = [
    {
        key: "#interfaceControlFrameRight > div.ax-menu.share-button-container > div.ax-menu__content.ax-menu__content.share-button-dialog > div.share-note",
        search: "Copy the URL in the browser to share the current page and player configuration.",
        replace: "复制 URL 以共享当前页面和播放器设置。",
    },
    {
        key: "#interfaceControlFrameRight > div.ax-menu.share-button-container > div.ax-menu__content.ax-menu__content.share-button-dialog > div.share-note > div > span",
        search: " For a share link without the prototype player ",
        replace: "仅复制当前页面的分享链接",
    },
    {
        key: "#interfaceControlFrameRight > div.ax-menu.share-button-container > div.ax-menu__content.ax-menu__content.share-button-dialog > div.share-note > div > a",
        search: " click here ",
        replace: "点击这里",
    },
    {
        key: "#changePageInstructions",
        search: "Use",
        replace: "使用",
    },
    {
        key: "#changePageInstructions",
        search: "and",
        replace: "和",
    },
    {
        key: "#changePageInstructions",
        search: "keys",
        replace: "按键",
    },
    {
        key: "#changePageInstructions",
        search: "to move between pages",
        replace: "在页面间切换",
    },
    {
        key: "div.feedback-issue-replies-summary > span",
        search: /.+/,
        replace: "查看回复",
    },
    {
        key: ".ax-form-errors__error",
        search: " Please enter text ",
        replace: "请输入内容",
    },
    {
        key: ".feedback-item-confirm-delete-popup > .feedback-item-confirm-delete-popup__question",
        search: " Are you sure? ",
        replace: "确定删除?",
    },
    {
        key: ".feedback-reply-actions > div > .feedback-reply-actions__mark-resolved > button",
        search: "Post and Resolve",
        replace: "回复并处理",
    },
    {
        key: ".feedback-reply-actions > div > .feedback-reply-actions__mark-resolved > button",
        search: " Post and Unresolve ",
        replace: "回复并取消处理",
    },
    {
        key: ".feedback-reply-actions > div > div:nth-child(1) > button",
        search: "Post",
        replace: "回复",
    },
    {
        key: ".feedback-commenting-as",
        search: " Commenting as ",
        replace: "",
    },
    {
        key: "#showHotspotsOption",
        search: "Show Hotspots",
        replace: "显示热点",
    },
    {
        key: "#showNotesOption",
        search: "Show Note Markers",
        replace: "显示笔记",
    },
    {
        key: "#showCommentsOption",
        search: "Show Comments",
        replace: "显示评论",
    },
    {
        key: "#showHotspotsOption",
        search: "Show Hotspots",
        replace: "显示热点",
    },
    {
        key: "#interfaceScaleListContainer > div:nth-child(1)",
        search: "Default Scale",
        replace: "默认比例",
    },
    {
        key: "#interfaceScaleListContainer > div:nth-child(2)",
        search: "Scale to Width",
        replace: "适合宽度",
    },
    {
        key: "#interfaceScaleListContainer > div:nth-child(3)",
        search: "Scale to Fit",
        replace: "适合大小",
    },

    /*
    ,{
        "key":"ul.ax-list > li.ax-list-item > div:nth-child(1)",
        "search":"Resolve",
        "replace":"标记为处理"
    },{
        "key":"ul.ax-list > li.ax-list-item > div:nth-child(2)",
        "search":" Mark as Unread ",
        "replace":"标记为未读"
    },{
        "key":"ul.ax-list > li.ax-list-item:last-child",
        "search":" Copy Link ",
        "replace":"复制链接"
    },
    */
];

var commentClassName = "div.feedback-issue-options > span";
function Work() {
    Object.entries(messages).map(([k, v]) => {
        /*elmGetter.get(k).then(div => {
        div.innerText = v;
       });*/
        elmGetter.each(k, document, (reply) => {
            debugger;
            reply.innerText = v;
        });
    });
    replace.forEach((v) => {
        elmGetter.each(v.key, document, (reply) => {
            reply.innerHTML = reply.innerHTML.replace(v.search, v.replace);
        });
    });

    // 评论时间
    elmGetter.each(commentClassName, document, (reply) => {
        if (!!reply.title) {
            var timeText = reply.title || "";
            var date = new Date(Date.parse(timeText));
            var formattedDate =
                date.getFullYear() +
                "/" +
                (date.getMonth() + 1) +
                "/" +
                date.getDate() +
                " " +
                date.getHours() +
                ":" +
                date.getMinutes() +
                ":" +
                date.getSeconds();
            reply.innerText = formattedDate;
        }
    });

    // 评论时间
    elmGetter.each(".feedback-item-content-date > span", document, (reply) => {
        if (!!reply.title) {
            var timeText = reply.title || "";
            var date = new Date(Date.parse(timeText));
            var formattedDate =
                date.getFullYear() +
                "/" +
                (date.getMonth() + 1) +
                "/" +
                date.getDate() +
                " " +
                date.getHours() +
                ":" +
                date.getMinutes() +
                ":" +
                date.getSeconds();
            reply.innerText = formattedDate;
        }
    });

    // 处理评论时间
    elmGetter.each(
        "#feedbackHost > div > div.feedback-panel-issues.feedback-panel__issues > div > div:nth-child(n) > div.feedback-issue__resolved-mark",
        document,
        (reply) => {
            const message = reply.querySelector("div:nth-child(1)");
            const time = reply.querySelector("div:nth-child(2)");
            if (message) {
                message.innerText = message.innerText.replace(
                    /Resolved by (.+)/,
                    "已由 $1 处理"
                );
            }
            if (time) {
                var timeText = time.innerText;
                var date = new Date(Date.parse(timeText));
                var formattedDate =
                    date.getFullYear() +
                    "/" +
                    (date.getMonth() + 1) +
                    "/" +
                    date.getDate();
                time.innerText = formattedDate;
            }
        }
    );
    //筛选选项加样式
    elmGetter.each(".color-list > button", document, (reply) => {
        if (!!reply.style) {
            reply.style.width = "16px";
            reply.style.height = "16px";
        }
    });
    //筛选选项加样式
    elmGetter.each(
        "div.ax-reply.feedback-thread-reply-container.ax-reply--editable > div > div > p",
        document,
        (reply) => {
            if (!!reply) {
                reply.dataPlaceholder = "";
            }
        }
    );
    // 有状态的按钮切换时修改文字
    // 配置 MutationObserver 监听 class 属性的变化
    const config = { attributes: true, attributeFilter: ["class"] };

    // 添加评论按钮
    elmGetter
        .get("#feedbackHost > div > div.feedback-panel-add-comment > button")
        .then((button) => {
        if (
            button.className ==
            "feedback-panel-add-comment-button ax-button ax-button--default ax-button--block ax-button--large"
        ) {
            button.textContent = "添加评论";
        } else {
            button.textContent = "完成";
        }
        // 创建 MutationObserver 实例
        const observer = new MutationObserver((mutationsList) => {
            // 遍历每个发生变化的属性
            for (let mutation of mutationsList) {
                if (
                    mutation.type === "attributes" &&
                    mutation.attributeName === "class"
                ) {
                    // 当 class 属性发生变化时,修改按钮内容
                    if (
                        button.className ==
                        "feedback-panel-add-comment-button ax-button ax-button--default ax-button--block ax-button--large"
                    ) {
                        button.textContent = "添加评论";
                    } else {
                        button.textContent = "完成";
                    }
                }
            }
        });

        // 开始监听按钮的变化
        observer.observe(button, config);
    });

    //评论的选项菜单 todo
    elmGetter.get(".feedback-issue__body > div:nth-child(1)").then((button) => {
        if (button.className == "ax-reply ax-reply--readonly") {
            if (
                button.parentElement?.parentElement?.children[0]?.children[2]
                ?.children[0]?.children[0]?.childElementCount > 1
            ) {
                button.parentElement.parentElement.children[0].children[2].children[0].children[0].children[1].children[0].children[1].textContent =
                    "标记为未读";
            }
        }
        // 创建 MutationObserver 实例
        const observer = new MutationObserver((mutationsList) => {
            // 遍历每个发生变化的属性
            for (let mutation of mutationsList) {
                if (
                    mutation.type === "attributes" &&
                    mutation.attributeName === "class"
                ) {
                    // 当 class 属性发生变化时,修改按钮内容
                    if (button.className == "ax-reply ax-reply--readonly") {
                        if (
                            button.parentElement?.parentElement?.children[0]
                            ?.children[2]?.children[0]?.children[0]
                            ?.childElementCount > 1
                        ) {
                            button.parentElement.parentElement.children[0].children[2].children[0].children[0].children[1].children[0].children[1].textContent =
                                "标记为未读";
                        }
                    }
                }
            }
        });

        // 开始监听按钮的变化
        observer.observe(button, config);
    });

    GM_addStyle(`
	     ::-webkit-scrollbar {
	      width: 8px;
	      height: 8px;
	     }
	     ::-webkit-scrollbar-thumb {
	      background: #CCC;
	      border-radius: 0.25em;
	     }
	     ::-webkit-scrollbar-track {
	      background: transparent;
	     }
        ::-webkit-scrollbar-thumb:hover {
          width: 12px;
          background: #AAA;  // 设置滚动条滑块鼠标悬停颜色
        }
    `);
}
(function () {
    "use strict";
    Work();
})();