Secțiune de comentarii îmbunătățită a Miyoushe Genius Invokation TCG Plaza

Secțiune de comentarii îmbunătățită a Miyoushe Genius Invokation TCG Plaza. Pentru uz personal.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         访问米游社七圣召唤卡牌广场的评论区时在页面底部打印评论发出用户的主页URL
// @description  访问米游社七圣召唤卡牌广场的评论区时在页面底部打印评论发出用户的主页URL。自用。
// @name:en         Better comment section of Miyoushe Genius Invokation TCG Plaza
// @description:en  Better comment section of Miyoushe Genius Invokation TCG Plaza. Self-use.
// @name:ar          قسم تعليقات أفضل في ساحة بطاقات استدعاء العباقرة لـ Miyoushe TCG
// @description:ar    قسم تعليقات أفضل في ساحة بطاقات استدعاء العباقرة لـ Miyoushe TCG. للاستخدام الشخصي.
// @name:bg          Подобрен раздел за коментари на Miyoushe Genius Invokation TCG Plaza
// @description:bg    Подобрен раздел за коментари на Miyoushe Genius Invokation TCG Plaza. За лична употреба.
// @name:cs          Lepší sekce komentářů Miyoushe Genius Invokation TCG Plaza
// @description:cs    Lepší sekce komentářů Miyoushe Genius Invokation TCG Plaza. Pro vlastní potřebu.
// @name:da          Bedre kommentarfelt i Miyoushe Genius Invokation TCG Plaza
// @description:da    Bedre kommentarfelt i Miyoushe Genius Invokation TCG Plaza. Til eget brug.
// @name:de          Besserer Kommentarbereich der Miyoushe Genius Invokation TCG Plaza
// @description:de    Besserer Kommentarbereich der Miyoushe Genius Invokation TCG Plaza. Für den Eigengebrauch.
// @name:el          Καλύτερη ενότητα σχολίων του Miyoushe Genius Invokation TCG Plaza
// @description:el    Καλύτερη ενότητα σχολίων του Miyoushe Genius Invokation TCG Plaza. Για προσωπική χρήση.
// @name:eo          Pli bona komenta sekcio de Miyoushe Genius Invokation TCG Plaza
// @description:eo    Pli bona komenta sekcio de Miyoushe Genius Invokation TCG Plaza. Por propra uzo.
// @name:es          Mejor sección de comentarios de Miyoushe Genius Invokation TCG Plaza
// @description:es    Mejor sección de comentarios de Miyoushe Genius Invokation TCG Plaza. Para uso personal.
// @name:fi          Parempi kommenttiosio Miyoushe Genius Invokation TCG Plazalla
// @description:fi    Parempi kommenttiosio Miyoushe Genius Invokation TCG Plazalla. Oma käyttö.
// @name:fr          Meilleure section de commentaires de Miyoushe Genius Invokation TCG Plaza
// @description:fr    Meilleure section de commentaires de Miyoushe Genius Invokation TCG Plaza. Pour usage personnel.
// @name:fr-CA       Meilleure section de commentaires de Miyoushe Genius Invokation TCG Plaza
// @description:fr-CA    Meilleure section de commentaires de Miyoushe Genius Invokation TCG Plaza. Pour usage personnel.
// @name:he          קטע תגובות טוב יותר של Miyoushe Genius Invokation TCG Plaza
// @description:he    קטע תגובות טוב יותר של Miyoushe Genius Invokation TCG Plaza. לשימוש עצמי.
// @name:hr          Bolji odjeljak za komentare Miyoushe Genius Invokation TCG Plaza
// @description:hr    Bolji odjeljak za komentare Miyoushe Genius Invokation TCG Plaza. Za osobnu upotrebu.
// @name:hu          Jobb komment szekció a Miyoushe Genius Invokation TCG Plaza-n
// @description:hu    Jobb komment szekció a Miyoushe Genius Invokation TCG Plaza-n. Saját használatra.
// @name:id          Bagian komentar yang lebih baik dari Miyoushe Genius Invokation TCG Plaza
// @description:id    Bagian komentar yang lebih baik dari Miyoushe Genius Invokation TCG Plaza. Untuk penggunaan pribadi.
// @name:it          Sezione commenti migliorata di Miyoushe Genius Invokation TCG Plaza
// @description:it    Sezione commenti migliorata di Miyoushe Genius Invokation TCG Plaza. Per uso personale.
// @name:ja          miHoYo(miHoYo)天才召喚TCGプラザのコメント欄を改善
// @description:ja    miHoYo(miHoYo)天才召喚TCGプラザのコメント欄を改善します。個人的な使用。
// @name:ka          Miyoushe Genius Invokation TCG Plaza-ს კომენტარების უკეთესი განყოფილება
// @description:ka    Miyoushe Genius Invokation TCG Plaza-ს კომენტარების უკეთესი განყოფილება. პირადი მოხმარებისთვის.
// @name:ko          Miyoushe Genius Invokation TCG Plaza의 더 나은 댓글 섹션
// @description:ko    Miyoushe Genius Invokation TCG Plaza의 더 나은 댓글 섹션. 개인 사용.
// @name:nb          Bedre kommentarfelt på Miyoushe Genius Invokation TCG Plaza
// @description:nb    Bedre kommentarfelt på Miyoushe Genius Invokation TCG Plaza. For eget bruk.
// @name:nl          Betere commentaarsectie van Miyoushe Genius Invokation TCG Plaza
// @description:nl    Betere commentaarsectie van Miyoushe Genius Invokation TCG Plaza. Voor eigen gebruik.
// @name:pl          Lepsza sekcja komentarzy Miyoushe Genius Invokation TCG Plaza
// @description:pl    Lepsza sekcja komentarzy Miyoushe Genius Invokation TCG Plaza. Do użytku własnego.
// @name:pt-BR       Melhor seção de comentários da Miyoushe Genius Invokation TCG Plaza
// @description:pt-BR    Melhor seção de comentários da Miyoushe Genius Invokation TCG Plaza. Para uso próprio.
// @name:ro          Secțiune de comentarii îmbunătățită a Miyoushe Genius Invokation TCG Plaza
// @description:ro    Secțiune de comentarii îmbunătățită a Miyoushe Genius Invokation TCG Plaza. Pentru uz personal.
// @name:ru          Улучшенная секция комментариев Miyoushe Genius Invokation TCG Plaza
// @description:ru    Улучшенная секция комментариев Miyoushe Genius Invokation TCG Plaza. Для личного использования.
// @name:sk          Lepšia sekcia komentárov Miyoushe Genius Invokation TCG Plaza
// @description:sk    Lepšia sekcia komentárov Miyoushe Genius Invokation TCG Plaza. Pre vlastnú potrebu.
// @name:sr          Бољи одељак за коментаре Miyoushe Genius Invokation TCG Plaza
// @description:sr    Бољи одељак за коментаре Miyoushe Genius Invokation TCG Plaza. За личну употребу.
// @name:sv          Bättre kommentarsektion på Miyoushe Genius Invokation TCG Plaza
// @description:sv    Bättre kommentarsektion på Miyoushe Genius Invokation TCG Plaza. För eget bruk.
// @name:th          ส่วนความคิดเห็นที่ดีขึ้นของ Miyoushe Genius Invokation TCG Plaza
// @description:th    ส่วนความคิดเห็นที่ดีขึ้นของ Miyoushe Genius Invokation TCG Plaza สำหรับการใช้งานส่วนตัว
// @name:tr          Miyoushe Genius Invokation TCG Plaza'nın daha iyi yorum bölümü
// @description:tr    Miyoushe Genius Invokation TCG Plaza'nın daha iyi yorum bölümü. Kişisel kullanım için.
// @name:ug          Miyoushe Genius Invokation TCG مەيدانىنىڭ تېخىمۇ ياخشى باھا بۆلىكى
// @description:ug    Miyoushe Genius Invokation TCG مەيدانىنىڭ تېخىمۇ ياخشى باھا بۆلىكى. شەخسىي ئىشلىتىش.
// @name:uk          Покращений розділ коментарів Miyoushe Genius Invokation TCG Plaza
// @description:uk    Покращений розділ коментарів Miyoushe Genius Invokation TCG Plaza. Для особистого використання.
// @name:vi          Phần bình luận tốt hơn của Miyoushe Genius Invokation TCG Plaza
// @description:vi    Phần bình luận tốt hơn của Miyoushe Genius Invokation TCG Plaza. Sử dụng cá nhân.
// @name:zh          米游社七圣召唤卡牌广场更好的评论区
// @description:zh    米游社七圣召唤卡牌广场更好的评论区。自用。
// @name:zh-CN       米游社七圣召唤卡牌广场更好的评论区
// @description:zh-CN    米游社七圣召唤卡牌广场更好的评论区。自用。
// @name:zh-HK       米游社七聖召喚卡牌廣場更好的評論區
// @description:zh-HK    米游社七聖召喚卡牌廣場更好的評論區。自用。
// @name:zh-SG       米游社七圣召唤卡牌广场更好的评论区
// @description:zh-SG    米游社七圣召唤卡牌广场更好的评论区。自用。
// @name:zh-TW       米游社七聖召喚卡牌廣場更好的評論區
// @description:zh-TW    米游社七聖召喚卡牌廣場更好的評論區。自用。
// @namespace    http://tampermonkey.net/
// @version      0.2.6.1
// @author       aspen138
// @match        https://webstatic.mihoyo.com/ys/event/bbs-lineup-qskp/*
// @grant        none
// @run-at       document-start
// @icon         https://www.miyoushe.com/favicon.ico
// @license      GPL-3.0 License
// ==/UserScript==



