Greasy Fork

Greasy Fork is available in English.

weihl_test

open one's eyes to see the world.

当前为 2024-10-15 提交的版本,查看 最新版本

// ==UserScript==
// @name         weihl_test
// @namespace    http://tampermonkey.net/
// @version      V0.1
// @description  open one's eyes to see the world.
// @author       weihule
// @match        https://pmos.sd.sgcc.com.cn:18080/trade/main/index.do*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=google.com
// @grant        none
// @license      AGPL-3.0
// ==/UserScript==

(function() {
    'use strict';
    window.addEventListener('load', function() {
        document.getElementsByClassName('nav-item modulemenu')[2].querySelector('a').click()

        setTimeout(function() {
            let iframe = document.getElementsByClassName('container-fluid')[2].querySelector('iframe');
            let iframeDocument = iframe.contentDocument || iframe.contentWindow.document;
            dialog_header = iframeDocument.getElementsByClassName('modal-dialog modal-lg')[1].getElementsByClassName('modal-content')[0].getElementsByClassName('modal-header')[0];
            dialog_header.getElementsByClassName('close')[0].click();
        }, 3000);

        console.log('la la la ')

        // 定位弹出窗口的x控件并点击
        // let iframe = document.getElementsByClassName('container-fluid')[2].querySelector('iframe');
        // let iframeDocument = iframe.contentDocument || iframe.contentWindow.document;
        // dialog_header = iframeDocument.getElementsByClassName('modal-dialog modal-lg')[1].getElementsByClassName('modal-content')[0].getElementsByClassName('modal-header')[0]
        // dialog_header.getElementsByClassName('close')[0].click()

        // 定位数据表单控件
        document.getElementsByClassName('dataTables_scroll')[0]

        const table = document.querySelector('.dataTables_scrollBody table');

        const headers = [];
        const headerCells = table.querySelectorAll('thead th');
        headerCells.forEach(cell => {
            headers.push(cell.textContent.trim());
        });
    
        const data = [];
        const rows = table.querySelectorAll('tbody tr');
        rows.forEach(row => {
            const rowData = [];
            const cells = row.querySelectorAll('td');
            cells.forEach(cell => {
                rowData.push(cell.textContent.trim());
            });
            data.push(rowData);
        });
    
        console.log('表头:', headers);
        console.log('数据:', data);
        
    });
})();