安徽86刷TS专用

方便批量刷TS使用

目前為 2024-03-30 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         安徽86刷TS专用
// @namespace    http://tampermonkey.net/
// @version      0.21
// @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直行")
})();