function myCopeWtih(item) {
    var user_account_uid = item.user.account_uid;
    var user_nickname = item.user.nickname;
    var user_comment = item.content.text;
    var user_comment_reply_id = item.reply_id;

    // 创建一个新的 div 元素来显示信息
    var infoDiv = document.createElement("div");
    infoDiv.style.margin = "10px";
    infoDiv.style.padding = "5px";
    infoDiv.style.border = "1px solid #ddd";
    infoDiv.style.backgroundColor = "#f9f9f9";

    // 设置 div 的内容
    infoDiv.innerHTML = "<strong>用户昵称:</strong> " + user_nickname + "<br>" +
    "<strong>评论:</strong> " + user_comment + "<br>" +
    "<strong>用户主页URL:</strong> " +
    "<a href='https://webstatic.mihoyo.com/ys/event/bbs-lineup-qskp/index.html#/pc/author/" + user_account_uid + "' target='_blank'>" +
    "https://webstatic.mihoyo.com/ys/event/bbs-lineup-qskp/index.html#/pc/author/" + user_account_uid + "</a>";


    // 找到评论区的容器元素,或者你可以创建一个新的容器元素
    var commentsContainer = document.querySelector("#your-comments-container-selector");
    if (commentsContainer) {
        // 将 div 添加到评论区的容器中
        commentsContainer.appendChild(infoDiv);
    } else {
        // 如果没有找到评论区容器,就直接添加到 body 中
        document.body.appendChild(infoDiv);
    }

    // 查找所有 img 元素,并将其链接到相应的 user_account_uid 主页
    var imgElements = document.querySelectorAll('img.hyl-comment-avatar__img');
    imgElements.forEach(function(img) {
        var imgSrc = img.getAttribute('src');

        if ((imgSrc && imgSrc.includes(String(user_account_uid)))) {
            //console.log("imgSrc does include user_account_uid.");
            var userProfileUrl = "https://webstatic.mihoyo.com/ys/event/bbs-lineup-qskp/index.html#/pc/author/" + user_account_uid;

            // Check if the image is inside an anchor tag
            var parentElement = img.parentElement;
            if (parentElement.tagName.toLowerCase() === 'a') {
                // If the parent is an anchor, set its href and target
                parentElement.href = userProfileUrl;
                parentElement.target = "_blank";  // Open in a new tab
            } else {
                // If not, create an anchor and wrap the image inside it
                var anchor = document.createElement('a');
                anchor.href = userProfileUrl;
                anchor.target = "_blank";  // Open in a new tab

                // Insert the anchor before the img and then move the img inside it
                parentElement.insertBefore(anchor, img);
                anchor.appendChild(img);
            }
        }
    });


}

