安徽86刷TS专用

方便批量刷TS使用

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         安徽86刷TS专用
// @namespace    http://tampermonkey.net/
// @version      0.212
// @description  方便批量刷TS使用
// @author       You
// @match        http://ngwf.cs.cmos/ngwf/src/module/basesr/query/SrProblemProcessComplexQuery.html?historyFlag=ngwf_history_page
// @icon         https://www.google.com/s2/favicons?sz=64&domain=tampermonkey.net
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // 替换所有换行符的函数
    /*    function replaceAllNewLines(str) {
        let result = '';
        let parts = str.split('\n');
        for (let part of parts) {
            result += part.trim() + ' ';
        }
        return result.trim();
    }
*/
    function replaceAllNewLines(str) {
        let result = '';
        // Replace tabs with empty strings
        let noTabs = str.replace(/\t/g, '');
        let parts = noTabs.split('\n');
        for (let part of parts) {
            result += part.trim() + ' ';
        }
        return result.trim();
    }


    // 复制到剪贴板的函数
    function copyToClipboard(text) {
        var tempInput = document.createElement('textarea');
        document.body.appendChild(tempInput);
        tempInput.value = text;
        tempInput.select();
        document.execCommand('copy');
        document.body.removeChild(tempInput);
    }

    // 添加按钮的函数
    function addButton() {
        console.error("我yi2直行")
        var targetContainer = document.querySelector("div.footer-btns");
        console.error(targetContainer);
        if (targetContainer) {
            var newButton = document.createElement("input");
            newButton.type = "button";
            newButton.value = "复制";
            newButton.className = "footer-b-btn";
            newButton.id = "myCopy";

            // 为按钮添加点击事件监听器
            newButton.addEventListener('click', function() {
                var iframeDocument = document;//.getElementById('uiTabIframe').contentDocument;
                let dataString = "";

                iframeDocument.querySelectorAll("#target_table > div > div.new-table.new-table-bordered.new-table-scrollable-x > div.new-table.is-scrolling-left > div.new-table-wrapper.new-table-body-wrapper > table > tbody > tr").forEach((row) => {
                    let seventhTd = row.cells[7]; // 索引从0开始
                    let eleventhTd = row.cells[11]; // 索引从0开始

                    let seventhText = seventhTd ? replaceAllNewLines(seventhTd.textContent) : '';
                    let eleventhText = eleventhTd ? replaceAllNewLines(eleventhTd.textContent) : '';

                    dataString += seventhText + '\t' + eleventhText + '\n';
                });

                // 复制到剪贴板
                copyToClipboard(dataString);
                alert('内容已复制到剪贴板');
            });

            targetContainer.appendChild(newButton);
        } else {
            console.error("目标容器未找到");
        }
    }

    // 在文档加载完毕后添加按钮
    function go() {
        setTimeout(addButton, 5000); // 5000毫秒等于5秒
    }
    go();
    console.error("我yi直行")
})();