您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
https://github.com/JavaZeroo
当前为
// ==UserScript== // @name Export Student Grades to Merged CSV // @namespace http://tampermonkey.net/ // @version 1.0 // @description https://github.com/JavaZeroo // @author JavaZero // @match http://jxgl.dlut.edu.cn/student/for-std/grade/sheet/* // @grant none // @license MIT // ==/UserScript== (function() { 'use strict'; function addButton() { const btn = document.createElement("button"); btn.innerHTML = "导出当前页面所有成绩"; btn.onclick = exportAllGradesToMergedCSV; const targetDiv = document.querySelector('.selectize-input.items.full.has-options.has-items'); if (targetDiv) { targetDiv.parentNode.insertBefore(btn, targetDiv.nextSibling); } else { document.body.appendChild(btn); } } function tableToCSV(table, tableName, includeHeader) { let csv = []; for (let i = 0, row; row = table.rows[i]; i++) { let rowData = []; // Add a new column for the table name (semester name) if (i === 0) { rowData.push(JSON.stringify("学期")); // Add header for the new column } else { rowData.push(JSON.stringify(tableName)); } for (let j = 0, col; col = row.cells[j]; j++) { const courseNameDiv = col.querySelector('.course-name'); const cellText = courseNameDiv ? courseNameDiv.innerText : col.innerText; rowData.push(JSON.stringify(cellText.replace(/\n/g, ' '))); } // Skip the header row for subsequent tables if (i === 0 && !includeHeader) { continue; } csv.push(rowData.join(',')); } return csv.join('\n'); } function exportAllGradesToMergedCSV() { const tables = document.querySelectorAll("table"); if (tables.length === 0) { alert("没有找到表格!"); return; } let all_csv = []; let includeHeader = true; // Include header only for the first table tables.forEach((table, index) => { const rows = table.querySelectorAll('tr'); if (rows.length <= 1) { return; } const semesterNameTag = table.closest('div').querySelector('.semesterName'); const tableName = semesterNameTag ? semesterNameTag.innerText : "表格 " + (index + 1); const csv = tableToCSV(table, tableName, includeHeader); all_csv.push(csv); includeHeader = false; // Exclude header for subsequent tables }); const merged_csv = all_csv.join('\n'); const blob = new Blob(["\ufeff" + merged_csv], { type: 'text/csv;charset=utf-8;' }); const url = URL.createObjectURL(blob); const link = document.createElement("a"); link.setAttribute("href", url); link.setAttribute("download", "所有成绩.csv"); link.style.visibility = 'hidden'; document.body.appendChild(link); link.click(); document.body.removeChild(link); } setTimeout(addButton, 1000); })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址