Quicker讨论区帖子页面优化

优化Quicker讨论区帖子的评论显示,使其结构更加清晰

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Quicker讨论区帖子页面优化
// @namespace    http://tampermonkey.net/
// @version      0.5
// @description  优化Quicker讨论区帖子的评论显示,使其结构更加清晰
// @author       Cesaryuan
// @update       2022-05-07 1.支持动作评论 2.高亮专业版用户 3.修复bug
// @update       2022-05-09 1.修复bug
// @match        https://getquicker.net/QA/Question/*
// @match        https://getquicker.net/Common/Topics/ViewTopic/*
// @grant        none
// @license      MIT
// @homepage     https://greasyfork.org/zh-CN/scripts/444527-quicker%E8%AE%A8%E8%AE%BA%E5%8C%BA%E5%B8%96%E5%AD%90%E9%A1%B5%E9%9D%A2%E4%BC%98%E5%8C%96/admin
// ==/UserScript==

(function () {
    "use strict";
    var url = window.location.href;
    // if (url.indexOf("https://getquicker.net/QA/Question/") != -1) {
        var elemets = document.querySelectorAll('.child-comment > .flex-grow-1')
        elemets.forEach(element => {
            /** @type {HTMLSpanElement} */
            var header = null;
            if(element.querySelector('.user-content:first-child')) {
                header = document.createElement('span');
                element.prepend(header);
            } else {
                /** @type {HTMLSpanElement} */
                header = element.children[0];
            }
            var replyingContainerSpan = element.children[2];
            var replying = replyingContainerSpan.querySelector('a');
            var userContent = element.querySelector('.user-content');
            header.prepend(replying);
            // add class
            header.classList.add('comment-header');

            // element.insertBefore(userContent, replyingContainerSpan);
            header.append(replyingContainerSpan);
            userContent.style.display = 'block';
        });

        injectStyle(`
            .child-comment {
                border-bottom: 4px solid #ededed;
            }
            .child-comment:nth-last-child(2) {
                border-bottom: 0px solid #ededed;
            }
            .comment-header {
                font-size: 14px;
                font-weight: 600;
            }
        `);
    // }


    function injectStyle(css) {
        var style = document.createElement("style");
        style.type = "text/css";
        style.innerHTML = css;
        document.head.appendChild(style);
    }
})();