// ==UserScript== // @name 超星字体解密 // @namespace wyn665817@163.com // @version 1.0.0 // @description 超星网页端字体解密,支持复制题目,兼容各类查题脚本 // @author wyn665817 // @match *://*.chaoxing.com/work/doHomeWorkNew* // @match *://*.edu.cn/work/doHomeWorkNew* // @require https://cdn.jsdelivr.net/gh/photopea/Typr.js@15aa12ffa6cf39e8788562ea4af65b42317375fb/src/Typr.min.js // @require https://cdn.jsdelivr.net/gh/photopea/Typr.js@f4fcdeb8014edc75ab7296bd85ac9cde8cb30489/src/Typr.U.min.js // @require https://cdn.jsdelivr.net/npm/blueimp-md5@2.19.0/js/md5.min.js // @resource Table https://www.forestpolice.org/ttf/2.0/table.json // @run-at document-end // @grant unsafeWindow // @grant GM_getResourceText // @license MIT // ==/UserScript== var $ = unsafeWindow.jQuery, Typr = Typr || window.Typr, md5 = md5 || window.md5; // 判断是否存在加密字体 var $tip = $('style:contains(font-cxsecret)'); if (!$tip.length) return; // 解析font-cxsecret字体 var font = $tip.text().match(/base64,([\w\W]+?)'/)[1]; font = Typr.parse(base64ToUint8Array(font))[0]; // 匹配解密字体 var table = JSON.parse(GM_getResourceText('Table')); var match = {}; for (var i = 19968; i < 40870; i++) { // 中文[19968, 40869] $tip = Typr.U.codeToGlyph(font, i); if (!$tip) continue; $tip = Typr.U.glyphToPath(font, $tip); $tip = md5(JSON.stringify($tip)).slice(24); // 8位即可区分 match[i] = table[$tip]; } // 替换加密字体 $('.font-cxsecret').html(function(index, html) { $.each(match, function(key, value) { key = String.fromCharCode(key); value = String.fromCharCode(value); html = html.replaceAll(key, value); }); return html; }).removeClass('font-cxsecret'); // 移除字体加密 function base64ToUint8Array(base64) { var data = window.atob(base64); var buffer = new Uint8Array(data.length); for (var i = 0; i < data.length; ++i) { buffer[i] = data.charCodeAt(i); } return buffer; }