(function() {
    'use strict';

    // 重写 XMLHttpRequest 的 open 方法
    const originalXHROpen = XMLHttpRequest.prototype.open;
    XMLHttpRequest.prototype.open = function(method, url, async, user, pass) {
        this.addEventListener('readystatechange', function() {
            if (this.readyState === 4 && this.status === 200 &&
                (url.includes('api-takumi.mihoyo.com/bouleuterion_v2/v1/account/reply/list') || url.includes('api-takumi.mihoyo.com/bouleuterion_v2/v1/account/reply/floor/list'))
            ) {
                try {
                    // 解析响应的 JSON 数据
                    const responseJSON = JSON.parse(this.responseText);
                    console.log(responseJSON);
                    // 检查数据结构并提取 account_uid
                    if (responseJSON && responseJSON.data && responseJSON.data.list) {
                        console.log('提取的account_uid列表:');
                        console.log("responseJSON.data.list=",responseJSON.data.list);
                        // 遍历list数组
                        responseJSON.data.list.forEach(item => {
                            myCopeWtih(item);
                            item.sub_reply_list.forEach(subItem => {
                                myCopeWtih(subItem);
                            });
                        });
                    }
                } catch (e) {
                    console.error('Error parsing JSON:', e);
                }
            }
        }, false);
        originalXHROpen.call(this, method, url, async, user, pass);
    };
})();