您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Sin Helper
当前为
此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.cn-greasyfork.org/scripts/471561/1239946/SinHelper.js
; (function () { window.sinHelper = { Cache: { }, /* 网络拦截相关 */ Xhr: { /** * */ inited: false, init: function () { if (this.inited === true) return; let oldSend = XMLHttpRequest.prototype.send, _this = this; XMLHttpRequest.prototype.send = function () { let xhr = this this.addEventListener("load", function () { if (xhr.readyState != 4 || xhr.status != 200) return; if (xhr.responseType != '' && xhr.responseType != 'text') return; xhr.requestData = arguments xhr.responseHeders = xhr.getAllResponseHeaders() xhr.responseData = function () { try { return JSON.parse(xhr.responseText) } catch (e) { return xhr.responseText } }(); _this.dispatchFetch(xhr) }) oldSend.apply(this, arguments); } this.inited = true; }, rules: {}, // pathname => function routes: [], // functions registRules: function (ruleName, ruleFunc) { if (typeof (ruleFunc) != 'function') { console.error("Xhr Rules 必须是可调用的函数", ruleName) return } this.rules[ruleName] = ruleFunc }, /* 调用注册的 pathname 处理函数 */ dispatchFetch: function (xhr) { let _this = this const url = new URL(xhr.responseURL) if (_this.rules[url.pathname]) { if (typeof (this.rules[url.pathname]) == 'function') { this.rules[url.pathname](xhr) } else { console.error("Xhr 处理函数错误:", url.pathname) } } else { _this.routes.forEach((route) => { if (typeof (route) == 'function') { route(xhr) } }) } } }, Url: { info: function (_url) { let urlInfo = new URL(_url) urlInfo['getParams'] = function(_key) { let _obj = Object.fromEntries(urlInfo.searchParams.entries()) if (_key) return _obj[_key] || null return _obj } return urlInfo }, getParams: function (_url, _key) { let urlStr = _url.split('?')[1] let urlSearchParams = new URLSearchParams(urlStr) let result = Object.fromEntries(urlSearchParams.entries()) if (_key) return result[_key] || null return result } }, /* 原生JS 下载Excel */ Excel: { 'trans2Base64': function (content) { return window.btoa(unescape(encodeURIComponent(content))); }, 'exportExcelFromFront': function (params) { let _this = this const { cellList, headerList, caption, exportName = 'exportName' } = params; const captionEle = caption ? `<caption>${caption}</caption>` : ''; // 表格标题 const headerEle = `<tr>${headerList?.map((item) => `<th>${item}</th>`)?.join('')}</tr>`; const cellEle = cellList ?.map((itemRow) => `<tr>${itemRow?.map((itemCell) => `<td>${itemCell}</td>`)?.join('')}</tr>`) ?.join(''); const excelContent = `${captionEle}${headerEle}${cellEle}`; let worksheet = '工作表1'; let excelFile = "<html xmlns:o='urn:schemas-microsoft-com:office:office' xmlns:x='urn:schemas-microsoft-com:office:excel' xmlns='http://www.w3.org/TR/REC-html40'>"; excelFile += '<head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head>'; excelFile += "<body><table width='10%' border='1'>"; excelFile += excelContent; excelFile += '</table></body>'; excelFile += '</html>'; const link = `data:application/vnd.ms-excel;base64,${_this.trans2Base64(excelFile)}`; const a = document.createElement('a'); a.download = `${exportName}.xlsx`; a.href = link; a.click(); } } }; })();