// ==UserScript== // @name 爱问答助手 // @namespace aiask/askHelperd // @version 1.0.9 // @author aiask // @description 全平台问答助手,一键获取整个页面的试题答案,目前支持【超星学习通、知到智慧树、国开、广开】,更多平台开发中... // @license MIT // @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAAAXNSR0IArs4c6QAAAHVQTFRFR3BMgICBQD8/QUVHQ0ZIRUhKX2FiQD8/Tk1NP0VJPzs7Pz8/QD4+UE9QQD8/PVlnQD8/M6vj////n5+fN5C60NDQSl9qOXWSZL/qTFNXzOr4QWl8yMjItLS02traOIOnNZzN6OfnlJeZ9/f3PYGgpdrzmdXxgSBJqQAAABB0Uk5TAP5E6vys+7/Q0RhsfPFV/OwFarYAAAEESURBVHjapdHrboMgGIBhUHBaD/sAlTE8VOt2/5c4GlBMRZOl7w8j+kQQ0FaVwbG48IDq+piMPcgkO1bD/8DXvhD4/fb9ePDuGiqa2krV7pO1AxSLYIl2ABoeTLSvYMBi4N0sphOAlVaqg1aTPggmZYYaFvNMBYGQz6G6m2vbhEBvF81MxALFTDpbQQd3ZhvBgxqiFfBEO/CJ7ZxkNPcUbWBwn5DJw4KSsJHcHPCTLLDuQxpLkiMLbAIWJs1wBRVkyAFXT7Sa+AYQjTywNfOD74DNA18I9Ifjpg7Es/3Jj5eKyIEcBgNwhk5L8XMPonMQQcfNhBfRpIfbFbiRskCX5enFyz/07TSN9vGxKwAAAABJRU5ErkJggg== // @match *://*.asklib.com/* // @match *://*.chaoxing.com/* // @match *://lms.ouchn.cn/* // @match *://tongyi.aliyun.com/qianwen/* // @match *://chatglm.cn/* // @match *://*.zhihuishu.com/* // @match *://course.ougd.cn/* // @match *://moodle.syxy.ouchn.cn/* // @match *://moodle.qwbx.ouchn.cn/* // @match *://elearning.bjou.edu.cn/* // @match *://whkpc.hnqtyq.cn:5678/* // @match *://study.ouchn.cn/* // @match *://*.taobao.com/* // @match *://*.tmall.com/* // @match *://chaoshi.detail.tmall.com/* // @match *://*.tmall.hk/* // @match *://*.liangxinyao.com/* // @match *://*.jd.com/* // @match *://*.jd.hk/* // @match *://*.yiyaojd.com/* // @match *://*.vip.com/* // @match *://*.vipglobal.hk/* // @exclude *://login.taobao.com/* // @exclude *://login.tmall.com/* // @exclude *://uland.taobao.com/* // @exclude *://pages.tmall.com/* // @exclude *://wq.jd.com/* // @require https://cdn.bootcdn.net/ajax/libs/vue/3.4.21/vue.global.prod.js // @require https://cdn.bootcdn.net/ajax/libs/vue-demi/0.14.6/index.iife.js // @require data:application/javascript,%3Bwindow.Vue%3DVue%3B // @require https://cdn.bootcdn.net/ajax/libs/element-plus/2.6.3/index.full.min.js // @require https://cdn.bootcdn.net/ajax/libs/jquery/3.7.1/jquery.min.js // @require https://cdn.bootcdn.net/ajax/libs/highlight.js/11.9.0/highlight.min.js // @require https://cdn.bootcdn.net/ajax/libs/markdown-it/13.0.1/markdown-it.min.js // @resource ElementPlus https://cdn.bootcdn.net/ajax/libs/element-plus/2.6.3/index.min.css // @resource ttf https://www.forestpolice.org/ttf/2.0/table.json // @require https://cdn.bootcdn.net/ajax/libs/jquery.qrcode/1.0/jquery.qrcode.min.js // @connect 127.0.0.1 // @connect 62.234.36.191 // @connect icodef.com // @connect muketool.com // @connect azkou.cn // @connect 82.157.105.20 // @grant GM_addStyle // @grant GM_getResourceText // @grant GM_getValue // @grant GM_info // @grant GM_setValue // @grant GM_xmlhttpRequest // @grant unsafeWindow // @run-at document-start // @antifeature payment 第三方接口存在付费项 // ==/UserScript== (e=>{if(typeof GM_addStyle=="function"){GM_addStyle(e);return}const i=document.createElement("style");i.textContent=e,document.head.append(i)})(" button[data-v-906f2363]{margin:10px}.aah_plat span[data-v-906f2363]{margin:5px}.el-row{margin-bottom:20px}.el-row:last-child{margin-bottom:0}.el-col{border-radius:4px}.grid-content{border-radius:4px;min-height:36px}.aah_btn{width:100%}.aah_title img{max-width:100%;height:auto;overflow:hidden}.aah_title{overflow:hidden;text-overflow:ellipsis;display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;margin-bottom:10px}.aah_active{box-shadow:0 0 5px #0af}.aah_password input{--el-input-inner-height: calc(var(--el-input-height, 32px) - 2px);background:none;border:none;box-sizing:border-box;color:var(--el-input-text-color, var(--el-text-color-regular));flex-grow:1;font-size:inherit;height:var(--el-input-inner-height);line-height:var(--el-input-inner-height);outline:none;padding:0;width:100%;margin:auto}.el-input__inner{border:none!important;margin:auto;--el-input-inner-height: calc(var(--el-input-height, 32px) - 2px);background:none;border:none;box-sizing:border-box;color:var(--el-input-text-color, var(--el-text-color-regular));flex-grow:1;font-size:inherit;height:var(--el-input-inner-height);line-height:var(--el-input-inner-height);outline:none;padding:0;width:100%}.aah_bomHet50{padding:13px 0 13px 10px}.aah_bomHet50 span{display:inline-block;line-height:24px;padding-left:14px;color:#a8a8b3}.aah_bomHet50 span i{display:inline-block;width:10px;height:10px;border:1px solid #DBDFE9;border-radius:2px;vertical-align:middle;margin-right:4px;margin-top:-2px}.aah_bomHet50 .dq i{background-color:#ecf5ff;box-shadow:0 0 5px #0af}.aah_bomHet50 .yp i{background-color:#f0f9eb;border-color:#409eff}.aah_bomHet50 .wp i{background-color:#fef0f0;border-color:#f56c6c}.aah_wrapper>div{pointer-events:none}.aah_wrapper>div>div{pointer-events:none}.el-dialog{pointer-events:auto}.minimized-dialog img{pointer-events:auto;width:50px!important;z-index:999;position:fixed;bottom:0;right:0}.aah_breadcrumb{margin-bottom:20px} "); (function (vue, ElementPlus, $, markdownit, hljs) { 'use strict'; let base={ href:location.href, css:`.coupon-box{margin-top:5px;align-items: center;background-image: linear-gradient(150deg, rgb(255, 153, 0), rgb(255, 102, 153));max-width: 380px;color: white;border-radius: 6px;} .coupon-center{display:flex;} .coupon-money{display: flex;align-items: center;justify-content: center;height:70px} .coupon-info{display: flex;flex-direction: column;justify-content: center;min-width: 170px;line-height: 20px;} .coupon-btn{justify-content: center;align-items: center;display: flex;height:70px} .coupon-btn a{display: flex;font-size: 20px;color: white;padding: 5px; } .coupon-btn a:hover{color:rgb(255,153,0)} .fsize30{font-size:30px} .fsize22{font-size:22px} .mg10{margin-top:10px} .mg20{margin-top:20px} `, warp:['.gl-warp >li','.mc .clearfix >li','#J-superkillGoodslist >li','.more2_list >li','.pd_common_wrap'], searchList:[], searchTempList:[], searchKey:0, num:5, getValue(name) { return GM_getValue(name); }, setValue(name, value) { GM_setValue(name, value); }, sleep(time){ return new Promise((resolve) => setTimeout(resolve, time)); }, getParam(name){ var reg = eval("/" + name + "/g"); var r = window.location.search.substr(1); var flag = reg.test(r); if (flag) { return true; } else { return false; } }, api:'https://api.azkou.cn/', tpi:'https://ts.azkou.cn/', post:async(url,data,headers) => { return new Promise((resolve, reject) => { GM_xmlhttpRequest({ method: "POST", url, data, headers, responseType:'json', onload: (res) => { resolve(res.response || res.responseText); }, onerror: (err) => { reject(err); }, }); }); }, addStyle(style){ GM_addStyle(style); }, removeClass(html){ let node_arr = html.split('|'); for (let i = 0; i < node_arr.length; i++) { $(node_arr[i]).remove(); } }, removeHtml(html){ base.removeClass(html); base.sleep(500).then(()=>{ base.removeClass(html); }) }, jumpUrl:(url)=>{ var form=null; if (document.getElementById('redirect_form')) { form = document.getElementById('redirect_form'); form.action = url; } else { form = document.createElement('form'); form.action =url; form.target = '_blank'; form.method = 'POST'; form.setAttribute("id", 'redirect_form'); document.body.appendChild(form); } form.submit(); form.action = ""; form.parentNode.removeChild(form); }, addClassHtml(warp,html){ let node_arr = warp.split('|'); for (let i = 0; i < node_arr.length; i++) { if($('div').is(node_arr[i])){ $(node_arr[i]).after(html); break; } } }, search(){ base.warp.forEach(function(item){ let list=$(item); list.map(function(key,items){ if($(items).attr('data-md5-value')!='yes'){ base.searchList.push(items); base.searchTempList.push(items); $(items).attr('data-md5-key',base.searchKey); $(items).attr('data-md5-value','yes'); base.searchKey++; } }) }) let requestTemp=base.searchTempList.splice(0,base.num); let requestList=[]; requestTemp.forEach(function(item,key){ let temp={}; temp['href']=$(item).find('a:first').attr('href'); temp['md5']=$(item).attr('data-md5-key'); requestList.push(temp); }) if(requestList.length>0){ base.post(`${base.api}?type=jdsearch&`,JSON.stringify({data:requestList}),{}).then((res)=>{ if(res.status==1){ res.data.map(function(item){ if(item.url){ $(base.searchList[item.md5]).find('a').bind("click", function(e) { e.preventDefault(); base.jumpUrl(item.url); }) } }) } }) } } } if (base.href.indexOf("//item.taobao.com/item") != -1 || base.href.indexOf("//detail.tmall.com/item") != -1 || base.href.indexOf("//chaoshi.detail.tmall.com/item") != -1 || base.href.indexOf("//detail.tmall.hk/hk/item") != -1 || base.href.indexOf("//detail.tmall.hk/item") != -1) { base.addStyle(base.css); $.getJSON(base.api+'?type=tbitem&url='+encodeURIComponent(base.href), function(res) { let html=''; if(res.status==1){ html+='
'+res.money+'
'+res.label+'
'+res.info+'
'; } if(res.shortUrl){ $("body").append(res.shortHtml); $(res.qcode).qrcode({render: "canvas", width: 160,height: 150,text: res.shortUrl}); } base.removeHtml(res.rwarp); base.sleep(500).then(()=>{ base.addClassHtml(res.warp,html); }) }) }else if (base.href.indexOf("item.jd") != -1 || base.href.indexOf("item.m.jd") != -1 || base.href.indexOf("//item.yiyaojd.com/") != -1 || base.href.indexOf("//e.jd.com/") != -1 || base.href.indexOf("//pro.jd.com/") != -1 || base.href.indexOf("//pro.m.jd.com/") != -1 || base.href.indexOf("//story.m.jd.com/") != -1 || base.href.indexOf("//prodev.m.jd.com/") != -1 || base.href.indexOf("//prodev.jd.com/") != -1) { if (!base.getParam('utm_campaign')) { $.getJSON(base.tpi+'?type=jditem&url='+encodeURIComponent(base.href), function(res) { if(res.data) window.location.href =res.data; }) } base.addStyle(base.css); $.getJSON(base.api+'?type=jditem&url='+encodeURIComponent(base.href), function(res) { let html=''; if(res.status==1){ html+='
'+res.money+'
'+res.label+'
'+res.info+'
'; } if(res.shortUrl){ $("body").append(res.shortHtml); $(res.qcode).qrcode({render: "canvas", width: 160,height: 150,text: res.shortUrl}); } base.removeHtml(res.rwarp); if($('div').is(res.warp)){ $(res.warp).after(html); }else{ $('.summary-top').after(html); } }) }else if (base.href.indexOf("jingfen.jd") != -1){ base.addStyle(base.css); $.getJSON(base.api+'?type=jingfen&url='+encodeURIComponent(base.href), function(res) { base.sleep(500).then(()=>{ base.removeHtml(res.rwarp); $(res.warp).append(res.shortHtml); $(res.qcode).qrcode({render: "canvas", width: 160,height: 150,text: res.shortUrl}); }) }) }else if (base.href.indexOf("jd") != -1 || base.href.indexOf("m.jd") != -1){ setInterval(base.search, 300); }else{ var _GM_getResourceText = /* @__PURE__ */ (() => typeof GM_getResourceText != "undefined" ? GM_getResourceText : void 0)(); var _GM_getValue = /* @__PURE__ */ (() => typeof GM_getValue != "undefined" ? GM_getValue : void 0)(); var _GM_info = /* @__PURE__ */ (() => typeof GM_info != "undefined" ? GM_info : void 0)(); var _GM_setValue = /* @__PURE__ */ (() => typeof GM_setValue != "undefined" ? GM_setValue : void 0)(); var _GM_xmlhttpRequest = /* @__PURE__ */ (() => typeof GM_xmlhttpRequest != "undefined" ? GM_xmlhttpRequest : void 0)(); var _unsafeWindow = /* @__PURE__ */ (() => typeof unsafeWindow != "undefined" ? unsafeWindow : void 0)(); var isVue2 = false; /*! * pinia v2.1.7 * (c) 2023 Eduardo San Martin Morote * @license MIT */ let activePinia; const setActivePinia = (pinia) => activePinia = pinia; const piniaSymbol = ( /* istanbul ignore next */ Symbol() ); function isPlainObject(o) { return o && typeof o === "object" && Object.prototype.toString.call(o) === "[object Object]" && typeof o.toJSON !== "function"; } var MutationType; (function(MutationType2) { MutationType2["direct"] = "direct"; MutationType2["patchObject"] = "patch object"; MutationType2["patchFunction"] = "patch function"; })(MutationType || (MutationType = {})); function createPinia() { const scope = vue.effectScope(true); const state = scope.run(() => vue.ref({})); let _p = []; let toBeInstalled = []; const pinia = vue.markRaw({ install(app) { setActivePinia(pinia); { pinia._a = app; app.provide(piniaSymbol, pinia); app.config.globalProperties.$pinia = pinia; toBeInstalled.forEach((plugin) => _p.push(plugin)); toBeInstalled = []; } }, use(plugin) { if (!this._a && !isVue2) { toBeInstalled.push(plugin); } else { _p.push(plugin); } return this; }, _p, // it's actually undefined here // @ts-expect-error _a: null, _e: scope, _s: /* @__PURE__ */ new Map(), state }); return pinia; } const noop = () => { }; function addSubscription(subscriptions, callback, detached, onCleanup = noop) { subscriptions.push(callback); const removeSubscription = () => { const idx = subscriptions.indexOf(callback); if (idx > -1) { subscriptions.splice(idx, 1); onCleanup(); } }; if (!detached && vue.getCurrentScope()) { vue.onScopeDispose(removeSubscription); } return removeSubscription; } function triggerSubscriptions(subscriptions, ...args) { subscriptions.slice().forEach((callback) => { callback(...args); }); } const fallbackRunWithContext = (fn) => fn(); function mergeReactiveObjects(target, patchToApply) { if (target instanceof Map && patchToApply instanceof Map) { patchToApply.forEach((value, key2) => target.set(key2, value)); } if (target instanceof Set && patchToApply instanceof Set) { patchToApply.forEach(target.add, target); } for (const key2 in patchToApply) { if (!patchToApply.hasOwnProperty(key2)) continue; const subPatch = patchToApply[key2]; const targetValue = target[key2]; if (isPlainObject(targetValue) && isPlainObject(subPatch) && target.hasOwnProperty(key2) && !vue.isRef(subPatch) && !vue.isReactive(subPatch)) { target[key2] = mergeReactiveObjects(targetValue, subPatch); } else { target[key2] = subPatch; } } return target; } const skipHydrateSymbol = ( /* istanbul ignore next */ Symbol() ); function shouldHydrate(obj) { return !isPlainObject(obj) || !obj.hasOwnProperty(skipHydrateSymbol); } const { assign } = Object; function isComputed(o) { return !!(vue.isRef(o) && o.effect); } function createOptionsStore(id, options, pinia, hot) { const { state, actions, getters } = options; const initialState = pinia.state.value[id]; let store; function setup() { if (!initialState && true) { { pinia.state.value[id] = state ? state() : {}; } } const localState = vue.toRefs(pinia.state.value[id]); return assign(localState, actions, Object.keys(getters || {}).reduce((computedGetters, name) => { computedGetters[name] = vue.markRaw(vue.computed(() => { setActivePinia(pinia); const store2 = pinia._s.get(id); return getters[name].call(store2, store2); })); return computedGetters; }, {})); } store = createSetupStore(id, setup, options, pinia, hot, true); return store; } function createSetupStore($id, setup, options = {}, pinia, hot, isOptionsStore) { let scope; const optionsForPlugin = assign({ actions: {} }, options); const $subscribeOptions = { deep: true // flush: 'post', }; let isListening; let isSyncListening; let subscriptions = []; let actionSubscriptions = []; let debuggerEvents; const initialState = pinia.state.value[$id]; if (!isOptionsStore && !initialState && true) { { pinia.state.value[$id] = {}; } } vue.ref({}); let activeListener; function $patch(partialStateOrMutator) { let subscriptionMutation; isListening = isSyncListening = false; if (typeof partialStateOrMutator === "function") { partialStateOrMutator(pinia.state.value[$id]); subscriptionMutation = { type: MutationType.patchFunction, storeId: $id, events: debuggerEvents }; } else { mergeReactiveObjects(pinia.state.value[$id], partialStateOrMutator); subscriptionMutation = { type: MutationType.patchObject, payload: partialStateOrMutator, storeId: $id, events: debuggerEvents }; } const myListenerId = activeListener = Symbol(); vue.nextTick().then(() => { if (activeListener === myListenerId) { isListening = true; } }); isSyncListening = true; triggerSubscriptions(subscriptions, subscriptionMutation, pinia.state.value[$id]); } const $reset = isOptionsStore ? function $reset2() { const { state } = options; const newState = state ? state() : {}; this.$patch(($state) => { assign($state, newState); }); } : ( /* istanbul ignore next */ noop ); function $dispose() { scope.stop(); subscriptions = []; actionSubscriptions = []; pinia._s.delete($id); } function wrapAction(name, action) { return function() { setActivePinia(pinia); const args = Array.from(arguments); const afterCallbackList = []; const onErrorCallbackList = []; function after(callback) { afterCallbackList.push(callback); } function onError(callback) { onErrorCallbackList.push(callback); } triggerSubscriptions(actionSubscriptions, { args, name, store, after, onError }); let ret; try { ret = action.apply(this && this.$id === $id ? this : store, args); } catch (error) { triggerSubscriptions(onErrorCallbackList, error); throw error; } if (ret instanceof Promise) { return ret.then((value) => { triggerSubscriptions(afterCallbackList, value); return value; }).catch((error) => { triggerSubscriptions(onErrorCallbackList, error); return Promise.reject(error); }); } triggerSubscriptions(afterCallbackList, ret); return ret; }; } const partialStore = { _p: pinia, // _s: scope, $id, $onAction: addSubscription.bind(null, actionSubscriptions), $patch, $reset, $subscribe(callback, options2 = {}) { const removeSubscription = addSubscription(subscriptions, callback, options2.detached, () => stopWatcher()); const stopWatcher = scope.run(() => vue.watch(() => pinia.state.value[$id], (state) => { if (options2.flush === "sync" ? isSyncListening : isListening) { callback({ storeId: $id, type: MutationType.direct, events: debuggerEvents }, state); } }, assign({}, $subscribeOptions, options2))); return removeSubscription; }, $dispose }; const store = vue.reactive(partialStore); pinia._s.set($id, store); const runWithContext = pinia._a && pinia._a.runWithContext || fallbackRunWithContext; const setupStore = runWithContext(() => pinia._e.run(() => (scope = vue.effectScope()).run(setup))); for (const key2 in setupStore) { const prop = setupStore[key2]; if (vue.isRef(prop) && !isComputed(prop) || vue.isReactive(prop)) { if (!isOptionsStore) { if (initialState && shouldHydrate(prop)) { if (vue.isRef(prop)) { prop.value = initialState[key2]; } else { mergeReactiveObjects(prop, initialState[key2]); } } { pinia.state.value[$id][key2] = prop; } } } else if (typeof prop === "function") { const actionValue = wrapAction(key2, prop); { setupStore[key2] = actionValue; } optionsForPlugin.actions[key2] = prop; } else ; } { assign(store, setupStore); assign(vue.toRaw(store), setupStore); } Object.defineProperty(store, "$state", { get: () => pinia.state.value[$id], set: (state) => { $patch(($state) => { assign($state, state); }); } }); pinia._p.forEach((extender) => { { assign(store, scope.run(() => extender({ store, app: pinia._a, pinia, options: optionsForPlugin }))); } }); if (initialState && isOptionsStore && options.hydrate) { options.hydrate(store.$state, initialState); } isListening = true; isSyncListening = true; return store; } function defineStore(idOrOptions, setup, setupOptions) { let id; let options; const isSetupStore = typeof setup === "function"; if (typeof idOrOptions === "string") { id = idOrOptions; options = isSetupStore ? setupOptions : setup; } else { options = idOrOptions; id = idOrOptions.id; } function useStore(pinia, hot) { const hasContext = vue.hasInjectionContext(); pinia = // in test mode, ignore the argument provided as we can always retrieve a // pinia instance with getActivePinia() pinia || (hasContext ? vue.inject(piniaSymbol, null) : null); if (pinia) setActivePinia(pinia); pinia = activePinia; if (!pinia._s.has(id)) { if (isSetupStore) { createSetupStore(id, setup, options, pinia); } else { createOptionsStore(id, options, pinia); } } const store = pinia._s.get(id); return store; } useStore.$id = id; return useStore; } const prefix = "AiAsk_"; class Cache { /** * 封装缓存 * @param key 缓存key * @param value 缓存值 * @param expire 过期时间 * * @returns 缓存值 */ static set(key2, value, expire = 0) { key2 = prefix + key2; if (expire > 0) { _GM_setValue(key2, { value, expire: (/* @__PURE__ */ new Date()).getTime() + expire * 1e3 }); } else { _GM_setValue(key2, { value, expire: 0 }); } return _GM_getValue(key2); } /** * 获取缓存 * @param key 缓存key * * @returns 缓存值 */ static get(key2, defaultVal = null) { key2 = prefix + key2; let cache = _GM_getValue(key2); if (cache && cache.expire > 0 && cache.expire < (/* @__PURE__ */ new Date()).getTime()) { _GM_setValue(key2, null); return defaultVal; } return cache ? cache.value : defaultVal; } } /*! @license DOMPurify 3.0.11 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.0.11/LICENSE */ const { entries, setPrototypeOf, isFrozen, getPrototypeOf, getOwnPropertyDescriptor } = Object; let { freeze, seal, create } = Object; let { apply, construct } = typeof Reflect !== "undefined" && Reflect; if (!freeze) { freeze = function freeze2(x) { return x; }; } if (!seal) { seal = function seal2(x) { return x; }; } if (!apply) { apply = function apply2(fun, thisValue, args) { return fun.apply(thisValue, args); }; } if (!construct) { construct = function construct2(Func, args) { return new Func(...args); }; } const arrayForEach = unapply(Array.prototype.forEach); const arrayPop = unapply(Array.prototype.pop); const arrayPush = unapply(Array.prototype.push); const stringToLowerCase = unapply(String.prototype.toLowerCase); const stringToString = unapply(String.prototype.toString); const stringMatch = unapply(String.prototype.match); const stringReplace = unapply(String.prototype.replace); const stringIndexOf = unapply(String.prototype.indexOf); const stringTrim = unapply(String.prototype.trim); const objectHasOwnProperty = unapply(Object.prototype.hasOwnProperty); const regExpTest = unapply(RegExp.prototype.test); const typeErrorCreate = unconstruct(TypeError); function unapply(func) { return function(thisArg) { for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { args[_key - 1] = arguments[_key]; } return apply(func, thisArg, args); }; } function unconstruct(func) { return function() { for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { args[_key2] = arguments[_key2]; } return construct(func, args); }; } function addToSet(set, array) { let transformCaseFunc = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : stringToLowerCase; if (setPrototypeOf) { setPrototypeOf(set, null); } let l = array.length; while (l--) { let element = array[l]; if (typeof element === "string") { const lcElement = transformCaseFunc(element); if (lcElement !== element) { if (!isFrozen(array)) { array[l] = lcElement; } element = lcElement; } } set[element] = true; } return set; } function cleanArray(array) { for (let index = 0; index < array.length; index++) { const isPropertyExist = objectHasOwnProperty(array, index); if (!isPropertyExist) { array[index] = null; } } return array; } function clone(object) { const newObject = create(null); for (const [property, value] of entries(object)) { const isPropertyExist = objectHasOwnProperty(object, property); if (isPropertyExist) { if (Array.isArray(value)) { newObject[property] = cleanArray(value); } else if (value && typeof value === "object" && value.constructor === Object) { newObject[property] = clone(value); } else { newObject[property] = value; } } } return newObject; } function lookupGetter(object, prop) { while (object !== null) { const desc = getOwnPropertyDescriptor(object, prop); if (desc) { if (desc.get) { return unapply(desc.get); } if (typeof desc.value === "function") { return unapply(desc.value); } } object = getPrototypeOf(object); } function fallbackValue() { return null; } return fallbackValue; } const html$1 = freeze(["a", "abbr", "acronym", "address", "area", "article", "aside", "audio", "b", "bdi", "bdo", "big", "blink", "blockquote", "body", "br", "button", "canvas", "caption", "center", "cite", "code", "col", "colgroup", "content", "data", "datalist", "dd", "decorator", "del", "details", "dfn", "dialog", "dir", "div", "dl", "dt", "element", "em", "fieldset", "figcaption", "figure", "font", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hgroup", "hr", "html", "i", "img", "input", "ins", "kbd", "label", "legend", "li", "main", "map", "mark", "marquee", "menu", "menuitem", "meter", "nav", "nobr", "ol", "optgroup", "option", "output", "p", "picture", "pre", "progress", "q", "rp", "rt", "ruby", "s", "samp", "section", "select", "shadow", "small", "source", "spacer", "span", "strike", "strong", "style", "sub", "summary", "sup", "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "time", "tr", "track", "tt", "u", "ul", "var", "video", "wbr"]); const svg$1 = freeze(["svg", "a", "altglyph", "altglyphdef", "altglyphitem", "animatecolor", "animatemotion", "animatetransform", "circle", "clippath", "defs", "desc", "ellipse", "filter", "font", "g", "glyph", "glyphref", "hkern", "image", "line", "lineargradient", "marker", "mask", "metadata", "mpath", "path", "pattern", "polygon", "polyline", "radialgradient", "rect", "stop", "style", "switch", "symbol", "text", "textpath", "title", "tref", "tspan", "view", "vkern"]); const svgFilters = freeze(["feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "feDropShadow", "feFlood", "feFuncA", "feFuncB", "feFuncG", "feFuncR", "feGaussianBlur", "feImage", "feMerge", "feMergeNode", "feMorphology", "feOffset", "fePointLight", "feSpecularLighting", "feSpotLight", "feTile", "feTurbulence"]); const svgDisallowed = freeze(["animate", "color-profile", "cursor", "discard", "font-face", "font-face-format", "font-face-name", "font-face-src", "font-face-uri", "foreignobject", "hatch", "hatchpath", "mesh", "meshgradient", "meshpatch", "meshrow", "missing-glyph", "script", "set", "solidcolor", "unknown", "use"]); const mathMl$1 = freeze(["math", "menclose", "merror", "mfenced", "mfrac", "mglyph", "mi", "mlabeledtr", "mmultiscripts", "mn", "mo", "mover", "mpadded", "mphantom", "mroot", "mrow", "ms", "mspace", "msqrt", "mstyle", "msub", "msup", "msubsup", "mtable", "mtd", "mtext", "mtr", "munder", "munderover", "mprescripts"]); const mathMlDisallowed = freeze(["maction", "maligngroup", "malignmark", "mlongdiv", "mscarries", "mscarry", "msgroup", "mstack", "msline", "msrow", "semantics", "annotation", "annotation-xml", "mprescripts", "none"]); const text = freeze(["#text"]); const html = freeze(["accept", "action", "align", "alt", "autocapitalize", "autocomplete", "autopictureinpicture", "autoplay", "background", "bgcolor", "border", "capture", "cellpadding", "cellspacing", "checked", "cite", "class", "clear", "color", "cols", "colspan", "controls", "controlslist", "coords", "crossorigin", "datetime", "decoding", "default", "dir", "disabled", "disablepictureinpicture", "disableremoteplayback", "download", "draggable", "enctype", "enterkeyhint", "face", "for", "headers", "height", "hidden", "high", "href", "hreflang", "id", "inputmode", "integrity", "ismap", "kind", "label", "lang", "list", "loading", "loop", "low", "max", "maxlength", "media", "method", "min", "minlength", "multiple", "muted", "name", "nonce", "noshade", "novalidate", "nowrap", "open", "optimum", "pattern", "placeholder", "playsinline", "poster", "preload", "pubdate", "radiogroup", "readonly", "rel", "required", "rev", "reversed", "role", "rows", "rowspan", "spellcheck", "scope", "selected", "shape", "size", "sizes", "span", "srclang", "start", "src", "srcset", "step", "style", "summary", "tabindex", "title", "translate", "type", "usemap", "valign", "value", "width", "xmlns", "slot"]); const svg = freeze(["accent-height", "accumulate", "additive", "alignment-baseline", "ascent", "attributename", "attributetype", "azimuth", "basefrequency", "baseline-shift", "begin", "bias", "by", "class", "clip", "clippathunits", "clip-path", "clip-rule", "color", "color-interpolation", "color-interpolation-filters", "color-profile", "color-rendering", "cx", "cy", "d", "dx", "dy", "diffuseconstant", "direction", "display", "divisor", "dur", "edgemode", "elevation", "end", "fill", "fill-opacity", "fill-rule", "filter", "filterunits", "flood-color", "flood-opacity", "font-family", "font-size", "font-size-adjust", "font-stretch", "font-style", "font-variant", "font-weight", "fx", "fy", "g1", "g2", "glyph-name", "glyphref", "gradientunits", "gradienttransform", "height", "href", "id", "image-rendering", "in", "in2", "k", "k1", "k2", "k3", "k4", "kerning", "keypoints", "keysplines", "keytimes", "lang", "lengthadjust", "letter-spacing", "kernelmatrix", "kernelunitlength", "lighting-color", "local", "marker-end", "marker-mid", "marker-start", "markerheight", "markerunits", "markerwidth", "maskcontentunits", "maskunits", "max", "mask", "media", "method", "mode", "min", "name", "numoctaves", "offset", "operator", "opacity", "order", "orient", "orientation", "origin", "overflow", "paint-order", "path", "pathlength", "patterncontentunits", "patterntransform", "patternunits", "points", "preservealpha", "preserveaspectratio", "primitiveunits", "r", "rx", "ry", "radius", "refx", "refy", "repeatcount", "repeatdur", "restart", "result", "rotate", "scale", "seed", "shape-rendering", "specularconstant", "specularexponent", "spreadmethod", "startoffset", "stddeviation", "stitchtiles", "stop-color", "stop-opacity", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke", "stroke-width", "style", "surfacescale", "systemlanguage", "tabindex", "targetx", "targety", "transform", "transform-origin", "text-anchor", "text-decoration", "text-rendering", "textlength", "type", "u1", "u2", "unicode", "values", "viewbox", "visibility", "version", "vert-adv-y", "vert-origin-x", "vert-origin-y", "width", "word-spacing", "wrap", "writing-mode", "xchannelselector", "ychannelselector", "x", "x1", "x2", "xmlns", "y", "y1", "y2", "z", "zoomandpan"]); const mathMl = freeze(["accent", "accentunder", "align", "bevelled", "close", "columnsalign", "columnlines", "columnspan", "denomalign", "depth", "dir", "display", "displaystyle", "encoding", "fence", "frame", "height", "href", "id", "largeop", "length", "linethickness", "lspace", "lquote", "mathbackground", "mathcolor", "mathsize", "mathvariant", "maxsize", "minsize", "movablelimits", "notation", "numalign", "open", "rowalign", "rowlines", "rowspacing", "rowspan", "rspace", "rquote", "scriptlevel", "scriptminsize", "scriptsizemultiplier", "selection", "separator", "separators", "stretchy", "subscriptshift", "supscriptshift", "symmetric", "voffset", "width", "xmlns"]); const xml = freeze(["xlink:href", "xml:id", "xlink:title", "xml:space", "xmlns:xlink"]); const MUSTACHE_EXPR = seal(/\{\{[\w\W]*|[\w\W]*\}\}/gm); const ERB_EXPR = seal(/<%[\w\W]*|[\w\W]*%>/gm); const TMPLIT_EXPR = seal(/\${[\w\W]*}/gm); const DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]/); const ARIA_ATTR = seal(/^aria-[\-\w]+$/); const IS_ALLOWED_URI = seal( /^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i // eslint-disable-line no-useless-escape ); const IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i); const ATTR_WHITESPACE = seal( /[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g // eslint-disable-line no-control-regex ); const DOCTYPE_NAME = seal(/^html$/i); const CUSTOM_ELEMENT = seal(/^[a-z][.\w]*(-[.\w]+)+$/i); var EXPRESSIONS = /* @__PURE__ */ Object.freeze({ __proto__: null, MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR, DATA_ATTR, ARIA_ATTR, IS_ALLOWED_URI, IS_SCRIPT_OR_DATA, ATTR_WHITESPACE, DOCTYPE_NAME, CUSTOM_ELEMENT }); const getGlobal = function getGlobal2() { return typeof window === "undefined" ? null : window; }; const _createTrustedTypesPolicy = function _createTrustedTypesPolicy2(trustedTypes, purifyHostElement) { if (typeof trustedTypes !== "object" || typeof trustedTypes.createPolicy !== "function") { return null; } let suffix = null; const ATTR_NAME = "data-tt-policy-suffix"; if (purifyHostElement && purifyHostElement.hasAttribute(ATTR_NAME)) { suffix = purifyHostElement.getAttribute(ATTR_NAME); } const policyName = "dompurify" + (suffix ? "#" + suffix : ""); try { return trustedTypes.createPolicy(policyName, { createHTML(html2) { return html2; }, createScriptURL(scriptUrl) { return scriptUrl; } }); } catch (_) { console.warn("TrustedTypes policy " + policyName + " could not be created."); return null; } }; function createDOMPurify() { let window2 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : getGlobal(); const DOMPurify = (root) => createDOMPurify(root); DOMPurify.version = "3.0.11"; DOMPurify.removed = []; if (!window2 || !window2.document || window2.document.nodeType !== 9) { DOMPurify.isSupported = false; return DOMPurify; } let { document: document2 } = window2; const originalDocument = document2; const currentScript = originalDocument.currentScript; const { DocumentFragment, HTMLTemplateElement, Node, Element, NodeFilter, NamedNodeMap = window2.NamedNodeMap || window2.MozNamedAttrMap, HTMLFormElement, DOMParser: DOMParser2, trustedTypes } = window2; const ElementPrototype = Element.prototype; const cloneNode = lookupGetter(ElementPrototype, "cloneNode"); const getNextSibling = lookupGetter(ElementPrototype, "nextSibling"); const getChildNodes = lookupGetter(ElementPrototype, "childNodes"); const getParentNode = lookupGetter(ElementPrototype, "parentNode"); if (typeof HTMLTemplateElement === "function") { const template = document2.createElement("template"); if (template.content && template.content.ownerDocument) { document2 = template.content.ownerDocument; } } let trustedTypesPolicy; let emptyHTML = ""; const { implementation, createNodeIterator, createDocumentFragment, getElementsByTagName } = document2; const { importNode } = originalDocument; let hooks = {}; DOMPurify.isSupported = typeof entries === "function" && typeof getParentNode === "function" && implementation && implementation.createHTMLDocument !== void 0; const { MUSTACHE_EXPR: MUSTACHE_EXPR2, ERB_EXPR: ERB_EXPR2, TMPLIT_EXPR: TMPLIT_EXPR2, DATA_ATTR: DATA_ATTR2, ARIA_ATTR: ARIA_ATTR2, IS_SCRIPT_OR_DATA: IS_SCRIPT_OR_DATA2, ATTR_WHITESPACE: ATTR_WHITESPACE2, CUSTOM_ELEMENT: CUSTOM_ELEMENT2 } = EXPRESSIONS; let { IS_ALLOWED_URI: IS_ALLOWED_URI$1 } = EXPRESSIONS; let ALLOWED_TAGS = null; const DEFAULT_ALLOWED_TAGS = addToSet({}, [...html$1, ...svg$1, ...svgFilters, ...mathMl$1, ...text]); let ALLOWED_ATTR = null; const DEFAULT_ALLOWED_ATTR = addToSet({}, [...html, ...svg, ...mathMl, ...xml]); let CUSTOM_ELEMENT_HANDLING = Object.seal(create(null, { tagNameCheck: { writable: true, configurable: false, enumerable: true, value: null }, attributeNameCheck: { writable: true, configurable: false, enumerable: true, value: null }, allowCustomizedBuiltInElements: { writable: true, configurable: false, enumerable: true, value: false } })); let FORBID_TAGS = null; let FORBID_ATTR = null; let ALLOW_ARIA_ATTR = true; let ALLOW_DATA_ATTR = true; let ALLOW_UNKNOWN_PROTOCOLS = false; let ALLOW_SELF_CLOSE_IN_ATTR = true; let SAFE_FOR_TEMPLATES = false; let WHOLE_DOCUMENT = false; let SET_CONFIG = false; let FORCE_BODY = false; let RETURN_DOM = false; let RETURN_DOM_FRAGMENT = false; let RETURN_TRUSTED_TYPE = false; let SANITIZE_DOM = true; let SANITIZE_NAMED_PROPS = false; const SANITIZE_NAMED_PROPS_PREFIX = "user-content-"; let KEEP_CONTENT = true; let IN_PLACE = false; let USE_PROFILES = {}; let FORBID_CONTENTS = null; const DEFAULT_FORBID_CONTENTS = addToSet({}, ["annotation-xml", "audio", "colgroup", "desc", "foreignobject", "head", "iframe", "math", "mi", "mn", "mo", "ms", "mtext", "noembed", "noframes", "noscript", "plaintext", "script", "style", "svg", "template", "thead", "title", "video", "xmp"]); let DATA_URI_TAGS = null; const DEFAULT_DATA_URI_TAGS = addToSet({}, ["audio", "video", "img", "source", "image", "track"]); let URI_SAFE_ATTRIBUTES = null; const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ["alt", "class", "for", "id", "label", "name", "pattern", "placeholder", "role", "summary", "title", "value", "style", "xmlns"]); const MATHML_NAMESPACE = "http://www.w3.org/1998/Math/MathML"; const SVG_NAMESPACE = "http://www.w3.org/2000/svg"; const HTML_NAMESPACE = "http://www.w3.org/1999/xhtml"; let NAMESPACE = HTML_NAMESPACE; let IS_EMPTY_INPUT = false; let ALLOWED_NAMESPACES = null; const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [MATHML_NAMESPACE, SVG_NAMESPACE, HTML_NAMESPACE], stringToString); let PARSER_MEDIA_TYPE = null; const SUPPORTED_PARSER_MEDIA_TYPES = ["application/xhtml+xml", "text/html"]; const DEFAULT_PARSER_MEDIA_TYPE = "text/html"; let transformCaseFunc = null; let CONFIG = null; const formElement = document2.createElement("form"); const isRegexOrFunction = function isRegexOrFunction2(testValue) { return testValue instanceof RegExp || testValue instanceof Function; }; const _parseConfig = function _parseConfig2() { let cfg = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}; if (CONFIG && CONFIG === cfg) { return; } if (!cfg || typeof cfg !== "object") { cfg = {}; } cfg = clone(cfg); PARSER_MEDIA_TYPE = // eslint-disable-next-line unicorn/prefer-includes SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? DEFAULT_PARSER_MEDIA_TYPE : cfg.PARSER_MEDIA_TYPE; transformCaseFunc = PARSER_MEDIA_TYPE === "application/xhtml+xml" ? stringToString : stringToLowerCase; ALLOWED_TAGS = objectHasOwnProperty(cfg, "ALLOWED_TAGS") ? addToSet({}, cfg.ALLOWED_TAGS, transformCaseFunc) : DEFAULT_ALLOWED_TAGS; ALLOWED_ATTR = objectHasOwnProperty(cfg, "ALLOWED_ATTR") ? addToSet({}, cfg.ALLOWED_ATTR, transformCaseFunc) : DEFAULT_ALLOWED_ATTR; ALLOWED_NAMESPACES = objectHasOwnProperty(cfg, "ALLOWED_NAMESPACES") ? addToSet({}, cfg.ALLOWED_NAMESPACES, stringToString) : DEFAULT_ALLOWED_NAMESPACES; URI_SAFE_ATTRIBUTES = objectHasOwnProperty(cfg, "ADD_URI_SAFE_ATTR") ? addToSet( clone(DEFAULT_URI_SAFE_ATTRIBUTES), // eslint-disable-line indent cfg.ADD_URI_SAFE_ATTR, // eslint-disable-line indent transformCaseFunc // eslint-disable-line indent ) : DEFAULT_URI_SAFE_ATTRIBUTES; DATA_URI_TAGS = objectHasOwnProperty(cfg, "ADD_DATA_URI_TAGS") ? addToSet( clone(DEFAULT_DATA_URI_TAGS), // eslint-disable-line indent cfg.ADD_DATA_URI_TAGS, // eslint-disable-line indent transformCaseFunc // eslint-disable-line indent ) : DEFAULT_DATA_URI_TAGS; FORBID_CONTENTS = objectHasOwnProperty(cfg, "FORBID_CONTENTS") ? addToSet({}, cfg.FORBID_CONTENTS, transformCaseFunc) : DEFAULT_FORBID_CONTENTS; FORBID_TAGS = objectHasOwnProperty(cfg, "FORBID_TAGS") ? addToSet({}, cfg.FORBID_TAGS, transformCaseFunc) : {}; FORBID_ATTR = objectHasOwnProperty(cfg, "FORBID_ATTR") ? addToSet({}, cfg.FORBID_ATTR, transformCaseFunc) : {}; USE_PROFILES = objectHasOwnProperty(cfg, "USE_PROFILES") ? cfg.USE_PROFILES : false; ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false; ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false; ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false; ALLOW_SELF_CLOSE_IN_ATTR = cfg.ALLOW_SELF_CLOSE_IN_ATTR !== false; SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false; WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false; RETURN_DOM = cfg.RETURN_DOM || false; RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false; RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false; FORCE_BODY = cfg.FORCE_BODY || false; SANITIZE_DOM = cfg.SANITIZE_DOM !== false; SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false; KEEP_CONTENT = cfg.KEEP_CONTENT !== false; IN_PLACE = cfg.IN_PLACE || false; IS_ALLOWED_URI$1 = cfg.ALLOWED_URI_REGEXP || IS_ALLOWED_URI; NAMESPACE = cfg.NAMESPACE || HTML_NAMESPACE; CUSTOM_ELEMENT_HANDLING = cfg.CUSTOM_ELEMENT_HANDLING || {}; if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck)) { CUSTOM_ELEMENT_HANDLING.tagNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck; } if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)) { CUSTOM_ELEMENT_HANDLING.attributeNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck; } if (cfg.CUSTOM_ELEMENT_HANDLING && typeof cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements === "boolean") { CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements; } if (SAFE_FOR_TEMPLATES) { ALLOW_DATA_ATTR = false; } if (RETURN_DOM_FRAGMENT) { RETURN_DOM = true; } if (USE_PROFILES) { ALLOWED_TAGS = addToSet({}, text); ALLOWED_ATTR = []; if (USE_PROFILES.html === true) { addToSet(ALLOWED_TAGS, html$1); addToSet(ALLOWED_ATTR, html); } if (USE_PROFILES.svg === true) { addToSet(ALLOWED_TAGS, svg$1); addToSet(ALLOWED_ATTR, svg); addToSet(ALLOWED_ATTR, xml); } if (USE_PROFILES.svgFilters === true) { addToSet(ALLOWED_TAGS, svgFilters); addToSet(ALLOWED_ATTR, svg); addToSet(ALLOWED_ATTR, xml); } if (USE_PROFILES.mathMl === true) { addToSet(ALLOWED_TAGS, mathMl$1); addToSet(ALLOWED_ATTR, mathMl); addToSet(ALLOWED_ATTR, xml); } } if (cfg.ADD_TAGS) { if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) { ALLOWED_TAGS = clone(ALLOWED_TAGS); } addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc); } if (cfg.ADD_ATTR) { if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) { ALLOWED_ATTR = clone(ALLOWED_ATTR); } addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc); } if (cfg.ADD_URI_SAFE_ATTR) { addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR, transformCaseFunc); } if (cfg.FORBID_CONTENTS) { if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) { FORBID_CONTENTS = clone(FORBID_CONTENTS); } addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc); } if (KEEP_CONTENT) { ALLOWED_TAGS["#text"] = true; } if (WHOLE_DOCUMENT) { addToSet(ALLOWED_TAGS, ["html", "head", "body"]); } if (ALLOWED_TAGS.table) { addToSet(ALLOWED_TAGS, ["tbody"]); delete FORBID_TAGS.tbody; } if (cfg.TRUSTED_TYPES_POLICY) { if (typeof cfg.TRUSTED_TYPES_POLICY.createHTML !== "function") { throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.'); } if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== "function") { throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.'); } trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY; emptyHTML = trustedTypesPolicy.createHTML(""); } else { if (trustedTypesPolicy === void 0) { trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript); } if (trustedTypesPolicy !== null && typeof emptyHTML === "string") { emptyHTML = trustedTypesPolicy.createHTML(""); } } if (freeze) { freeze(cfg); } CONFIG = cfg; }; const MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ["mi", "mo", "mn", "ms", "mtext"]); const HTML_INTEGRATION_POINTS = addToSet({}, ["foreignobject", "desc", "title", "annotation-xml"]); const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ["title", "style", "font", "a", "script"]); const ALL_SVG_TAGS = addToSet({}, [...svg$1, ...svgFilters, ...svgDisallowed]); const ALL_MATHML_TAGS = addToSet({}, [...mathMl$1, ...mathMlDisallowed]); const _checkValidNamespace = function _checkValidNamespace2(element) { let parent = getParentNode(element); if (!parent || !parent.tagName) { parent = { namespaceURI: NAMESPACE, tagName: "template" }; } const tagName = stringToLowerCase(element.tagName); const parentTagName = stringToLowerCase(parent.tagName); if (!ALLOWED_NAMESPACES[element.namespaceURI]) { return false; } if (element.namespaceURI === SVG_NAMESPACE) { if (parent.namespaceURI === HTML_NAMESPACE) { return tagName === "svg"; } if (parent.namespaceURI === MATHML_NAMESPACE) { return tagName === "svg" && (parentTagName === "annotation-xml" || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]); } return Boolean(ALL_SVG_TAGS[tagName]); } if (element.namespaceURI === MATHML_NAMESPACE) { if (parent.namespaceURI === HTML_NAMESPACE) { return tagName === "math"; } if (parent.namespaceURI === SVG_NAMESPACE) { return tagName === "math" && HTML_INTEGRATION_POINTS[parentTagName]; } return Boolean(ALL_MATHML_TAGS[tagName]); } if (element.namespaceURI === HTML_NAMESPACE) { if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) { return false; } if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) { return false; } return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]); } if (PARSER_MEDIA_TYPE === "application/xhtml+xml" && ALLOWED_NAMESPACES[element.namespaceURI]) { return true; } return false; }; const _forceRemove = function _forceRemove2(node) { arrayPush(DOMPurify.removed, { element: node }); try { node.parentNode.removeChild(node); } catch (_) { node.remove(); } }; const _removeAttribute = function _removeAttribute2(name, node) { try { arrayPush(DOMPurify.removed, { attribute: node.getAttributeNode(name), from: node }); } catch (_) { arrayPush(DOMPurify.removed, { attribute: null, from: node }); } node.removeAttribute(name); if (name === "is" && !ALLOWED_ATTR[name]) { if (RETURN_DOM || RETURN_DOM_FRAGMENT) { try { _forceRemove(node); } catch (_) { } } else { try { node.setAttribute(name, ""); } catch (_) { } } } }; const _initDocument = function _initDocument2(dirty) { let doc = null; let leadingWhitespace = null; if (FORCE_BODY) { dirty = "" + dirty; } else { const matches = stringMatch(dirty, /^[\r\n\t ]+/); leadingWhitespace = matches && matches[0]; } if (PARSER_MEDIA_TYPE === "application/xhtml+xml" && NAMESPACE === HTML_NAMESPACE) { dirty = '' + dirty + ""; } const dirtyPayload = trustedTypesPolicy ? trustedTypesPolicy.createHTML(dirty) : dirty; if (NAMESPACE === HTML_NAMESPACE) { try { doc = new DOMParser2().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE); } catch (_) { } } if (!doc || !doc.documentElement) { doc = implementation.createDocument(NAMESPACE, "template", null); try { doc.documentElement.innerHTML = IS_EMPTY_INPUT ? emptyHTML : dirtyPayload; } catch (_) { } } const body = doc.body || doc.documentElement; if (dirty && leadingWhitespace) { body.insertBefore(document2.createTextNode(leadingWhitespace), body.childNodes[0] || null); } if (NAMESPACE === HTML_NAMESPACE) { return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? "html" : "body")[0]; } return WHOLE_DOCUMENT ? doc.documentElement : body; }; const _createNodeIterator = function _createNodeIterator2(root) { return createNodeIterator.call( root.ownerDocument || root, root, // eslint-disable-next-line no-bitwise NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT | NodeFilter.SHOW_PROCESSING_INSTRUCTION | NodeFilter.SHOW_CDATA_SECTION, null ); }; const _isClobbered = function _isClobbered2(elm) { return elm instanceof HTMLFormElement && (typeof elm.nodeName !== "string" || typeof elm.textContent !== "string" || typeof elm.removeChild !== "function" || !(elm.attributes instanceof NamedNodeMap) || typeof elm.removeAttribute !== "function" || typeof elm.setAttribute !== "function" || typeof elm.namespaceURI !== "string" || typeof elm.insertBefore !== "function" || typeof elm.hasChildNodes !== "function"); }; const _isNode = function _isNode2(object) { return typeof Node === "function" && object instanceof Node; }; const _executeHook = function _executeHook2(entryPoint, currentNode, data) { if (!hooks[entryPoint]) { return; } arrayForEach(hooks[entryPoint], (hook) => { hook.call(DOMPurify, currentNode, data, CONFIG); }); }; const _sanitizeElements = function _sanitizeElements2(currentNode) { let content = null; _executeHook("beforeSanitizeElements", currentNode, null); if (_isClobbered(currentNode)) { _forceRemove(currentNode); return true; } const tagName = transformCaseFunc(currentNode.nodeName); _executeHook("uponSanitizeElement", currentNode, { tagName, allowedTags: ALLOWED_TAGS }); if (currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(/<[/\w]/g, currentNode.innerHTML) && regExpTest(/<[/\w]/g, currentNode.textContent)) { _forceRemove(currentNode); return true; } if (currentNode.nodeType === 7) { _forceRemove(currentNode); return true; } if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) { if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName)) { if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) { return false; } if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)) { return false; } } if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) { const parentNode = getParentNode(currentNode) || currentNode.parentNode; const childNodes = getChildNodes(currentNode) || currentNode.childNodes; if (childNodes && parentNode) { const childCount = childNodes.length; for (let i = childCount - 1; i >= 0; --i) { parentNode.insertBefore(cloneNode(childNodes[i], true), getNextSibling(currentNode)); } } } _forceRemove(currentNode); return true; } if (currentNode instanceof Element && !_checkValidNamespace(currentNode)) { _forceRemove(currentNode); return true; } if ((tagName === "noscript" || tagName === "noembed" || tagName === "noframes") && regExpTest(/<\/no(script|embed|frames)/i, currentNode.innerHTML)) { _forceRemove(currentNode); return true; } if (SAFE_FOR_TEMPLATES && currentNode.nodeType === 3) { content = currentNode.textContent; arrayForEach([MUSTACHE_EXPR2, ERB_EXPR2, TMPLIT_EXPR2], (expr) => { content = stringReplace(content, expr, " "); }); if (currentNode.textContent !== content) { arrayPush(DOMPurify.removed, { element: currentNode.cloneNode() }); currentNode.textContent = content; } } _executeHook("afterSanitizeElements", currentNode, null); return false; }; const _isValidAttribute = function _isValidAttribute2(lcTag, lcName, value) { if (SANITIZE_DOM && (lcName === "id" || lcName === "name") && (value in document2 || value in formElement)) { return false; } if (ALLOW_DATA_ATTR && !FORBID_ATTR[lcName] && regExpTest(DATA_ATTR2, lcName)) ; else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR2, lcName)) ; else if (!ALLOWED_ATTR[lcName] || FORBID_ATTR[lcName]) { if ( // First condition does a very basic check if a) it's basically a valid custom element tagname AND // b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck // and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck _isBasicCustomElement(lcTag) && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, lcTag) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(lcTag)) && (CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.attributeNameCheck, lcName) || CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.attributeNameCheck(lcName)) || // Alternative, second condition checks if it's an `is`-attribute, AND // the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck lcName === "is" && CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, value) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(value)) ) ; else { return false; } } else if (URI_SAFE_ATTRIBUTES[lcName]) ; else if (regExpTest(IS_ALLOWED_URI$1, stringReplace(value, ATTR_WHITESPACE2, ""))) ; else if ((lcName === "src" || lcName === "xlink:href" || lcName === "href") && lcTag !== "script" && stringIndexOf(value, "data:") === 0 && DATA_URI_TAGS[lcTag]) ; else if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA2, stringReplace(value, ATTR_WHITESPACE2, ""))) ; else if (value) { return false; } else ; return true; }; const _isBasicCustomElement = function _isBasicCustomElement2(tagName) { return tagName !== "annotation-xml" && stringMatch(tagName, CUSTOM_ELEMENT2); }; const _sanitizeAttributes = function _sanitizeAttributes2(currentNode) { _executeHook("beforeSanitizeAttributes", currentNode, null); const { attributes } = currentNode; if (!attributes) { return; } const hookEvent = { attrName: "", attrValue: "", keepAttr: true, allowedAttributes: ALLOWED_ATTR }; let l = attributes.length; while (l--) { const attr = attributes[l]; const { name, namespaceURI, value: attrValue } = attr; const lcName = transformCaseFunc(name); let value = name === "value" ? attrValue : stringTrim(attrValue); hookEvent.attrName = lcName; hookEvent.attrValue = value; hookEvent.keepAttr = true; hookEvent.forceKeepAttr = void 0; _executeHook("uponSanitizeAttribute", currentNode, hookEvent); value = hookEvent.attrValue; if (hookEvent.forceKeepAttr) { continue; } _removeAttribute(name, currentNode); if (!hookEvent.keepAttr) { continue; } if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(/\/>/i, value)) { _removeAttribute(name, currentNode); continue; } if (SAFE_FOR_TEMPLATES) { arrayForEach([MUSTACHE_EXPR2, ERB_EXPR2, TMPLIT_EXPR2], (expr) => { value = stringReplace(value, expr, " "); }); } const lcTag = transformCaseFunc(currentNode.nodeName); if (!_isValidAttribute(lcTag, lcName, value)) { continue; } if (SANITIZE_NAMED_PROPS && (lcName === "id" || lcName === "name")) { _removeAttribute(name, currentNode); value = SANITIZE_NAMED_PROPS_PREFIX + value; } if (trustedTypesPolicy && typeof trustedTypes === "object" && typeof trustedTypes.getAttributeType === "function") { if (namespaceURI) ; else { switch (trustedTypes.getAttributeType(lcTag, lcName)) { case "TrustedHTML": { value = trustedTypesPolicy.createHTML(value); break; } case "TrustedScriptURL": { value = trustedTypesPolicy.createScriptURL(value); break; } } } } try { if (namespaceURI) { currentNode.setAttributeNS(namespaceURI, name, value); } else { currentNode.setAttribute(name, value); } arrayPop(DOMPurify.removed); } catch (_) { } } _executeHook("afterSanitizeAttributes", currentNode, null); }; const _sanitizeShadowDOM = function _sanitizeShadowDOM2(fragment) { let shadowNode = null; const shadowIterator = _createNodeIterator(fragment); _executeHook("beforeSanitizeShadowDOM", fragment, null); while (shadowNode = shadowIterator.nextNode()) { _executeHook("uponSanitizeShadowNode", shadowNode, null); if (_sanitizeElements(shadowNode)) { continue; } if (shadowNode.content instanceof DocumentFragment) { _sanitizeShadowDOM2(shadowNode.content); } _sanitizeAttributes(shadowNode); } _executeHook("afterSanitizeShadowDOM", fragment, null); }; DOMPurify.sanitize = function(dirty) { let cfg = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}; let body = null; let importedNode = null; let currentNode = null; let returnNode = null; IS_EMPTY_INPUT = !dirty; if (IS_EMPTY_INPUT) { dirty = ""; } if (typeof dirty !== "string" && !_isNode(dirty)) { if (typeof dirty.toString === "function") { dirty = dirty.toString(); if (typeof dirty !== "string") { throw typeErrorCreate("dirty is not a string, aborting"); } } else { throw typeErrorCreate("toString is not a function"); } } if (!DOMPurify.isSupported) { return dirty; } if (!SET_CONFIG) { _parseConfig(cfg); } DOMPurify.removed = []; if (typeof dirty === "string") { IN_PLACE = false; } if (IN_PLACE) { if (dirty.nodeName) { const tagName = transformCaseFunc(dirty.nodeName); if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) { throw typeErrorCreate("root node is forbidden and cannot be sanitized in-place"); } } } else if (dirty instanceof Node) { body = _initDocument(""); importedNode = body.ownerDocument.importNode(dirty, true); if (importedNode.nodeType === 1 && importedNode.nodeName === "BODY") { body = importedNode; } else if (importedNode.nodeName === "HTML") { body = importedNode; } else { body.appendChild(importedNode); } } else { if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT && // eslint-disable-next-line unicorn/prefer-includes dirty.indexOf("<") === -1) { return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(dirty) : dirty; } body = _initDocument(dirty); if (!body) { return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : ""; } } if (body && FORCE_BODY) { _forceRemove(body.firstChild); } const nodeIterator = _createNodeIterator(IN_PLACE ? dirty : body); while (currentNode = nodeIterator.nextNode()) { if (_sanitizeElements(currentNode)) { continue; } if (currentNode.content instanceof DocumentFragment) { _sanitizeShadowDOM(currentNode.content); } _sanitizeAttributes(currentNode); } if (IN_PLACE) { return dirty; } if (RETURN_DOM) { if (RETURN_DOM_FRAGMENT) { returnNode = createDocumentFragment.call(body.ownerDocument); while (body.firstChild) { returnNode.appendChild(body.firstChild); } } else { returnNode = body; } if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmode) { returnNode = importNode.call(originalDocument, returnNode, true); } return returnNode; } let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML; if (WHOLE_DOCUMENT && ALLOWED_TAGS["!doctype"] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) { serializedHTML = "\n" + serializedHTML; } if (SAFE_FOR_TEMPLATES) { arrayForEach([MUSTACHE_EXPR2, ERB_EXPR2, TMPLIT_EXPR2], (expr) => { serializedHTML = stringReplace(serializedHTML, expr, " "); }); } return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(serializedHTML) : serializedHTML; }; DOMPurify.setConfig = function() { let cfg = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}; _parseConfig(cfg); SET_CONFIG = true; }; DOMPurify.clearConfig = function() { CONFIG = null; SET_CONFIG = false; }; DOMPurify.isValidAttribute = function(tag, attr, value) { if (!CONFIG) { _parseConfig({}); } const lcTag = transformCaseFunc(tag); const lcName = transformCaseFunc(attr); return _isValidAttribute(lcTag, lcName, value); }; DOMPurify.addHook = function(entryPoint, hookFunction) { if (typeof hookFunction !== "function") { return; } hooks[entryPoint] = hooks[entryPoint] || []; arrayPush(hooks[entryPoint], hookFunction); }; DOMPurify.removeHook = function(entryPoint) { if (hooks[entryPoint]) { return arrayPop(hooks[entryPoint]); } }; DOMPurify.removeHooks = function(entryPoint) { if (hooks[entryPoint]) { hooks[entryPoint] = []; } }; DOMPurify.removeAllHooks = function() { hooks = {}; }; return DOMPurify; } var purify = createDOMPurify(); var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {}; function getDefaultExportFromCjs(x) { return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x; } function getAugmentedNamespace(n) { if (n.__esModule) return n; var f = n.default; if (typeof f == "function") { var a = function a2() { if (this instanceof a2) { return Reflect.construct(f, arguments, this.constructor); } return f.apply(this, arguments); }; a.prototype = f.prototype; } else a = {}; Object.defineProperty(a, "__esModule", { value: true }); Object.keys(n).forEach(function(k) { var d = Object.getOwnPropertyDescriptor(n, k); Object.defineProperty(a, k, d.get ? d : { enumerable: true, get: function() { return n[k]; } }); }); return a; } var md5 = { exports: {} }; const __viteBrowserExternal = {}; const __viteBrowserExternal$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, default: __viteBrowserExternal }, Symbol.toStringTag, { value: "Module" })); const require$$1 = /* @__PURE__ */ getAugmentedNamespace(__viteBrowserExternal$1); /** * [js-md5]{@link https://github.com/emn178/js-md5} * * @namespace md5 * @version 0.8.3 * @author Chen, Yi-Cyuan [emn178@gmail.com] * @copyright Chen, Yi-Cyuan 2014-2023 * @license MIT */ (function(module) { (function() { var INPUT_ERROR = "input is invalid type"; var FINALIZE_ERROR = "finalize already called"; var WINDOW = typeof window === "object"; var root = WINDOW ? window : {}; if (root.JS_MD5_NO_WINDOW) { WINDOW = false; } var WEB_WORKER = !WINDOW && typeof self === "object"; var NODE_JS = !root.JS_MD5_NO_NODE_JS && typeof process === "object" && process.versions && process.versions.node; if (NODE_JS) { root = commonjsGlobal; } else if (WEB_WORKER) { root = self; } var COMMON_JS = !root.JS_MD5_NO_COMMON_JS && true && module.exports; var ARRAY_BUFFER = !root.JS_MD5_NO_ARRAY_BUFFER && typeof ArrayBuffer !== "undefined"; var HEX_CHARS = "0123456789abcdef".split(""); var EXTRA = [128, 32768, 8388608, -2147483648]; var SHIFT = [0, 8, 16, 24]; var OUTPUT_TYPES = ["hex", "array", "digest", "buffer", "arrayBuffer", "base64"]; var BASE64_ENCODE_CHAR = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""); var blocks = [], buffer8; if (ARRAY_BUFFER) { var buffer = new ArrayBuffer(68); buffer8 = new Uint8Array(buffer); blocks = new Uint32Array(buffer); } var isArray = Array.isArray; if (root.JS_MD5_NO_NODE_JS || !isArray) { isArray = function(obj) { return Object.prototype.toString.call(obj) === "[object Array]"; }; } var isView = ArrayBuffer.isView; if (ARRAY_BUFFER && (root.JS_MD5_NO_ARRAY_BUFFER_IS_VIEW || !isView)) { isView = function(obj) { return typeof obj === "object" && obj.buffer && obj.buffer.constructor === ArrayBuffer; }; } var formatMessage = function(message) { var type = typeof message; if (type === "string") { return [message, true]; } if (type !== "object" || message === null) { throw new Error(INPUT_ERROR); } if (ARRAY_BUFFER && message.constructor === ArrayBuffer) { return [new Uint8Array(message), false]; } if (!isArray(message) && !isView(message)) { throw new Error(INPUT_ERROR); } return [message, false]; }; var createOutputMethod = function(outputType) { return function(message) { return new Md5(true).update(message)[outputType](); }; }; var createMethod = function() { var method = createOutputMethod("hex"); if (NODE_JS) { method = nodeWrap(method); } method.create = function() { return new Md5(); }; method.update = function(message) { return method.create().update(message); }; for (var i = 0; i < OUTPUT_TYPES.length; ++i) { var type = OUTPUT_TYPES[i]; method[type] = createOutputMethod(type); } return method; }; var nodeWrap = function(method) { var crypto = require$$1; var Buffer = require$$1.Buffer; var bufferFrom; if (Buffer.from && !root.JS_MD5_NO_BUFFER_FROM) { bufferFrom = Buffer.from; } else { bufferFrom = function(message) { return new Buffer(message); }; } var nodeMethod = function(message) { if (typeof message === "string") { return crypto.createHash("md5").update(message, "utf8").digest("hex"); } else { if (message === null || message === void 0) { throw new Error(INPUT_ERROR); } else if (message.constructor === ArrayBuffer) { message = new Uint8Array(message); } } if (isArray(message) || isView(message) || message.constructor === Buffer) { return crypto.createHash("md5").update(bufferFrom(message)).digest("hex"); } else { return method(message); } }; return nodeMethod; }; var createHmacOutputMethod = function(outputType) { return function(key2, message) { return new HmacMd5(key2, true).update(message)[outputType](); }; }; var createHmacMethod = function() { var method = createHmacOutputMethod("hex"); method.create = function(key2) { return new HmacMd5(key2); }; method.update = function(key2, message) { return method.create(key2).update(message); }; for (var i = 0; i < OUTPUT_TYPES.length; ++i) { var type = OUTPUT_TYPES[i]; method[type] = createHmacOutputMethod(type); } return method; }; function Md5(sharedMemory) { if (sharedMemory) { blocks[0] = blocks[16] = blocks[1] = blocks[2] = blocks[3] = blocks[4] = blocks[5] = blocks[6] = blocks[7] = blocks[8] = blocks[9] = blocks[10] = blocks[11] = blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0; this.blocks = blocks; this.buffer8 = buffer8; } else { if (ARRAY_BUFFER) { var buffer2 = new ArrayBuffer(68); this.buffer8 = new Uint8Array(buffer2); this.blocks = new Uint32Array(buffer2); } else { this.blocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; } } this.h0 = this.h1 = this.h2 = this.h3 = this.start = this.bytes = this.hBytes = 0; this.finalized = this.hashed = false; this.first = true; } Md5.prototype.update = function(message) { if (this.finalized) { throw new Error(FINALIZE_ERROR); } var result = formatMessage(message); message = result[0]; var isString = result[1]; var code, index = 0, i, length = message.length, blocks2 = this.blocks; var buffer82 = this.buffer8; while (index < length) { if (this.hashed) { this.hashed = false; blocks2[0] = blocks2[16]; blocks2[16] = blocks2[1] = blocks2[2] = blocks2[3] = blocks2[4] = blocks2[5] = blocks2[6] = blocks2[7] = blocks2[8] = blocks2[9] = blocks2[10] = blocks2[11] = blocks2[12] = blocks2[13] = blocks2[14] = blocks2[15] = 0; } if (isString) { if (ARRAY_BUFFER) { for (i = this.start; index < length && i < 64; ++index) { code = message.charCodeAt(index); if (code < 128) { buffer82[i++] = code; } else if (code < 2048) { buffer82[i++] = 192 | code >>> 6; buffer82[i++] = 128 | code & 63; } else if (code < 55296 || code >= 57344) { buffer82[i++] = 224 | code >>> 12; buffer82[i++] = 128 | code >>> 6 & 63; buffer82[i++] = 128 | code & 63; } else { code = 65536 + ((code & 1023) << 10 | message.charCodeAt(++index) & 1023); buffer82[i++] = 240 | code >>> 18; buffer82[i++] = 128 | code >>> 12 & 63; buffer82[i++] = 128 | code >>> 6 & 63; buffer82[i++] = 128 | code & 63; } } } else { for (i = this.start; index < length && i < 64; ++index) { code = message.charCodeAt(index); if (code < 128) { blocks2[i >>> 2] |= code << SHIFT[i++ & 3]; } else if (code < 2048) { blocks2[i >>> 2] |= (192 | code >>> 6) << SHIFT[i++ & 3]; blocks2[i >>> 2] |= (128 | code & 63) << SHIFT[i++ & 3]; } else if (code < 55296 || code >= 57344) { blocks2[i >>> 2] |= (224 | code >>> 12) << SHIFT[i++ & 3]; blocks2[i >>> 2] |= (128 | code >>> 6 & 63) << SHIFT[i++ & 3]; blocks2[i >>> 2] |= (128 | code & 63) << SHIFT[i++ & 3]; } else { code = 65536 + ((code & 1023) << 10 | message.charCodeAt(++index) & 1023); blocks2[i >>> 2] |= (240 | code >>> 18) << SHIFT[i++ & 3]; blocks2[i >>> 2] |= (128 | code >>> 12 & 63) << SHIFT[i++ & 3]; blocks2[i >>> 2] |= (128 | code >>> 6 & 63) << SHIFT[i++ & 3]; blocks2[i >>> 2] |= (128 | code & 63) << SHIFT[i++ & 3]; } } } } else { if (ARRAY_BUFFER) { for (i = this.start; index < length && i < 64; ++index) { buffer82[i++] = message[index]; } } else { for (i = this.start; index < length && i < 64; ++index) { blocks2[i >>> 2] |= message[index] << SHIFT[i++ & 3]; } } } this.lastByteIndex = i; this.bytes += i - this.start; if (i >= 64) { this.start = i - 64; this.hash(); this.hashed = true; } else { this.start = i; } } if (this.bytes > 4294967295) { this.hBytes += this.bytes / 4294967296 << 0; this.bytes = this.bytes % 4294967296; } return this; }; Md5.prototype.finalize = function() { if (this.finalized) { return; } this.finalized = true; var blocks2 = this.blocks, i = this.lastByteIndex; blocks2[i >>> 2] |= EXTRA[i & 3]; if (i >= 56) { if (!this.hashed) { this.hash(); } blocks2[0] = blocks2[16]; blocks2[16] = blocks2[1] = blocks2[2] = blocks2[3] = blocks2[4] = blocks2[5] = blocks2[6] = blocks2[7] = blocks2[8] = blocks2[9] = blocks2[10] = blocks2[11] = blocks2[12] = blocks2[13] = blocks2[14] = blocks2[15] = 0; } blocks2[14] = this.bytes << 3; blocks2[15] = this.hBytes << 3 | this.bytes >>> 29; this.hash(); }; Md5.prototype.hash = function() { var a, b, c, d, bc, da, blocks2 = this.blocks; if (this.first) { a = blocks2[0] - 680876937; a = (a << 7 | a >>> 25) - 271733879 << 0; d = (-1732584194 ^ a & 2004318071) + blocks2[1] - 117830708; d = (d << 12 | d >>> 20) + a << 0; c = (-271733879 ^ d & (a ^ -271733879)) + blocks2[2] - 1126478375; c = (c << 17 | c >>> 15) + d << 0; b = (a ^ c & (d ^ a)) + blocks2[3] - 1316259209; b = (b << 22 | b >>> 10) + c << 0; } else { a = this.h0; b = this.h1; c = this.h2; d = this.h3; a += (d ^ b & (c ^ d)) + blocks2[0] - 680876936; a = (a << 7 | a >>> 25) + b << 0; d += (c ^ a & (b ^ c)) + blocks2[1] - 389564586; d = (d << 12 | d >>> 20) + a << 0; c += (b ^ d & (a ^ b)) + blocks2[2] + 606105819; c = (c << 17 | c >>> 15) + d << 0; b += (a ^ c & (d ^ a)) + blocks2[3] - 1044525330; b = (b << 22 | b >>> 10) + c << 0; } a += (d ^ b & (c ^ d)) + blocks2[4] - 176418897; a = (a << 7 | a >>> 25) + b << 0; d += (c ^ a & (b ^ c)) + blocks2[5] + 1200080426; d = (d << 12 | d >>> 20) + a << 0; c += (b ^ d & (a ^ b)) + blocks2[6] - 1473231341; c = (c << 17 | c >>> 15) + d << 0; b += (a ^ c & (d ^ a)) + blocks2[7] - 45705983; b = (b << 22 | b >>> 10) + c << 0; a += (d ^ b & (c ^ d)) + blocks2[8] + 1770035416; a = (a << 7 | a >>> 25) + b << 0; d += (c ^ a & (b ^ c)) + blocks2[9] - 1958414417; d = (d << 12 | d >>> 20) + a << 0; c += (b ^ d & (a ^ b)) + blocks2[10] - 42063; c = (c << 17 | c >>> 15) + d << 0; b += (a ^ c & (d ^ a)) + blocks2[11] - 1990404162; b = (b << 22 | b >>> 10) + c << 0; a += (d ^ b & (c ^ d)) + blocks2[12] + 1804603682; a = (a << 7 | a >>> 25) + b << 0; d += (c ^ a & (b ^ c)) + blocks2[13] - 40341101; d = (d << 12 | d >>> 20) + a << 0; c += (b ^ d & (a ^ b)) + blocks2[14] - 1502002290; c = (c << 17 | c >>> 15) + d << 0; b += (a ^ c & (d ^ a)) + blocks2[15] + 1236535329; b = (b << 22 | b >>> 10) + c << 0; a += (c ^ d & (b ^ c)) + blocks2[1] - 165796510; a = (a << 5 | a >>> 27) + b << 0; d += (b ^ c & (a ^ b)) + blocks2[6] - 1069501632; d = (d << 9 | d >>> 23) + a << 0; c += (a ^ b & (d ^ a)) + blocks2[11] + 643717713; c = (c << 14 | c >>> 18) + d << 0; b += (d ^ a & (c ^ d)) + blocks2[0] - 373897302; b = (b << 20 | b >>> 12) + c << 0; a += (c ^ d & (b ^ c)) + blocks2[5] - 701558691; a = (a << 5 | a >>> 27) + b << 0; d += (b ^ c & (a ^ b)) + blocks2[10] + 38016083; d = (d << 9 | d >>> 23) + a << 0; c += (a ^ b & (d ^ a)) + blocks2[15] - 660478335; c = (c << 14 | c >>> 18) + d << 0; b += (d ^ a & (c ^ d)) + blocks2[4] - 405537848; b = (b << 20 | b >>> 12) + c << 0; a += (c ^ d & (b ^ c)) + blocks2[9] + 568446438; a = (a << 5 | a >>> 27) + b << 0; d += (b ^ c & (a ^ b)) + blocks2[14] - 1019803690; d = (d << 9 | d >>> 23) + a << 0; c += (a ^ b & (d ^ a)) + blocks2[3] - 187363961; c = (c << 14 | c >>> 18) + d << 0; b += (d ^ a & (c ^ d)) + blocks2[8] + 1163531501; b = (b << 20 | b >>> 12) + c << 0; a += (c ^ d & (b ^ c)) + blocks2[13] - 1444681467; a = (a << 5 | a >>> 27) + b << 0; d += (b ^ c & (a ^ b)) + blocks2[2] - 51403784; d = (d << 9 | d >>> 23) + a << 0; c += (a ^ b & (d ^ a)) + blocks2[7] + 1735328473; c = (c << 14 | c >>> 18) + d << 0; b += (d ^ a & (c ^ d)) + blocks2[12] - 1926607734; b = (b << 20 | b >>> 12) + c << 0; bc = b ^ c; a += (bc ^ d) + blocks2[5] - 378558; a = (a << 4 | a >>> 28) + b << 0; d += (bc ^ a) + blocks2[8] - 2022574463; d = (d << 11 | d >>> 21) + a << 0; da = d ^ a; c += (da ^ b) + blocks2[11] + 1839030562; c = (c << 16 | c >>> 16) + d << 0; b += (da ^ c) + blocks2[14] - 35309556; b = (b << 23 | b >>> 9) + c << 0; bc = b ^ c; a += (bc ^ d) + blocks2[1] - 1530992060; a = (a << 4 | a >>> 28) + b << 0; d += (bc ^ a) + blocks2[4] + 1272893353; d = (d << 11 | d >>> 21) + a << 0; da = d ^ a; c += (da ^ b) + blocks2[7] - 155497632; c = (c << 16 | c >>> 16) + d << 0; b += (da ^ c) + blocks2[10] - 1094730640; b = (b << 23 | b >>> 9) + c << 0; bc = b ^ c; a += (bc ^ d) + blocks2[13] + 681279174; a = (a << 4 | a >>> 28) + b << 0; d += (bc ^ a) + blocks2[0] - 358537222; d = (d << 11 | d >>> 21) + a << 0; da = d ^ a; c += (da ^ b) + blocks2[3] - 722521979; c = (c << 16 | c >>> 16) + d << 0; b += (da ^ c) + blocks2[6] + 76029189; b = (b << 23 | b >>> 9) + c << 0; bc = b ^ c; a += (bc ^ d) + blocks2[9] - 640364487; a = (a << 4 | a >>> 28) + b << 0; d += (bc ^ a) + blocks2[12] - 421815835; d = (d << 11 | d >>> 21) + a << 0; da = d ^ a; c += (da ^ b) + blocks2[15] + 530742520; c = (c << 16 | c >>> 16) + d << 0; b += (da ^ c) + blocks2[2] - 995338651; b = (b << 23 | b >>> 9) + c << 0; a += (c ^ (b | ~d)) + blocks2[0] - 198630844; a = (a << 6 | a >>> 26) + b << 0; d += (b ^ (a | ~c)) + blocks2[7] + 1126891415; d = (d << 10 | d >>> 22) + a << 0; c += (a ^ (d | ~b)) + blocks2[14] - 1416354905; c = (c << 15 | c >>> 17) + d << 0; b += (d ^ (c | ~a)) + blocks2[5] - 57434055; b = (b << 21 | b >>> 11) + c << 0; a += (c ^ (b | ~d)) + blocks2[12] + 1700485571; a = (a << 6 | a >>> 26) + b << 0; d += (b ^ (a | ~c)) + blocks2[3] - 1894986606; d = (d << 10 | d >>> 22) + a << 0; c += (a ^ (d | ~b)) + blocks2[10] - 1051523; c = (c << 15 | c >>> 17) + d << 0; b += (d ^ (c | ~a)) + blocks2[1] - 2054922799; b = (b << 21 | b >>> 11) + c << 0; a += (c ^ (b | ~d)) + blocks2[8] + 1873313359; a = (a << 6 | a >>> 26) + b << 0; d += (b ^ (a | ~c)) + blocks2[15] - 30611744; d = (d << 10 | d >>> 22) + a << 0; c += (a ^ (d | ~b)) + blocks2[6] - 1560198380; c = (c << 15 | c >>> 17) + d << 0; b += (d ^ (c | ~a)) + blocks2[13] + 1309151649; b = (b << 21 | b >>> 11) + c << 0; a += (c ^ (b | ~d)) + blocks2[4] - 145523070; a = (a << 6 | a >>> 26) + b << 0; d += (b ^ (a | ~c)) + blocks2[11] - 1120210379; d = (d << 10 | d >>> 22) + a << 0; c += (a ^ (d | ~b)) + blocks2[2] + 718787259; c = (c << 15 | c >>> 17) + d << 0; b += (d ^ (c | ~a)) + blocks2[9] - 343485551; b = (b << 21 | b >>> 11) + c << 0; if (this.first) { this.h0 = a + 1732584193 << 0; this.h1 = b - 271733879 << 0; this.h2 = c - 1732584194 << 0; this.h3 = d + 271733878 << 0; this.first = false; } else { this.h0 = this.h0 + a << 0; this.h1 = this.h1 + b << 0; this.h2 = this.h2 + c << 0; this.h3 = this.h3 + d << 0; } }; Md5.prototype.hex = function() { this.finalize(); var h0 = this.h0, h1 = this.h1, h2 = this.h2, h3 = this.h3; return HEX_CHARS[h0 >>> 4 & 15] + HEX_CHARS[h0 & 15] + HEX_CHARS[h0 >>> 12 & 15] + HEX_CHARS[h0 >>> 8 & 15] + HEX_CHARS[h0 >>> 20 & 15] + HEX_CHARS[h0 >>> 16 & 15] + HEX_CHARS[h0 >>> 28 & 15] + HEX_CHARS[h0 >>> 24 & 15] + HEX_CHARS[h1 >>> 4 & 15] + HEX_CHARS[h1 & 15] + HEX_CHARS[h1 >>> 12 & 15] + HEX_CHARS[h1 >>> 8 & 15] + HEX_CHARS[h1 >>> 20 & 15] + HEX_CHARS[h1 >>> 16 & 15] + HEX_CHARS[h1 >>> 28 & 15] + HEX_CHARS[h1 >>> 24 & 15] + HEX_CHARS[h2 >>> 4 & 15] + HEX_CHARS[h2 & 15] + HEX_CHARS[h2 >>> 12 & 15] + HEX_CHARS[h2 >>> 8 & 15] + HEX_CHARS[h2 >>> 20 & 15] + HEX_CHARS[h2 >>> 16 & 15] + HEX_CHARS[h2 >>> 28 & 15] + HEX_CHARS[h2 >>> 24 & 15] + HEX_CHARS[h3 >>> 4 & 15] + HEX_CHARS[h3 & 15] + HEX_CHARS[h3 >>> 12 & 15] + HEX_CHARS[h3 >>> 8 & 15] + HEX_CHARS[h3 >>> 20 & 15] + HEX_CHARS[h3 >>> 16 & 15] + HEX_CHARS[h3 >>> 28 & 15] + HEX_CHARS[h3 >>> 24 & 15]; }; Md5.prototype.toString = Md5.prototype.hex; Md5.prototype.digest = function() { this.finalize(); var h0 = this.h0, h1 = this.h1, h2 = this.h2, h3 = this.h3; return [ h0 & 255, h0 >>> 8 & 255, h0 >>> 16 & 255, h0 >>> 24 & 255, h1 & 255, h1 >>> 8 & 255, h1 >>> 16 & 255, h1 >>> 24 & 255, h2 & 255, h2 >>> 8 & 255, h2 >>> 16 & 255, h2 >>> 24 & 255, h3 & 255, h3 >>> 8 & 255, h3 >>> 16 & 255, h3 >>> 24 & 255 ]; }; Md5.prototype.array = Md5.prototype.digest; Md5.prototype.arrayBuffer = function() { this.finalize(); var buffer2 = new ArrayBuffer(16); var blocks2 = new Uint32Array(buffer2); blocks2[0] = this.h0; blocks2[1] = this.h1; blocks2[2] = this.h2; blocks2[3] = this.h3; return buffer2; }; Md5.prototype.buffer = Md5.prototype.arrayBuffer; Md5.prototype.base64 = function() { var v1, v2, v3, base64Str = "", bytes = this.array(); for (var i = 0; i < 15; ) { v1 = bytes[i++]; v2 = bytes[i++]; v3 = bytes[i++]; base64Str += BASE64_ENCODE_CHAR[v1 >>> 2] + BASE64_ENCODE_CHAR[(v1 << 4 | v2 >>> 4) & 63] + BASE64_ENCODE_CHAR[(v2 << 2 | v3 >>> 6) & 63] + BASE64_ENCODE_CHAR[v3 & 63]; } v1 = bytes[i]; base64Str += BASE64_ENCODE_CHAR[v1 >>> 2] + BASE64_ENCODE_CHAR[v1 << 4 & 63] + "=="; return base64Str; }; function HmacMd5(key2, sharedMemory) { var i, result = formatMessage(key2); key2 = result[0]; if (result[1]) { var bytes = [], length = key2.length, index = 0, code; for (i = 0; i < length; ++i) { code = key2.charCodeAt(i); if (code < 128) { bytes[index++] = code; } else if (code < 2048) { bytes[index++] = 192 | code >>> 6; bytes[index++] = 128 | code & 63; } else if (code < 55296 || code >= 57344) { bytes[index++] = 224 | code >>> 12; bytes[index++] = 128 | code >>> 6 & 63; bytes[index++] = 128 | code & 63; } else { code = 65536 + ((code & 1023) << 10 | key2.charCodeAt(++i) & 1023); bytes[index++] = 240 | code >>> 18; bytes[index++] = 128 | code >>> 12 & 63; bytes[index++] = 128 | code >>> 6 & 63; bytes[index++] = 128 | code & 63; } } key2 = bytes; } if (key2.length > 64) { key2 = new Md5(true).update(key2).array(); } var oKeyPad = [], iKeyPad = []; for (i = 0; i < 64; ++i) { var b = key2[i] || 0; oKeyPad[i] = 92 ^ b; iKeyPad[i] = 54 ^ b; } Md5.call(this, sharedMemory); this.update(iKeyPad); this.oKeyPad = oKeyPad; this.inner = true; this.sharedMemory = sharedMemory; } HmacMd5.prototype = new Md5(); HmacMd5.prototype.finalize = function() { Md5.prototype.finalize.call(this); if (this.inner) { this.inner = false; var innerHash = this.array(); Md5.call(this, this.sharedMemory); this.update(this.oKeyPad); this.update(innerHash); Md5.prototype.finalize.call(this); } }; var exports = createMethod(); exports.md5 = exports; exports.md5.hmac = createHmacMethod(); if (COMMON_JS) { module.exports = exports; } else { root.md5 = exports; } })(); })(md5); var md5Exports = md5.exports; const scriptInfo$1 = _GM_info; const key = randomString(9) + "_"; function request(url, method, data = void 0, headers = void 0, timeout = 1e4) { if (method === "GET" && data) { url += `?${new URLSearchParams(data).toString()}`; } const finalHeaders = { "User-Agent": _unsafeWindow.navigator.userAgent, "Content-Type": "application/json", ...headers }; return new Promise((resolve, reject) => { const startTime = Date.now(); _GM_xmlhttpRequest({ method, url, headers: finalHeaders, data: method !== "GET" ? JSON.stringify(data) : void 0, timeout, onload: function(response) { const endTime = Date.now(); const duration = endTime - startTime; resolve([response, duration]); }, ontimeout: () => reject(new Error("接口请求超时")), onerror: (error) => { console.error("接口请求失败", error); reject(error); } }); }); } function requestFetch(url, method, data, headers, timeout = 5e3) { const finalHeaders = { "User-Agent": _unsafeWindow.navigator.userAgent, "Content-Type": method === "POST" ? "application/json" : "text/plain;charset=UTF-8", ...headers }; return new Promise((resolve, reject) => { fetch(url, { method, headers: finalHeaders, body: method === "POST" ? JSON.stringify(data) : void 0 }).then((response) => resolve(response.text())).catch(function(error) { reject(error); }); }); } function headi() { let z = Array.from({ length: 4 }, () => Math.floor(Math.random() * 255)).join("."); return { "X-Forwarded-For": z, "X-Real-IP": z }; } function sleep(time) { return new Promise((resolve) => setTimeout(resolve, time)); } function removeHtml(htmlStr) { const textArea = document.createElement("textarea"); textArea.innerHTML = htmlStr; htmlStr = textArea.value; htmlStr = htmlStr.replace(/[\t\r\xa0]/g, " "); htmlStr = htmlStr.replace(/[\u2000-\u200a]/g, " "); htmlStr = htmlStr.replace(//g, "\n"); htmlStr = htmlStr.replace(/<(\/)?(p|div).*?>/g, "\n"); htmlStr = htmlStr.replace(/ {2,}/g, " "); htmlStr = htmlStr.replace(/\n{2,}/g, "\n"); htmlStr = purify.sanitize(htmlStr, { ALLOWED_TAGS: ["img", "br", "sub", "sup", "table", "caption", "thead", "tfoot", "tbody", "tr", "th", "td", "strong"], ALLOWED_ATTR: ["src", "href"], ALLOW_DATA_ATTR: false }); return htmlStr.trim(); } function removeHtml1(htmlStr) { const textArea = document.createElement("textarea"); textArea.innerHTML = htmlStr; htmlStr = textArea.value; htmlStr = htmlStr.replace(/[\t\r\xa0]/g, " "); htmlStr = htmlStr.replace(/[\u2000-\u200a]/g, " "); htmlStr = htmlStr.replace(//g, "\n"); htmlStr = htmlStr.replace(/<(\/)?(p|div).*?>/g, "\n"); htmlStr = htmlStr.replace(/ {2,}/g, " "); htmlStr = htmlStr.replace(/\n{2,}/g, "\n"); htmlStr = purify.sanitize(htmlStr, { ALLOWED_TAGS: ["img", "br", "sub", "sup"], ALLOWED_ATTR: ["src", "href"], ALLOW_DATA_ATTR: false }); return htmlStr.trim(); } function titleClean(title) { return title.replace(/^【.*?】\s*/, "").replace(/\s*(\d+\.\d+分)$/, ""); } function typeChange(typeNumber) { let types = { "单选题": "0", "多选题": "1", "填空题": "2", "判断题": "3", "简答题": "4", "名词解释": "5", "论述题": "6", "计算题": "7", "分录题": "9", "资料题": "10", "连线题": "11", "排序题": "13", "完型填空": "14", "阅读理解": "15", "程序题": "17", "口语题": "18", "听力题": "19", "共用选项题": "20", "测评题": "21", "钟表题": "23", "选词填空": "24", "选做题": "25", "其它": "8" }; return types[typeNumber] ?? "8"; } function typeChange2(typeNumber) { let types = { "0": "单选题", "1": "多选题", "2": "填空题", "3": "判断题", "4": "简答题", "5": "名词解释", "6": "论述题", "7": "计算题", "9": "分录题", "10": "资料题", "11": "连线题", "13": "排序题", "14": "完型填空", "15": "阅读理解", "17": "程序题", "18": "口语题", "19": "听力题", "20": "共用选项题", "21": "测评题", "23": "钟表题", "24": "选词填空", "25": "选做题", "8": "其它" }; return types[typeNumber] ?? "其他"; } function answerFormat(answer) { if (answer instanceof Array) { answer = answer.filter(function(item) { return item !== null; }); for (let i = 0; i < answer.length; i++) { answer[i] = removeHtml(answer[i]); } } else if (typeof answer === "string") { answer = titleClean(answer); } return answer; } function removeSpace(str) { return str.replace(/[\s\p{P}]/gu, ""); } function matchAnswer(answer, options) { if (answer == "" || answer == null || answer == void 0) { return []; } answer = answer.map((item) => removeHtml1(item)); options = options.map((item) => removeHtml1(item)); answer = answerFormat(answer); let isMatch = options.every((item) => { return /[\u4e00-\u9fa5a-zA-Z0-9]/.test(item); }); if (isMatch) { answer = answer.map((item) => removeSpace(item)); options = options.map((item) => removeSpace(item)); } var matchArr = []; for (var i = 0; i < answer.length; i++) { for (var j = 0; j < options.length; j++) { if (answer[i] == options[j]) { matchArr.push(j); } } } return matchArr; } function qc(item) { $(item).find(".answerBg, .textDIV, .eidtDiv").each(function() { ($(this).find(".check_answer").length || $(this).find(".check_answer_dx").length) && $(this).click(); }); $(item).find(".answerBg, .textDIV, .eidtDiv").find("textarea").each(function() { _unsafeWindow.UE.getEditor($(this).attr("name")).ready(function() { this.setContent(""); }); }); $(item).find(":radio, :checkbox").prop("checked", false); $(item).find("textarea").each(function() { _unsafeWindow.UE.getEditor($(this).attr("name")).ready(function() { this.setContent(""); }); }); } function qc1(item) { $(item).find(".before-after, .textDIV, .eidtDiv").each(function() { ($(this).find(".check_answer").length || $(this).find(".check_answer_dx").length) && $(this).click(); }); $(item).find(".before-after, .textDIV, .eidtDiv").find("textarea").each(function() { _unsafeWindow.UE.getEditor($(this).attr("name")).ready(function() { this.setContent(""); }); }); $(item).find(":radio, :checkbox").prop("checked", false); $(item).find("textarea").each(function() { _unsafeWindow.UE.getEditor($(this).attr("name")).ready(function() { this.setContent(""); }); }); } const allowCopy = () => { document.body.oncopy = null; document.body.oncut = null; document.body.onpaste = null; document.body.onselectstart = null; document.body.ondragstart = null; const style = document.createElement("style"); style.innerHTML = ` * { -webkit-user-select: auto !important; -moz-user-select: auto !important; -o-user-select: auto !important; user-select: auto !important; } `; document.head.appendChild(style); }; function isTrue(text2) { return Boolean(String(text2).match(/(正确|是|对|√|T|ri|true)/)); } function isFalse(text2) { return Boolean(String(text2).match(/(错误|否|错|×|F|wr|false)/)); } function msg(content, type = "info") { try { ElementPlus.ElNotification({ // @ts-ignore title: `${scriptInfo$1.script.name} v${scriptInfo$1.script.version}`, // 设置通知标题,使用模板字符串拼接脚本信息 message: content, // 设置通知内容 type, // 设置通知类型,默认为 "info" dangerouslyUseHTMLString: true // 允许使用 HTML 字符串 }); } catch (e) { console.log(e); } } function randomString(len) { let str = ""; for (; str.length < len; str += Math.random().toString(36).substr(2)) ; return str.substr(0, len); } function wapp() { const app = _unsafeWindow[key]; return app; } const waitUntil = (condition, interval = 100) => { return new Promise((resolve) => { const timer = setInterval(() => { if (condition()) { clearInterval(timer); resolve(); } }, interval); }); }; const questionHash = (type, question, options, optionsSort = true) => { let option = Array.from(options).sort(); const optionsStr = option.join(""); const hash = md5Exports.md5(`${type}${question}${optionsStr}`); return hash; }; class Answer { constructor() { } /** * @description: 接口打分,是否有答案,是否匹配 */ static score(answer) { } /** * @description: 批量获取所有答案 */ static async getAllAnswers(questionList) { const promises = [ this.getAnswer3(questionList), this.getAnswer1(questionList) ]; return Promise.all(promises); } /** * @description: 批量获取答案 */ static async getAnswers(questionList) { const promises = [ this.getAnswer3(questionList) ]; return Promise.all(promises); } /** * @description: 批量获取答案(免费接口) */ static async getAnswersFree(questionList) { const promises = [ this.getAnswer1(questionList) // this.getAnswer2(questionList), ]; return Promise.all(promises); } /** * @description: 内置接口1 一之题库 */ static async getAnswer1(questionData) { let headers = headi(); return new Promise((resolve) => { request("http://cx.icodef.com/wyn-nb?v=4", "POST", { question: questionData.question }, headers).then((res) => { let duration = res[1]; try { res = JSON.parse(res[0].responseText); } catch (error) { resolve({ form: "免费题库", answer: null, error, duration }); } let answer = ""; if (res.code === 1) { let data = res.data.replace(/javascript:void\(0\);/g, "").trim().replace(/\n/g, ""); const keywords = ["叛逆", "公众号", "李恒雅", "一之"]; if (keywords.every((keyword) => !data.includes(keyword))) { answer = data.split("#"); } } resolve({ form: "免费题库", answer, duration }); }).catch((error) => { resolve({ form: "免费题库", answer: void 0, msg: error, duration: 5e3 }); }); }); } static async getAnswer2(questionData) { return new Promise((resolve) => { if (![0, 1, 2].includes(parseInt(questionData.type))) { resolve({ form: "muketool", answer: "", duration: "不支持的题型" }); return; } request("https://api.muketool.com/cx/v2/query", "POST", { question: questionData.question, type: parseInt(questionData.type) }, {}).then((res) => { let duration = res[1]; res = JSON.parse(res[0].responseText); resolve({ form: "muketool", answer: res.code === 1 ? res.data.split("#") : "", duration }); }).catch(() => { resolve({ form: "muketool", answer: "" }); }); }); } static async getAnswer3(questionData) { const headers = { "Content-Type": "application/json", "referer": location.href, "v": scriptInfo.version, "s": scriptInfo.author }; const data = { question: questionData.question, // 选项数组 options: questionData.options.map((item) => item), type: questionData.type, questionData: questionData.html.innerHTML, workType: questionData.workType, key: appCache.key ?? "" }; return new Promise((resolve) => { request("http://62.234.36.191/search", "POST", data, headers).then((res) => { let duration = res[1]; res = JSON.parse(res[0].responseText); if (res.code === 200) { resolve({ form: "付费题库", answer: res.data.answer, duration, msg: res.msg }); } else { resolve({ form: "付费题库", answer: "", duration, msg: res.msg }); } }).catch((error) => { resolve({ form: "付费题库", answer: "", error, duration: 10, msg: "请求失败" }); }); }); } /** * @description: 将答案缓存在本地 */ static cacheAnswer(questionData) { const data = { type: questionData.type, question: questionData.question, options: questionData.options, answer: questionData.answer }; const hash = questionHash(data.type, data.question, data.options); let questionList = Cache.get("questionList", []); let index = questionList.findIndex((item) => item.hash === hash); if (index === -1) { questionList.push({ hash, ...data }); } else { questionList[index] = { hash, ...data }; } Cache.set("questionList", questionList); } /** * @description: 从本地缓存获取答案 */ static getCacheAnswer(questionData) { var _a; const hash = questionHash(questionData.type, questionData.question, questionData.options); let questionList = Cache.get("questionList", []); let index = questionList.findIndex((item) => item.hash === hash); if (index === -1) { return { form: "缓存题库", answer: "", error: "未找到缓存", duration: 10, msg: "暂无缓存试题" }; } else { console.log(questionList[index]); return { form: "缓存题库", answer: (_a = questionList[index]) == null ? void 0 : _a.answer, duration: 10 }; } } } const parsePack = (str) => { const pattern = /data:\s*({.*?})\s*\n/g; const result = []; let match; while ((match = pattern.exec(str)) !== null) { const jsonStr = match[1]; try { const json = JSON.parse(jsonStr); result.push(json); } catch (e) { console.log(e); } } return result; }; const aiAsk = async (message, callback, isfinish) => { let config = getApp(); let url = config.gpt[0].api; console.log(url); let data = JSON.stringify({ "model": "gpt-3.5-turbo", "messages": [ { "role": "system", "content": "请只需要回答我的问题不要有多余的话,如果你不知道请返回【我不会】" }, { "role": "user", "content": message } ], "stream": true }); let headers = { "Accept": "application/json", "Authorization": `Bearer ${config.gpt[0].key}`, "Content-Type": "application/json" }; return new Promise((resolve, reject) => { if (!config.gpt[0].key) { callback(`AI响应异常,可能是没有获取KEY,请按下方步骤操作 1. 打开[智普清言](https://chatglm.cn/main/alltoolsdetail) 2. 登录后随便发一条消息即可 3. 返回答题页刷新页面 `); return resolve("暂无KEY"); } _GM_xmlhttpRequest({ method: "POST", url, data, headers, responseType: "stream", onloadstart: async (r) => { console.log(r); let finish = false; const reader = r.response.getReader(); const decoder = new TextDecoder(); while (!finish) { const { done, value } = await reader.read(); if (done) { finish = true; console.log("读取完毕"); isfinish(); break; } const jsonArray = parsePack(decoder.decode(value)); jsonArray.forEach((json) => { if (!json.choices || json.choices.length === 0) { return; } const text2 = json.choices[0].delta.content; if (text2 === void 0 || text2 === "") { return; } callback(text2); }); } } }); }); }; var Typr = {}; Typr.parse = function(buff) { var bin = Typr._bin; var data = new Uint8Array(buff); var offset = 0; bin.readFixed(data, offset); offset += 4; var numTables = bin.readUshort(data, offset); offset += 2; bin.readUshort(data, offset); offset += 2; bin.readUshort(data, offset); offset += 2; bin.readUshort(data, offset); offset += 2; var tags = ["cmap", "head", "hhea", "maxp", "hmtx", "name", "OS/2", "post", "loca", "glyf", "kern", "CFF ", "GPOS", "GSUB", "SVG "]; var obj = { _data: data }; var tabs = {}; for (var i = 0; i < numTables; i++) { var tag = bin.readASCII(data, offset, 4); offset += 4; bin.readUint(data, offset); offset += 4; var toffset = bin.readUint(data, offset); offset += 4; var length = bin.readUint(data, offset); offset += 4; tabs[tag] = { offset: toffset, length }; } for (var i = 0; i < tags.length; i++) { var t = tags[i]; if (tabs[t]) obj[t.trim()] = Typr[t.trim()].parse(data, tabs[t].offset, tabs[t].length, obj); } return obj; }; Typr._tabOffset = function(data, tab) { var bin = Typr._bin; var numTables = bin.readUshort(data, 4); var offset = 12; for (var i = 0; i < numTables; i++) { var tag = bin.readASCII(data, offset, 4); offset += 4; bin.readUint(data, offset); offset += 4; var toffset = bin.readUint(data, offset); offset += 4; bin.readUint(data, offset); offset += 4; if (tag == tab) return toffset; } return 0; }; Typr._bin = { readFixed: function(data, o) { return (data[o] << 8 | data[o + 1]) + (data[o + 2] << 8 | data[o + 3]) / (256 * 256 + 4); }, readF2dot14: function(data, o) { var num = Typr._bin.readShort(data, o); return num / 16384; }, readInt: function(buff, p) { var a = Typr._bin.t.uint8; a[0] = buff[p + 3]; a[1] = buff[p + 2]; a[2] = buff[p + 1]; a[3] = buff[p]; return Typr._bin.t.int32[0]; }, readInt8: function(buff, p) { var a = Typr._bin.t.uint8; a[0] = buff[p]; return Typr._bin.t.int8[0]; }, readShort: function(buff, p) { var a = Typr._bin.t.uint8; a[1] = buff[p]; a[0] = buff[p + 1]; return Typr._bin.t.int16[0]; }, readUshort: function(buff, p) { return buff[p] << 8 | buff[p + 1]; }, readUshorts: function(buff, p, len) { var arr = []; for (var i = 0; i < len; i++) arr.push(Typr._bin.readUshort(buff, p + i * 2)); return arr; }, readUint: function(buff, p) { var a = Typr._bin.t.uint8; a[3] = buff[p]; a[2] = buff[p + 1]; a[1] = buff[p + 2]; a[0] = buff[p + 3]; return Typr._bin.t.uint32[0]; }, readUint64: function(buff, p) { return Typr._bin.readUint(buff, p) * (4294967295 + 1) + Typr._bin.readUint(buff, p + 4); }, readASCII: function(buff, p, l) { var s = ""; for (var i = 0; i < l; i++) s += String.fromCharCode(buff[p + i]); return s; }, readUnicode: function(buff, p, l) { var s = ""; for (var i = 0; i < l; i++) { var c = buff[p++] << 8 | buff[p++]; s += String.fromCharCode(c); } return s; }, _tdec: window["TextDecoder"] ? new window["TextDecoder"]() : null, readUTF8: function(buff, p, l) { var tdec = Typr._bin._tdec; if (tdec && p == 0 && l == buff.length) return tdec["decode"](buff); return Typr._bin.readASCII(buff, p, l); }, readBytes: function(buff, p, l) { var arr = []; for (var i = 0; i < l; i++) arr.push(buff[p + i]); return arr; }, readASCIIArray: function(buff, p, l) { var s = []; for (var i = 0; i < l; i++) s.push(String.fromCharCode(buff[p + i])); return s; } }; Typr._bin.t = { buff: new ArrayBuffer(8) }; Typr._bin.t.int8 = new Int8Array(Typr._bin.t.buff); Typr._bin.t.uint8 = new Uint8Array(Typr._bin.t.buff); Typr._bin.t.int16 = new Int16Array(Typr._bin.t.buff); Typr._bin.t.uint16 = new Uint16Array(Typr._bin.t.buff); Typr._bin.t.int32 = new Int32Array(Typr._bin.t.buff); Typr._bin.t.uint32 = new Uint32Array(Typr._bin.t.buff); Typr._lctf = {}; Typr._lctf.parse = function(data, offset, length, font, subt) { var bin = Typr._bin; var obj = {}; var offset0 = offset; bin.readFixed(data, offset); offset += 4; var offScriptList = bin.readUshort(data, offset); offset += 2; var offFeatureList = bin.readUshort(data, offset); offset += 2; var offLookupList = bin.readUshort(data, offset); offset += 2; obj.scriptList = Typr._lctf.readScriptList(data, offset0 + offScriptList); obj.featureList = Typr._lctf.readFeatureList(data, offset0 + offFeatureList); obj.lookupList = Typr._lctf.readLookupList(data, offset0 + offLookupList, subt); return obj; }; Typr._lctf.readLookupList = function(data, offset, subt) { var bin = Typr._bin; var offset0 = offset; var obj = []; var count = bin.readUshort(data, offset); offset += 2; for (var i = 0; i < count; i++) { var noff = bin.readUshort(data, offset); offset += 2; var lut = Typr._lctf.readLookupTable(data, offset0 + noff, subt); obj.push(lut); } return obj; }; Typr._lctf.readLookupTable = function(data, offset, subt) { var bin = Typr._bin; var offset0 = offset; var obj = { tabs: [] }; obj.ltype = bin.readUshort(data, offset); offset += 2; obj.flag = bin.readUshort(data, offset); offset += 2; var cnt = bin.readUshort(data, offset); offset += 2; for (var i = 0; i < cnt; i++) { var noff = bin.readUshort(data, offset); offset += 2; var tab = subt(data, obj.ltype, offset0 + noff); obj.tabs.push(tab); } return obj; }; Typr._lctf.numOfOnes = function(n) { var num = 0; for (var i = 0; i < 32; i++) if ((n >>> i & 1) != 0) num++; return num; }; Typr._lctf.readClassDef = function(data, offset) { var bin = Typr._bin; var obj = []; var format = bin.readUshort(data, offset); offset += 2; if (format == 1) { var startGlyph = bin.readUshort(data, offset); offset += 2; var glyphCount = bin.readUshort(data, offset); offset += 2; for (var i = 0; i < glyphCount; i++) { obj.push(startGlyph + i); obj.push(startGlyph + i); obj.push(bin.readUshort(data, offset)); offset += 2; } } if (format == 2) { var count = bin.readUshort(data, offset); offset += 2; for (var i = 0; i < count; i++) { obj.push(bin.readUshort(data, offset)); offset += 2; obj.push(bin.readUshort(data, offset)); offset += 2; obj.push(bin.readUshort(data, offset)); offset += 2; } } return obj; }; Typr._lctf.getInterval = function(tab, val) { for (var i = 0; i < tab.length; i += 3) { var start = tab[i], end = tab[i + 1]; tab[i + 2]; if (start <= val && val <= end) return i; } return -1; }; Typr._lctf.readValueRecord = function(data, offset, valFmt) { var bin = Typr._bin; var arr = []; arr.push(valFmt & 1 ? bin.readShort(data, offset) : 0); offset += valFmt & 1 ? 2 : 0; arr.push(valFmt & 2 ? bin.readShort(data, offset) : 0); offset += valFmt & 2 ? 2 : 0; arr.push(valFmt & 4 ? bin.readShort(data, offset) : 0); offset += valFmt & 4 ? 2 : 0; arr.push(valFmt & 8 ? bin.readShort(data, offset) : 0); offset += valFmt & 8 ? 2 : 0; return arr; }; Typr._lctf.readCoverage = function(data, offset) { var bin = Typr._bin; var cvg = {}; cvg.fmt = bin.readUshort(data, offset); offset += 2; var count = bin.readUshort(data, offset); offset += 2; if (cvg.fmt == 1) cvg.tab = bin.readUshorts(data, offset, count); if (cvg.fmt == 2) cvg.tab = bin.readUshorts(data, offset, count * 3); return cvg; }; Typr._lctf.coverageIndex = function(cvg, val) { var tab = cvg.tab; if (cvg.fmt == 1) return tab.indexOf(val); if (cvg.fmt == 2) { var ind = Typr._lctf.getInterval(tab, val); if (ind != -1) return tab[ind + 2] + (val - tab[ind]); } return -1; }; Typr._lctf.readFeatureList = function(data, offset) { var bin = Typr._bin; var offset0 = offset; var obj = []; var count = bin.readUshort(data, offset); offset += 2; for (var i = 0; i < count; i++) { var tag = bin.readASCII(data, offset, 4); offset += 4; var noff = bin.readUshort(data, offset); offset += 2; obj.push({ tag: tag.trim(), tab: Typr._lctf.readFeatureTable(data, offset0 + noff) }); } return obj; }; Typr._lctf.readFeatureTable = function(data, offset) { var bin = Typr._bin; bin.readUshort(data, offset); offset += 2; var lookupCount = bin.readUshort(data, offset); offset += 2; var indices = []; for (var i = 0; i < lookupCount; i++) indices.push(bin.readUshort(data, offset + 2 * i)); return indices; }; Typr._lctf.readScriptList = function(data, offset) { var bin = Typr._bin; var offset0 = offset; var obj = {}; var count = bin.readUshort(data, offset); offset += 2; for (var i = 0; i < count; i++) { var tag = bin.readASCII(data, offset, 4); offset += 4; var noff = bin.readUshort(data, offset); offset += 2; obj[tag.trim()] = Typr._lctf.readScriptTable(data, offset0 + noff); } return obj; }; Typr._lctf.readScriptTable = function(data, offset) { var bin = Typr._bin; var offset0 = offset; var obj = {}; var defLangSysOff = bin.readUshort(data, offset); offset += 2; obj.default = Typr._lctf.readLangSysTable(data, offset0 + defLangSysOff); var langSysCount = bin.readUshort(data, offset); offset += 2; for (var i = 0; i < langSysCount; i++) { var tag = bin.readASCII(data, offset, 4); offset += 4; var langSysOff = bin.readUshort(data, offset); offset += 2; obj[tag.trim()] = Typr._lctf.readLangSysTable(data, offset0 + langSysOff); } return obj; }; Typr._lctf.readLangSysTable = function(data, offset) { var bin = Typr._bin; var obj = {}; bin.readUshort(data, offset); offset += 2; obj.reqFeature = bin.readUshort(data, offset); offset += 2; var featureCount = bin.readUshort(data, offset); offset += 2; obj.features = bin.readUshorts(data, offset, featureCount); return obj; }; Typr.CFF = {}; Typr.CFF.parse = function(data, offset, length) { var bin = Typr._bin; data = new Uint8Array(data.buffer, offset, length); offset = 0; data[offset]; offset++; data[offset]; offset++; data[offset]; offset++; data[offset]; offset++; var ninds = []; offset = Typr.CFF.readIndex(data, offset, ninds); var names = []; for (var i = 0; i < ninds.length - 1; i++) names.push(bin.readASCII(data, offset + ninds[i], ninds[i + 1] - ninds[i])); offset += ninds[ninds.length - 1]; var tdinds = []; offset = Typr.CFF.readIndex(data, offset, tdinds); var topDicts = []; for (var i = 0; i < tdinds.length - 1; i++) topDicts.push(Typr.CFF.readDict(data, offset + tdinds[i], offset + tdinds[i + 1])); offset += tdinds[tdinds.length - 1]; var topdict = topDicts[0]; var sinds = []; offset = Typr.CFF.readIndex(data, offset, sinds); var strings = []; for (var i = 0; i < sinds.length - 1; i++) strings.push(bin.readASCII(data, offset + sinds[i], sinds[i + 1] - sinds[i])); offset += sinds[sinds.length - 1]; Typr.CFF.readSubrs(data, offset, topdict); if (topdict.CharStrings) { offset = topdict.CharStrings; var sinds = []; offset = Typr.CFF.readIndex(data, offset, sinds); var cstr = []; for (var i = 0; i < sinds.length - 1; i++) cstr.push(bin.readBytes(data, offset + sinds[i], sinds[i + 1] - sinds[i])); topdict.CharStrings = cstr; } if (topdict.Encoding) topdict.Encoding = Typr.CFF.readEncoding(data, topdict.Encoding, topdict.CharStrings.length); if (topdict.charset) topdict.charset = Typr.CFF.readCharset(data, topdict.charset, topdict.CharStrings.length); if (topdict.Private) { offset = topdict.Private[1]; topdict.Private = Typr.CFF.readDict(data, offset, offset + topdict.Private[0]); if (topdict.Private.Subrs) Typr.CFF.readSubrs(data, offset + topdict.Private.Subrs, topdict.Private); } var obj = {}; for (var p in topdict) { if (["FamilyName", "FullName", "Notice", "version", "Copyright"].indexOf(p) != -1) obj[p] = strings[topdict[p] - 426 + 35]; else obj[p] = topdict[p]; } return obj; }; Typr.CFF.readSubrs = function(data, offset, obj) { var bin = Typr._bin; var gsubinds = []; offset = Typr.CFF.readIndex(data, offset, gsubinds); var bias, nSubrs = gsubinds.length; if (nSubrs < 1240) bias = 107; else if (nSubrs < 33900) bias = 1131; else bias = 32768; obj.Bias = bias; obj.Subrs = []; for (var i = 0; i < gsubinds.length - 1; i++) obj.Subrs.push(bin.readBytes(data, offset + gsubinds[i], gsubinds[i + 1] - gsubinds[i])); }; Typr.CFF.tableSE = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 0, 111, 112, 113, 114, 0, 115, 116, 117, 118, 119, 120, 121, 122, 0, 123, 0, 124, 125, 126, 127, 128, 129, 130, 131, 0, 132, 133, 0, 134, 135, 136, 137, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 138, 0, 139, 0, 0, 0, 0, 140, 141, 142, 143, 0, 0, 0, 0, 0, 144, 0, 0, 0, 145, 0, 0, 146, 147, 148, 149, 0, 0, 0, 0]; Typr.CFF.glyphByUnicode = function(cff, code) { for (var i = 0; i < cff.charset.length; i++) if (cff.charset[i] == code) return i; return -1; }; Typr.CFF.glyphBySE = function(cff, charcode) { if (charcode < 0 || charcode > 255) return -1; return Typr.CFF.glyphByUnicode(cff, Typr.CFF.tableSE[charcode]); }; Typr.CFF.readEncoding = function(data, offset, num) { Typr._bin; var array = [".notdef"]; var format = data[offset]; offset++; if (format == 0) { var nCodes = data[offset]; offset++; for (var i = 0; i < nCodes; i++) array.push(data[offset + i]); } else throw "error: unknown encoding format: " + format; return array; }; Typr.CFF.readCharset = function(data, offset, num) { var bin = Typr._bin; var charset = [".notdef"]; var format = data[offset]; offset++; if (format == 0) { for (var i = 0; i < num; i++) { var first = bin.readUshort(data, offset); offset += 2; charset.push(first); } } else if (format == 1 || format == 2) { while (charset.length < num) { var first = bin.readUshort(data, offset); offset += 2; var nLeft = 0; if (format == 1) { nLeft = data[offset]; offset++; } else { nLeft = bin.readUshort(data, offset); offset += 2; } for (var i = 0; i <= nLeft; i++) { charset.push(first); first++; } } } else throw "error: format: " + format; return charset; }; Typr.CFF.readIndex = function(data, offset, inds) { var bin = Typr._bin; var count = bin.readUshort(data, offset); offset += 2; var offsize = data[offset]; offset++; if (offsize == 1) for (var i = 0; i < count + 1; i++) inds.push(data[offset + i]); else if (offsize == 2) for (var i = 0; i < count + 1; i++) inds.push(bin.readUshort(data, offset + i * 2)); else if (offsize == 3) for (var i = 0; i < count + 1; i++) inds.push(bin.readUint(data, offset + i * 3 - 1) & 16777215); else if (count != 0) throw "unsupported offset size: " + offsize + ", count: " + count; offset += (count + 1) * offsize; return offset - 1; }; Typr.CFF.getCharString = function(data, offset, o) { var bin = Typr._bin; var b0 = data[offset], b1 = data[offset + 1]; data[offset + 2]; data[offset + 3]; data[offset + 4]; var vs = 1; var op = null, val = null; if (b0 <= 20) { op = b0; vs = 1; } if (b0 == 12) { op = b0 * 100 + b1; vs = 2; } if (21 <= b0 && b0 <= 27) { op = b0; vs = 1; } if (b0 == 28) { val = bin.readShort(data, offset + 1); vs = 3; } if (29 <= b0 && b0 <= 31) { op = b0; vs = 1; } if (32 <= b0 && b0 <= 246) { val = b0 - 139; vs = 1; } if (247 <= b0 && b0 <= 250) { val = (b0 - 247) * 256 + b1 + 108; vs = 2; } if (251 <= b0 && b0 <= 254) { val = -(b0 - 251) * 256 - b1 - 108; vs = 2; } if (b0 == 255) { val = bin.readInt(data, offset + 1) / 65535; vs = 5; } o.val = val != null ? val : "o" + op; o.size = vs; }; Typr.CFF.readCharString = function(data, offset, length) { var end = offset + length; var bin = Typr._bin; var arr = []; while (offset < end) { var b0 = data[offset], b1 = data[offset + 1]; data[offset + 2]; data[offset + 3]; data[offset + 4]; var vs = 1; var op = null, val = null; if (b0 <= 20) { op = b0; vs = 1; } if (b0 == 12) { op = b0 * 100 + b1; vs = 2; } if (b0 == 19 || b0 == 20) { op = b0; vs = 2; } if (21 <= b0 && b0 <= 27) { op = b0; vs = 1; } if (b0 == 28) { val = bin.readShort(data, offset + 1); vs = 3; } if (29 <= b0 && b0 <= 31) { op = b0; vs = 1; } if (32 <= b0 && b0 <= 246) { val = b0 - 139; vs = 1; } if (247 <= b0 && b0 <= 250) { val = (b0 - 247) * 256 + b1 + 108; vs = 2; } if (251 <= b0 && b0 <= 254) { val = -(b0 - 251) * 256 - b1 - 108; vs = 2; } if (b0 == 255) { val = bin.readInt(data, offset + 1) / 65535; vs = 5; } arr.push(val != null ? val : "o" + op); offset += vs; } return arr; }; Typr.CFF.readDict = function(data, offset, end) { var bin = Typr._bin; var dict = {}; var carr = []; while (offset < end) { var b0 = data[offset], b1 = data[offset + 1]; data[offset + 2]; data[offset + 3]; data[offset + 4]; var vs = 1; var key2 = null, val = null; if (b0 == 28) { val = bin.readShort(data, offset + 1); vs = 3; } if (b0 == 29) { val = bin.readInt(data, offset + 1); vs = 5; } if (32 <= b0 && b0 <= 246) { val = b0 - 139; vs = 1; } if (247 <= b0 && b0 <= 250) { val = (b0 - 247) * 256 + b1 + 108; vs = 2; } if (251 <= b0 && b0 <= 254) { val = -(b0 - 251) * 256 - b1 - 108; vs = 2; } if (b0 == 255) { val = bin.readInt(data, offset + 1) / 65535; vs = 5; throw "unknown number"; } if (b0 == 30) { var nibs = []; vs = 1; while (true) { var b = data[offset + vs]; vs++; var nib0 = b >> 4, nib1 = b & 15; if (nib0 != 15) nibs.push(nib0); if (nib1 != 15) nibs.push(nib1); if (nib1 == 15) break; } var s = ""; var chars = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ".", "e", "e-", "reserved", "-", "endOfNumber"]; for (var i = 0; i < nibs.length; i++) s += chars[nibs[i]]; val = parseFloat(s); } if (b0 <= 21) { var keys = ["version", "Notice", "FullName", "FamilyName", "Weight", "FontBBox", "BlueValues", "OtherBlues", "FamilyBlues", "FamilyOtherBlues", "StdHW", "StdVW", "escape", "UniqueID", "XUID", "charset", "Encoding", "CharStrings", "Private", "Subrs", "defaultWidthX", "nominalWidthX"]; key2 = keys[b0]; vs = 1; if (b0 == 12) { var keys = ["Copyright", "isFixedPitch", "ItalicAngle", "UnderlinePosition", "UnderlineThickness", "PaintType", "CharstringType", "FontMatrix", "StrokeWidth", "BlueScale", "BlueShift", "BlueFuzz", "StemSnapH", "StemSnapV", "ForceBold", 0, 0, "LanguageGroup", "ExpansionFactor", "initialRandomSeed", "SyntheticBase", "PostScript", "BaseFontName", "BaseFontBlend", 0, 0, 0, 0, 0, 0, "ROS", "CIDFontVersion", "CIDFontRevision", "CIDFontType", "CIDCount", "UIDBase", "FDArray", "FDSelect", "FontName"]; key2 = keys[b1]; vs = 2; } } if (key2 != null) { dict[key2] = carr.length == 1 ? carr[0] : carr; carr = []; } else carr.push(val); offset += vs; } return dict; }; Typr.cmap = {}; Typr.cmap.parse = function(data, offset, length) { data = new Uint8Array(data.buffer, offset, length); offset = 0; var bin = Typr._bin; var obj = {}; bin.readUshort(data, offset); offset += 2; var numTables = bin.readUshort(data, offset); offset += 2; var offs = []; obj.tables = []; for (var i = 0; i < numTables; i++) { var platformID = bin.readUshort(data, offset); offset += 2; var encodingID = bin.readUshort(data, offset); offset += 2; var noffset = bin.readUint(data, offset); offset += 4; var id = "p" + platformID + "e" + encodingID; var tind = offs.indexOf(noffset); if (tind == -1) { tind = obj.tables.length; var subt; offs.push(noffset); var format = bin.readUshort(data, noffset); if (format == 0) subt = Typr.cmap.parse0(data, noffset); else if (format == 4) subt = Typr.cmap.parse4(data, noffset); else if (format == 6) subt = Typr.cmap.parse6(data, noffset); else if (format == 12) subt = Typr.cmap.parse12(data, noffset); else console.log("unknown format: " + format, platformID, encodingID, noffset); obj.tables.push(subt); } if (obj[id] != null) throw "multiple tables for one platform+encoding"; obj[id] = tind; } return obj; }; Typr.cmap.parse0 = function(data, offset) { var bin = Typr._bin; var obj = {}; obj.format = bin.readUshort(data, offset); offset += 2; var len = bin.readUshort(data, offset); offset += 2; bin.readUshort(data, offset); offset += 2; obj.map = []; for (var i = 0; i < len - 6; i++) obj.map.push(data[offset + i]); return obj; }; Typr.cmap.parse4 = function(data, offset) { var bin = Typr._bin; var offset0 = offset; var obj = {}; obj.format = bin.readUshort(data, offset); offset += 2; var length = bin.readUshort(data, offset); offset += 2; bin.readUshort(data, offset); offset += 2; var segCountX2 = bin.readUshort(data, offset); offset += 2; var segCount = segCountX2 / 2; obj.searchRange = bin.readUshort(data, offset); offset += 2; obj.entrySelector = bin.readUshort(data, offset); offset += 2; obj.rangeShift = bin.readUshort(data, offset); offset += 2; obj.endCount = bin.readUshorts(data, offset, segCount); offset += segCount * 2; offset += 2; obj.startCount = bin.readUshorts(data, offset, segCount); offset += segCount * 2; obj.idDelta = []; for (var i = 0; i < segCount; i++) { obj.idDelta.push(bin.readShort(data, offset)); offset += 2; } obj.idRangeOffset = bin.readUshorts(data, offset, segCount); offset += segCount * 2; obj.glyphIdArray = []; while (offset < offset0 + length) { obj.glyphIdArray.push(bin.readUshort(data, offset)); offset += 2; } return obj; }; Typr.cmap.parse6 = function(data, offset) { var bin = Typr._bin; var obj = {}; obj.format = bin.readUshort(data, offset); offset += 2; bin.readUshort(data, offset); offset += 2; bin.readUshort(data, offset); offset += 2; obj.firstCode = bin.readUshort(data, offset); offset += 2; var entryCount = bin.readUshort(data, offset); offset += 2; obj.glyphIdArray = []; for (var i = 0; i < entryCount; i++) { obj.glyphIdArray.push(bin.readUshort(data, offset)); offset += 2; } return obj; }; Typr.cmap.parse12 = function(data, offset) { var bin = Typr._bin; var obj = {}; obj.format = bin.readUshort(data, offset); offset += 2; offset += 2; bin.readUint(data, offset); offset += 4; bin.readUint(data, offset); offset += 4; var nGroups = bin.readUint(data, offset); offset += 4; obj.groups = []; for (var i = 0; i < nGroups; i++) { var off = offset + i * 12; var startCharCode = bin.readUint(data, off + 0); var endCharCode = bin.readUint(data, off + 4); var startGlyphID = bin.readUint(data, off + 8); obj.groups.push([startCharCode, endCharCode, startGlyphID]); } return obj; }; Typr.glyf = {}; Typr.glyf.parse = function(data, offset, length, font) { var obj = []; for (var g = 0; g < font.maxp.numGlyphs; g++) obj.push(null); return obj; }; Typr.glyf._parseGlyf = function(font, g) { var bin = Typr._bin; var data = font._data; var offset = Typr._tabOffset(data, "glyf") + font.loca[g]; if (font.loca[g] == font.loca[g + 1]) return null; var gl = {}; gl.noc = bin.readShort(data, offset); offset += 2; gl.xMin = bin.readShort(data, offset); offset += 2; gl.yMin = bin.readShort(data, offset); offset += 2; gl.xMax = bin.readShort(data, offset); offset += 2; gl.yMax = bin.readShort(data, offset); offset += 2; if (gl.xMin >= gl.xMax || gl.yMin >= gl.yMax) return null; if (gl.noc > 0) { gl.endPts = []; for (var i = 0; i < gl.noc; i++) { gl.endPts.push(bin.readUshort(data, offset)); offset += 2; } var instructionLength = bin.readUshort(data, offset); offset += 2; if (data.length - offset < instructionLength) return null; gl.instructions = bin.readBytes(data, offset, instructionLength); offset += instructionLength; var crdnum = gl.endPts[gl.noc - 1] + 1; gl.flags = []; for (var i = 0; i < crdnum; i++) { var flag = data[offset]; offset++; gl.flags.push(flag); if ((flag & 8) != 0) { var rep = data[offset]; offset++; for (var j = 0; j < rep; j++) { gl.flags.push(flag); i++; } } } gl.xs = []; for (var i = 0; i < crdnum; i++) { var i8 = (gl.flags[i] & 2) != 0, same = (gl.flags[i] & 16) != 0; if (i8) { gl.xs.push(same ? data[offset] : -data[offset]); offset++; } else { if (same) gl.xs.push(0); else { gl.xs.push(bin.readShort(data, offset)); offset += 2; } } } gl.ys = []; for (var i = 0; i < crdnum; i++) { var i8 = (gl.flags[i] & 4) != 0, same = (gl.flags[i] & 32) != 0; if (i8) { gl.ys.push(same ? data[offset] : -data[offset]); offset++; } else { if (same) gl.ys.push(0); else { gl.ys.push(bin.readShort(data, offset)); offset += 2; } } } var x = 0, y = 0; for (var i = 0; i < crdnum; i++) { x += gl.xs[i]; y += gl.ys[i]; gl.xs[i] = x; gl.ys[i] = y; } } else { var ARG_1_AND_2_ARE_WORDS = 1 << 0; var ARGS_ARE_XY_VALUES = 1 << 1; var WE_HAVE_A_SCALE = 1 << 3; var MORE_COMPONENTS = 1 << 5; var WE_HAVE_AN_X_AND_Y_SCALE = 1 << 6; var WE_HAVE_A_TWO_BY_TWO = 1 << 7; var WE_HAVE_INSTRUCTIONS = 1 << 8; gl.parts = []; var flags; do { flags = bin.readUshort(data, offset); offset += 2; var part = { m: { a: 1, b: 0, c: 0, d: 1, tx: 0, ty: 0 }, p1: -1, p2: -1 }; gl.parts.push(part); part.glyphIndex = bin.readUshort(data, offset); offset += 2; if (flags & ARG_1_AND_2_ARE_WORDS) { var arg1 = bin.readShort(data, offset); offset += 2; var arg2 = bin.readShort(data, offset); offset += 2; } else { var arg1 = bin.readInt8(data, offset); offset++; var arg2 = bin.readInt8(data, offset); offset++; } if (flags & ARGS_ARE_XY_VALUES) { part.m.tx = arg1; part.m.ty = arg2; } else { part.p1 = arg1; part.p2 = arg2; } if (flags & WE_HAVE_A_SCALE) { part.m.a = part.m.d = bin.readF2dot14(data, offset); offset += 2; } else if (flags & WE_HAVE_AN_X_AND_Y_SCALE) { part.m.a = bin.readF2dot14(data, offset); offset += 2; part.m.d = bin.readF2dot14(data, offset); offset += 2; } else if (flags & WE_HAVE_A_TWO_BY_TWO) { part.m.a = bin.readF2dot14(data, offset); offset += 2; part.m.b = bin.readF2dot14(data, offset); offset += 2; part.m.c = bin.readF2dot14(data, offset); offset += 2; part.m.d = bin.readF2dot14(data, offset); offset += 2; } } while (flags & MORE_COMPONENTS); if (flags & WE_HAVE_INSTRUCTIONS) { var numInstr = bin.readUshort(data, offset); offset += 2; gl.instr = []; for (var i = 0; i < numInstr; i++) { gl.instr.push(data[offset]); offset++; } } } return gl; }; Typr.GPOS = {}; Typr.GPOS.parse = function(data, offset, length, font) { return Typr._lctf.parse(data, offset, length, font, Typr.GPOS.subt); }; Typr.GPOS.subt = function(data, ltype, offset) { if (ltype != 2) return null; var bin = Typr._bin, offset0 = offset, tab = {}; tab.format = bin.readUshort(data, offset); offset += 2; var covOff = bin.readUshort(data, offset); offset += 2; tab.coverage = Typr._lctf.readCoverage(data, covOff + offset0); tab.valFmt1 = bin.readUshort(data, offset); offset += 2; tab.valFmt2 = bin.readUshort(data, offset); offset += 2; var ones1 = Typr._lctf.numOfOnes(tab.valFmt1); var ones2 = Typr._lctf.numOfOnes(tab.valFmt2); if (tab.format == 1) { tab.pairsets = []; var count = bin.readUshort(data, offset); offset += 2; for (var i = 0; i < count; i++) { var psoff = bin.readUshort(data, offset); offset += 2; psoff += offset0; var pvcount = bin.readUshort(data, psoff); psoff += 2; var arr = []; for (var j = 0; j < pvcount; j++) { var gid2 = bin.readUshort(data, psoff); psoff += 2; var value1, value2; if (tab.valFmt1 != 0) { value1 = Typr._lctf.readValueRecord(data, psoff, tab.valFmt1); psoff += ones1 * 2; } if (tab.valFmt2 != 0) { value2 = Typr._lctf.readValueRecord(data, psoff, tab.valFmt2); psoff += ones2 * 2; } arr.push({ gid2, val1: value1, val2: value2 }); } tab.pairsets.push(arr); } } if (tab.format == 2) { var classDef1 = bin.readUshort(data, offset); offset += 2; var classDef2 = bin.readUshort(data, offset); offset += 2; var class1Count = bin.readUshort(data, offset); offset += 2; var class2Count = bin.readUshort(data, offset); offset += 2; tab.classDef1 = Typr._lctf.readClassDef(data, offset0 + classDef1); tab.classDef2 = Typr._lctf.readClassDef(data, offset0 + classDef2); tab.matrix = []; for (var i = 0; i < class1Count; i++) { var row = []; for (var j = 0; j < class2Count; j++) { var value1 = null, value2 = null; if (tab.valFmt1 != 0) { value1 = Typr._lctf.readValueRecord(data, offset, tab.valFmt1); offset += ones1 * 2; } if (tab.valFmt2 != 0) { value2 = Typr._lctf.readValueRecord(data, offset, tab.valFmt2); offset += ones2 * 2; } row.push({ val1: value1, val2: value2 }); } tab.matrix.push(row); } } return tab; }; Typr.GSUB = {}; Typr.GSUB.parse = function(data, offset, length, font) { return Typr._lctf.parse(data, offset, length, font, Typr.GSUB.subt); }; Typr.GSUB.subt = function(data, ltype, offset) { var bin = Typr._bin, offset0 = offset, tab = {}; if (ltype != 1 && ltype != 4 && ltype != 5) return null; tab.fmt = bin.readUshort(data, offset); offset += 2; var covOff = bin.readUshort(data, offset); offset += 2; tab.coverage = Typr._lctf.readCoverage(data, covOff + offset0); if (ltype == 1) { if (tab.fmt == 1) { tab.delta = bin.readShort(data, offset); offset += 2; } else if (tab.fmt == 2) { var cnt = bin.readUshort(data, offset); offset += 2; tab.newg = bin.readUshorts(data, offset, cnt); offset += tab.newg.length * 2; } } else if (ltype == 4) { tab.vals = []; var cnt = bin.readUshort(data, offset); offset += 2; for (var i = 0; i < cnt; i++) { var loff = bin.readUshort(data, offset); offset += 2; tab.vals.push(Typr.GSUB.readLigatureSet(data, offset0 + loff)); } } else if (ltype == 5) { if (tab.fmt == 2) { var cDefOffset = bin.readUshort(data, offset); offset += 2; tab.cDef = Typr._lctf.readClassDef(data, offset0 + cDefOffset); tab.scset = []; var subClassSetCount = bin.readUshort(data, offset); offset += 2; for (var i = 0; i < subClassSetCount; i++) { var scsOff = bin.readUshort(data, offset); offset += 2; tab.scset.push(scsOff == 0 ? null : Typr.GSUB.readSubClassSet(data, offset0 + scsOff)); } } else console.log("unknown table format", tab.fmt); } return tab; }; Typr.GSUB.readSubClassSet = function(data, offset) { var rUs = Typr._bin.readUshort, offset0 = offset, lset = []; var cnt = rUs(data, offset); offset += 2; for (var i = 0; i < cnt; i++) { var loff = rUs(data, offset); offset += 2; lset.push(Typr.GSUB.readSubClassRule(data, offset0 + loff)); } return lset; }; Typr.GSUB.readSubClassRule = function(data, offset) { var rUs = Typr._bin.readUshort, rule2 = {}; var gcount = rUs(data, offset); offset += 2; var scount = rUs(data, offset); offset += 2; rule2.input = []; for (var i = 0; i < gcount - 1; i++) { rule2.input.push(rUs(data, offset)); offset += 2; } rule2.substLookupRecords = Typr.GSUB.readSubstLookupRecords(data, offset, scount); return rule2; }; Typr.GSUB.readSubstLookupRecords = function(data, offset, cnt) { var rUs = Typr._bin.readUshort; var out = []; for (var i = 0; i < cnt; i++) { out.push(rUs(data, offset), rUs(data, offset + 2)); offset += 4; } return out; }; Typr.GSUB.readChainSubClassSet = function(data, offset) { var bin = Typr._bin, offset0 = offset, lset = []; var cnt = bin.readUshort(data, offset); offset += 2; for (var i = 0; i < cnt; i++) { var loff = bin.readUshort(data, offset); offset += 2; lset.push(Typr.GSUB.readChainSubClassRule(data, offset0 + loff)); } return lset; }; Typr.GSUB.readChainSubClassRule = function(data, offset) { var bin = Typr._bin, rule2 = {}; var pps = ["backtrack", "input", "lookahead"]; for (var pi = 0; pi < pps.length; pi++) { var cnt = bin.readUshort(data, offset); offset += 2; if (pi == 1) cnt--; rule2[pps[pi]] = bin.readUshorts(data, offset, cnt); offset += rule2[pps[pi]].length * 2; } var cnt = bin.readUshort(data, offset); offset += 2; rule2.subst = bin.readUshorts(data, offset, cnt * 2); offset += rule2.subst.length * 2; return rule2; }; Typr.GSUB.readLigatureSet = function(data, offset) { var bin = Typr._bin, offset0 = offset, lset = []; var lcnt = bin.readUshort(data, offset); offset += 2; for (var j = 0; j < lcnt; j++) { var loff = bin.readUshort(data, offset); offset += 2; lset.push(Typr.GSUB.readLigature(data, offset0 + loff)); } return lset; }; Typr.GSUB.readLigature = function(data, offset) { var bin = Typr._bin, lig = { chain: [] }; lig.nglyph = bin.readUshort(data, offset); offset += 2; var ccnt = bin.readUshort(data, offset); offset += 2; for (var k = 0; k < ccnt - 1; k++) { lig.chain.push(bin.readUshort(data, offset)); offset += 2; } return lig; }; Typr.head = {}; Typr.head.parse = function(data, offset, length) { var bin = Typr._bin; var obj = {}; bin.readFixed(data, offset); offset += 4; obj.fontRevision = bin.readFixed(data, offset); offset += 4; bin.readUint(data, offset); offset += 4; bin.readUint(data, offset); offset += 4; obj.flags = bin.readUshort(data, offset); offset += 2; obj.unitsPerEm = bin.readUshort(data, offset); offset += 2; obj.created = bin.readUint64(data, offset); offset += 8; obj.modified = bin.readUint64(data, offset); offset += 8; obj.xMin = bin.readShort(data, offset); offset += 2; obj.yMin = bin.readShort(data, offset); offset += 2; obj.xMax = bin.readShort(data, offset); offset += 2; obj.yMax = bin.readShort(data, offset); offset += 2; obj.macStyle = bin.readUshort(data, offset); offset += 2; obj.lowestRecPPEM = bin.readUshort(data, offset); offset += 2; obj.fontDirectionHint = bin.readShort(data, offset); offset += 2; obj.indexToLocFormat = bin.readShort(data, offset); offset += 2; obj.glyphDataFormat = bin.readShort(data, offset); offset += 2; return obj; }; Typr.hhea = {}; Typr.hhea.parse = function(data, offset, length) { var bin = Typr._bin; var obj = {}; bin.readFixed(data, offset); offset += 4; obj.ascender = bin.readShort(data, offset); offset += 2; obj.descender = bin.readShort(data, offset); offset += 2; obj.lineGap = bin.readShort(data, offset); offset += 2; obj.advanceWidthMax = bin.readUshort(data, offset); offset += 2; obj.minLeftSideBearing = bin.readShort(data, offset); offset += 2; obj.minRightSideBearing = bin.readShort(data, offset); offset += 2; obj.xMaxExtent = bin.readShort(data, offset); offset += 2; obj.caretSlopeRise = bin.readShort(data, offset); offset += 2; obj.caretSlopeRun = bin.readShort(data, offset); offset += 2; obj.caretOffset = bin.readShort(data, offset); offset += 2; offset += 4 * 2; obj.metricDataFormat = bin.readShort(data, offset); offset += 2; obj.numberOfHMetrics = bin.readUshort(data, offset); offset += 2; return obj; }; Typr.hmtx = {}; Typr.hmtx.parse = function(data, offset, length, font) { var bin = Typr._bin; var obj = {}; obj.aWidth = []; obj.lsBearing = []; var aw = 0, lsb = 0; for (var i = 0; i < font.maxp.numGlyphs; i++) { if (i < font.hhea.numberOfHMetrics) { aw = bin.readUshort(data, offset); offset += 2; lsb = bin.readShort(data, offset); offset += 2; } obj.aWidth.push(aw); obj.lsBearing.push(lsb); } return obj; }; Typr.kern = {}; Typr.kern.parse = function(data, offset, length, font) { var bin = Typr._bin; var version = bin.readUshort(data, offset); offset += 2; if (version == 1) return Typr.kern.parseV1(data, offset - 2, length, font); var nTables = bin.readUshort(data, offset); offset += 2; var map = { glyph1: [], rval: [] }; for (var i = 0; i < nTables; i++) { offset += 2; var length = bin.readUshort(data, offset); offset += 2; var coverage = bin.readUshort(data, offset); offset += 2; var format = coverage >>> 8; format &= 15; if (format == 0) offset = Typr.kern.readFormat0(data, offset, map); else throw "unknown kern table format: " + format; } return map; }; Typr.kern.parseV1 = function(data, offset, length, font) { var bin = Typr._bin; bin.readFixed(data, offset); offset += 4; var nTables = bin.readUint(data, offset); offset += 4; var map = { glyph1: [], rval: [] }; for (var i = 0; i < nTables; i++) { bin.readUint(data, offset); offset += 4; var coverage = bin.readUshort(data, offset); offset += 2; bin.readUshort(data, offset); offset += 2; var format = coverage >>> 8; format &= 15; if (format == 0) offset = Typr.kern.readFormat0(data, offset, map); else throw "unknown kern table format: " + format; } return map; }; Typr.kern.readFormat0 = function(data, offset, map) { var bin = Typr._bin; var pleft = -1; var nPairs = bin.readUshort(data, offset); offset += 2; bin.readUshort(data, offset); offset += 2; bin.readUshort(data, offset); offset += 2; bin.readUshort(data, offset); offset += 2; for (var j = 0; j < nPairs; j++) { var left = bin.readUshort(data, offset); offset += 2; var right = bin.readUshort(data, offset); offset += 2; var value = bin.readShort(data, offset); offset += 2; if (left != pleft) { map.glyph1.push(left); map.rval.push({ glyph2: [], vals: [] }); } var rval = map.rval[map.rval.length - 1]; rval.glyph2.push(right); rval.vals.push(value); pleft = left; } return offset; }; Typr.loca = {}; Typr.loca.parse = function(data, offset, length, font) { var bin = Typr._bin; var obj = []; var ver = font.head.indexToLocFormat; var len = font.maxp.numGlyphs + 1; if (ver == 0) for (var i = 0; i < len; i++) obj.push(bin.readUshort(data, offset + (i << 1)) << 1); if (ver == 1) for (var i = 0; i < len; i++) obj.push(bin.readUint(data, offset + (i << 2))); return obj; }; Typr.maxp = {}; Typr.maxp.parse = function(data, offset, length) { var bin = Typr._bin; var obj = {}; var ver = bin.readUint(data, offset); offset += 4; obj.numGlyphs = bin.readUshort(data, offset); offset += 2; if (ver == 65536) { obj.maxPoints = bin.readUshort(data, offset); offset += 2; obj.maxContours = bin.readUshort(data, offset); offset += 2; obj.maxCompositePoints = bin.readUshort(data, offset); offset += 2; obj.maxCompositeContours = bin.readUshort(data, offset); offset += 2; obj.maxZones = bin.readUshort(data, offset); offset += 2; obj.maxTwilightPoints = bin.readUshort(data, offset); offset += 2; obj.maxStorage = bin.readUshort(data, offset); offset += 2; obj.maxFunctionDefs = bin.readUshort(data, offset); offset += 2; obj.maxInstructionDefs = bin.readUshort(data, offset); offset += 2; obj.maxStackElements = bin.readUshort(data, offset); offset += 2; obj.maxSizeOfInstructions = bin.readUshort(data, offset); offset += 2; obj.maxComponentElements = bin.readUshort(data, offset); offset += 2; obj.maxComponentDepth = bin.readUshort(data, offset); offset += 2; } return obj; }; Typr.name = {}; Typr.name.parse = function(data, offset, length) { var bin = Typr._bin; var obj = {}; bin.readUshort(data, offset); offset += 2; var count = bin.readUshort(data, offset); offset += 2; bin.readUshort(data, offset); offset += 2; var offset0 = offset; for (var i = 0; i < count; i++) { var platformID = bin.readUshort(data, offset); offset += 2; var encodingID = bin.readUshort(data, offset); offset += 2; var languageID = bin.readUshort(data, offset); offset += 2; var nameID = bin.readUshort(data, offset); offset += 2; var length = bin.readUshort(data, offset); offset += 2; var noffset = bin.readUshort(data, offset); offset += 2; var plat = "p" + platformID; if (obj[plat] == null) obj[plat] = {}; var names = ["copyright", "fontFamily", "fontSubfamily", "ID", "fullName", "version", "postScriptName", "trademark", "manufacturer", "designer", "description", "urlVendor", "urlDesigner", "licence", "licenceURL", "---", "typoFamilyName", "typoSubfamilyName", "compatibleFull", "sampleText", "postScriptCID", "wwsFamilyName", "wwsSubfamilyName", "lightPalette", "darkPalette"]; var cname = names[nameID]; var soff = offset0 + count * 12 + noffset; var str; if (platformID == 0) str = bin.readUnicode(data, soff, length / 2); else if (platformID == 3 && encodingID == 0) str = bin.readUnicode(data, soff, length / 2); else if (encodingID == 0) str = bin.readASCII(data, soff, length); else if (encodingID == 1) str = bin.readUnicode(data, soff, length / 2); else if (encodingID == 3) str = bin.readUnicode(data, soff, length / 2); else if (platformID == 1) { str = bin.readASCII(data, soff, length); console.log("reading unknown MAC encoding " + encodingID + " as ASCII"); } else throw "unknown encoding " + encodingID + ", platformID: " + platformID; obj[plat][cname] = str; obj[plat]._lang = languageID; } for (var p in obj) if (obj[p].postScriptName != null && obj[p]._lang == 1033) return obj[p]; for (var p in obj) if (obj[p].postScriptName != null && obj[p]._lang == 3084) return obj[p]; for (var p in obj) if (obj[p].postScriptName != null) return obj[p]; var tname; for (var p in obj) { tname = p; break; } console.log("returning name table with languageID " + obj[tname]._lang); return obj[tname]; }; Typr["OS/2"] = {}; Typr["OS/2"].parse = function(data, offset, length) { var bin = Typr._bin; var ver = bin.readUshort(data, offset); offset += 2; var obj = {}; if (ver == 0) Typr["OS/2"].version0(data, offset, obj); else if (ver == 1) Typr["OS/2"].version1(data, offset, obj); else if (ver == 2 || ver == 3 || ver == 4) Typr["OS/2"].version2(data, offset, obj); else if (ver == 5) Typr["OS/2"].version5(data, offset, obj); else throw "unknown OS/2 table version: " + ver; return obj; }; Typr["OS/2"].version0 = function(data, offset, obj) { var bin = Typr._bin; obj.xAvgCharWidth = bin.readShort(data, offset); offset += 2; obj.usWeightClass = bin.readUshort(data, offset); offset += 2; obj.usWidthClass = bin.readUshort(data, offset); offset += 2; obj.fsType = bin.readUshort(data, offset); offset += 2; obj.ySubscriptXSize = bin.readShort(data, offset); offset += 2; obj.ySubscriptYSize = bin.readShort(data, offset); offset += 2; obj.ySubscriptXOffset = bin.readShort(data, offset); offset += 2; obj.ySubscriptYOffset = bin.readShort(data, offset); offset += 2; obj.ySuperscriptXSize = bin.readShort(data, offset); offset += 2; obj.ySuperscriptYSize = bin.readShort(data, offset); offset += 2; obj.ySuperscriptXOffset = bin.readShort(data, offset); offset += 2; obj.ySuperscriptYOffset = bin.readShort(data, offset); offset += 2; obj.yStrikeoutSize = bin.readShort(data, offset); offset += 2; obj.yStrikeoutPosition = bin.readShort(data, offset); offset += 2; obj.sFamilyClass = bin.readShort(data, offset); offset += 2; obj.panose = bin.readBytes(data, offset, 10); offset += 10; obj.ulUnicodeRange1 = bin.readUint(data, offset); offset += 4; obj.ulUnicodeRange2 = bin.readUint(data, offset); offset += 4; obj.ulUnicodeRange3 = bin.readUint(data, offset); offset += 4; obj.ulUnicodeRange4 = bin.readUint(data, offset); offset += 4; obj.achVendID = [bin.readInt8(data, offset), bin.readInt8(data, offset + 1), bin.readInt8(data, offset + 2), bin.readInt8(data, offset + 3)]; offset += 4; obj.fsSelection = bin.readUshort(data, offset); offset += 2; obj.usFirstCharIndex = bin.readUshort(data, offset); offset += 2; obj.usLastCharIndex = bin.readUshort(data, offset); offset += 2; obj.sTypoAscender = bin.readShort(data, offset); offset += 2; obj.sTypoDescender = bin.readShort(data, offset); offset += 2; obj.sTypoLineGap = bin.readShort(data, offset); offset += 2; obj.usWinAscent = bin.readUshort(data, offset); offset += 2; obj.usWinDescent = bin.readUshort(data, offset); offset += 2; return offset; }; Typr["OS/2"].version1 = function(data, offset, obj) { var bin = Typr._bin; offset = Typr["OS/2"].version0(data, offset, obj); obj.ulCodePageRange1 = bin.readUint(data, offset); offset += 4; obj.ulCodePageRange2 = bin.readUint(data, offset); offset += 4; return offset; }; Typr["OS/2"].version2 = function(data, offset, obj) { var bin = Typr._bin; offset = Typr["OS/2"].version1(data, offset, obj); obj.sxHeight = bin.readShort(data, offset); offset += 2; obj.sCapHeight = bin.readShort(data, offset); offset += 2; obj.usDefault = bin.readUshort(data, offset); offset += 2; obj.usBreak = bin.readUshort(data, offset); offset += 2; obj.usMaxContext = bin.readUshort(data, offset); offset += 2; return offset; }; Typr["OS/2"].version5 = function(data, offset, obj) { var bin = Typr._bin; offset = Typr["OS/2"].version2(data, offset, obj); obj.usLowerOpticalPointSize = bin.readUshort(data, offset); offset += 2; obj.usUpperOpticalPointSize = bin.readUshort(data, offset); offset += 2; return offset; }; Typr.post = {}; Typr.post.parse = function(data, offset, length) { var bin = Typr._bin; var obj = {}; obj.version = bin.readFixed(data, offset); offset += 4; obj.italicAngle = bin.readFixed(data, offset); offset += 4; obj.underlinePosition = bin.readShort(data, offset); offset += 2; obj.underlineThickness = bin.readShort(data, offset); offset += 2; return obj; }; Typr.SVG = {}; Typr.SVG.parse = function(data, offset, length) { var bin = Typr._bin; var obj = { entries: [] }; var offset0 = offset; bin.readUshort(data, offset); offset += 2; var svgDocIndexOffset = bin.readUint(data, offset); offset += 4; bin.readUint(data, offset); offset += 4; offset = svgDocIndexOffset + offset0; var numEntries = bin.readUshort(data, offset); offset += 2; for (var i = 0; i < numEntries; i++) { var startGlyphID = bin.readUshort(data, offset); offset += 2; var endGlyphID = bin.readUshort(data, offset); offset += 2; var svgDocOffset = bin.readUint(data, offset); offset += 4; var svgDocLength = bin.readUint(data, offset); offset += 4; var sbuf = new Uint8Array(data.buffer, offset0 + svgDocOffset + svgDocIndexOffset, svgDocLength); var svg2 = bin.readUTF8(sbuf, 0, sbuf.length); for (var f = startGlyphID; f <= endGlyphID; f++) { obj.entries[f] = svg2; } } return obj; }; Typr.SVG.toPath = function(str) { var pth = { cmds: [], crds: [] }; if (str == null) return pth; var prsr = new DOMParser(); var doc = prsr["parseFromString"](str, "image/svg+xml"); var svg2 = doc.firstChild; while (svg2.tagName != "svg") svg2 = svg2.nextSibling; var vb = svg2.getAttribute("viewBox"); if (vb) vb = vb.trim().split(" ").map(parseFloat); else vb = [0, 0, 1e3, 1e3]; Typr.SVG._toPath(svg2.children, pth); for (var i = 0; i < pth.crds.length; i += 2) { var x = pth.crds[i], y = pth.crds[i + 1]; x -= vb[0]; y -= vb[1]; y = -y; pth.crds[i] = x; pth.crds[i + 1] = y; } return pth; }; Typr.SVG._toPath = function(nds, pth, fill) { for (var ni = 0; ni < nds.length; ni++) { var nd = nds[ni], tn = nd.tagName; var cfl = nd.getAttribute("fill"); if (cfl == null) cfl = fill; if (tn == "g") Typr.SVG._toPath(nd.children, pth, cfl); else if (tn == "path") { pth.cmds.push(cfl ? cfl : "#000000"); var d = nd.getAttribute("d"); var toks = Typr.SVG._tokens(d); Typr.SVG._toksToPath(toks, pth); pth.cmds.push("X"); } else if (tn == "defs") ; else console.log(tn, nd); } }; Typr.SVG._tokens = function(d) { var ts = [], off = 0, rn = false, cn = ""; while (off < d.length) { var cc = d.charCodeAt(off), ch = d.charAt(off); off++; var isNum = 48 <= cc && cc <= 57 || ch == "." || ch == "-"; if (rn) { if (ch == "-") { ts.push(parseFloat(cn)); cn = ch; } else if (isNum) cn += ch; else { ts.push(parseFloat(cn)); if (ch != "," && ch != " ") ts.push(ch); rn = false; } } else { if (isNum) { cn = ch; rn = true; } else if (ch != "," && ch != " ") ts.push(ch); } } if (rn) ts.push(parseFloat(cn)); return ts; }; Typr.SVG._toksToPath = function(ts, pth) { var i = 0, x = 0, y = 0, ox = 0, oy = 0; var pc = { M: 2, L: 2, H: 1, V: 1, S: 4, C: 6 }; var cmds = pth.cmds, crds = pth.crds; while (i < ts.length) { var cmd = ts[i]; i++; if (cmd == "z") { cmds.push("Z"); x = ox; y = oy; } else { var cmu = cmd.toUpperCase(); var ps = pc[cmu], reps = Typr.SVG._reps(ts, i, ps); for (var j = 0; j < reps; j++) { var xi = 0, yi = 0; if (cmd != cmu) { xi = x; yi = y; } if (cmu == "M") { x = xi + ts[i++]; y = yi + ts[i++]; cmds.push("M"); crds.push(x, y); ox = x; oy = y; } else if (cmu == "L") { x = xi + ts[i++]; y = yi + ts[i++]; cmds.push("L"); crds.push(x, y); } else if (cmu == "H") { x = xi + ts[i++]; cmds.push("L"); crds.push(x, y); } else if (cmu == "V") { y = yi + ts[i++]; cmds.push("L"); crds.push(x, y); } else if (cmu == "C") { var x1 = xi + ts[i++], y1 = yi + ts[i++], x2 = xi + ts[i++], y2 = yi + ts[i++], x3 = xi + ts[i++], y3 = yi + ts[i++]; cmds.push("C"); crds.push(x1, y1, x2, y2, x3, y3); x = x3; y = y3; } else if (cmu == "S") { var co = Math.max(crds.length - 4, 0); var x1 = x + x - crds[co], y1 = y + y - crds[co + 1]; var x2 = xi + ts[i++], y2 = yi + ts[i++], x3 = xi + ts[i++], y3 = yi + ts[i++]; cmds.push("C"); crds.push(x1, y1, x2, y2, x3, y3); x = x3; y = y3; } else console.log("Unknown SVG command " + cmd); } } } }; Typr.SVG._reps = function(ts, off, ps) { var i = off; while (i < ts.length) { if (typeof ts[i] == "string") break; i += ps; } return (i - off) / ps; }; if (Typr == null) Typr = {}; if (Typr.U == null) Typr.U = {}; Typr.U.codeToGlyph = function(font, code) { var cmap = font.cmap; var tind = -1; if (cmap.p0e4 != null) tind = cmap.p0e4; else if (cmap.p3e1 != null) tind = cmap.p3e1; else if (cmap.p1e0 != null) tind = cmap.p1e0; if (tind == -1) throw "no familiar platform and encoding!"; var tab = cmap.tables[tind]; if (tab.format == 0) { if (code >= tab.map.length) return 0; return tab.map[code]; } else if (tab.format == 4) { var sind = -1; for (var i = 0; i < tab.endCount.length; i++) if (code <= tab.endCount[i]) { sind = i; break; } if (sind == -1) return 0; if (tab.startCount[sind] > code) return 0; var gli = 0; if (tab.idRangeOffset[sind] != 0) gli = tab.glyphIdArray[code - tab.startCount[sind] + (tab.idRangeOffset[sind] >> 1) - (tab.idRangeOffset.length - sind)]; else gli = code + tab.idDelta[sind]; return gli & 65535; } else if (tab.format == 12) { if (code > tab.groups[tab.groups.length - 1][1]) return 0; for (var i = 0; i < tab.groups.length; i++) { var grp = tab.groups[i]; if (grp[0] <= code && code <= grp[1]) return grp[2] + (code - grp[0]); } return 0; } else throw "unknown cmap table format " + tab.format; }; Typr.U.glyphToPath = function(font, gid) { var path = { cmds: [], crds: [] }; if (font.SVG && font.SVG.entries[gid]) { var p = font.SVG.entries[gid]; if (p == null) return path; if (typeof p == "string") { p = Typr.SVG.toPath(p); font.SVG.entries[gid] = p; } return p; } else if (font.CFF) { var state = { x: 0, y: 0, stack: [], nStems: 0, haveWidth: false, width: font.CFF.Private ? font.CFF.Private.defaultWidthX : 0, open: false }; Typr.U._drawCFF(font.CFF.CharStrings[gid], state, font.CFF, path); } else if (font.glyf) { Typr.U._drawGlyf(gid, font, path); } return path; }; Typr.U._drawGlyf = function(gid, font, path) { var gl = font.glyf[gid]; if (gl == null) gl = font.glyf[gid] = Typr.glyf._parseGlyf(font, gid); if (gl != null) { if (gl.noc > -1) Typr.U._simpleGlyph(gl, path); else Typr.U._compoGlyph(gl, font, path); } }; Typr.U._simpleGlyph = function(gl, p) { for (var c = 0; c < gl.noc; c++) { var i0 = c == 0 ? 0 : gl.endPts[c - 1] + 1; var il = gl.endPts[c]; for (var i = i0; i <= il; i++) { var pr = i == i0 ? il : i - 1; var nx = i == il ? i0 : i + 1; var onCurve = gl.flags[i] & 1; var prOnCurve = gl.flags[pr] & 1; var nxOnCurve = gl.flags[nx] & 1; var x = gl.xs[i], y = gl.ys[i]; if (i == i0) { if (onCurve) { if (prOnCurve) Typr.U.P.moveTo(p, gl.xs[pr], gl.ys[pr]); else { Typr.U.P.moveTo(p, x, y); continue; } } else { if (prOnCurve) Typr.U.P.moveTo(p, gl.xs[pr], gl.ys[pr]); else Typr.U.P.moveTo(p, (gl.xs[pr] + x) / 2, (gl.ys[pr] + y) / 2); } } if (onCurve) { if (prOnCurve) Typr.U.P.lineTo(p, x, y); } else { if (nxOnCurve) Typr.U.P.qcurveTo(p, x, y, gl.xs[nx], gl.ys[nx]); else Typr.U.P.qcurveTo(p, x, y, (x + gl.xs[nx]) / 2, (y + gl.ys[nx]) / 2); } } Typr.U.P.closePath(p); } }; Typr.U._compoGlyph = function(gl, font, p) { for (var j = 0; j < gl.parts.length; j++) { var path = { cmds: [], crds: [] }; var prt = gl.parts[j]; Typr.U._drawGlyf(prt.glyphIndex, font, path); var m = prt.m; for (var i = 0; i < path.crds.length; i += 2) { var x = path.crds[i], y = path.crds[i + 1]; p.crds.push(x * m.a + y * m.b + m.tx); p.crds.push(x * m.c + y * m.d + m.ty); } for (var i = 0; i < path.cmds.length; i++) p.cmds.push(path.cmds[i]); } }; Typr.U._getGlyphClass = function(g, cd) { var intr = Typr._lctf.getInterval(cd, g); return intr == -1 ? 0 : cd[intr + 2]; }; Typr.U.getPairAdjustment = function(font, g1, g2) { if (font.GPOS) { var ltab = null; for (var i = 0; i < font.GPOS.featureList.length; i++) { var fl = font.GPOS.featureList[i]; if (fl.tag == "kern") { for (var j = 0; j < fl.tab.length; j++) if (font.GPOS.lookupList[fl.tab[j]].ltype == 2) ltab = font.GPOS.lookupList[fl.tab[j]]; } } if (ltab) { for (var i = 0; i < ltab.tabs.length; i++) { var tab = ltab.tabs[i]; var ind = Typr._lctf.coverageIndex(tab.coverage, g1); if (ind == -1) continue; var adj; if (tab.format == 1) { var right = tab.pairsets[ind]; for (var j = 0; j < right.length; j++) if (right[j].gid2 == g2) adj = right[j]; if (adj == null) continue; } else if (tab.format == 2) { var c1 = Typr.U._getGlyphClass(g1, tab.classDef1); var c2 = Typr.U._getGlyphClass(g2, tab.classDef2); var adj = tab.matrix[c1][c2]; } return adj.val1[2]; } } } if (font.kern) { var ind1 = font.kern.glyph1.indexOf(g1); if (ind1 != -1) { var ind2 = font.kern.rval[ind1].glyph2.indexOf(g2); if (ind2 != -1) return font.kern.rval[ind1].vals[ind2]; } } return 0; }; Typr.U.stringToGlyphs = function(font, str) { var gls = []; for (var i = 0; i < str.length; i++) { var cc = str.codePointAt(i); if (cc > 65535) i++; gls.push(Typr.U.codeToGlyph(font, cc)); } var gsub = font["GSUB"]; if (gsub == null) return gls; var llist = gsub.lookupList, flist = gsub.featureList; var wsep = '\n " ,.:;!?() ،'; var R = "آأؤإاةدذرزوٱٲٳٵٶٷڈډڊڋڌڍڎڏڐڑڒړڔڕږڗژڙۀۃۄۅۆۇۈۉۊۋۍۏےۓەۮۯܐܕܖܗܘܙܞܨܪܬܯݍݙݚݛݫݬݱݳݴݸݹࡀࡆࡇࡉࡔࡧࡩࡪࢪࢫࢬࢮࢱࢲࢹૅેૉ૊૎૏ૐ૑૒૝ૡ૤૯஁ஃ஄அஉ஌எஏ஑னப஫஬"; var L = "ꡲ્૗"; for (var ci = 0; ci < gls.length; ci++) { var gl = gls[ci]; var slft = ci == 0 || wsep.indexOf(str[ci - 1]) != -1; var srgt = ci == gls.length - 1 || wsep.indexOf(str[ci + 1]) != -1; if (!slft && R.indexOf(str[ci - 1]) != -1) slft = true; if (!srgt && R.indexOf(str[ci]) != -1) srgt = true; if (!srgt && L.indexOf(str[ci + 1]) != -1) srgt = true; if (!slft && L.indexOf(str[ci]) != -1) slft = true; var feat = null; if (slft) feat = srgt ? "isol" : "init"; else feat = srgt ? "fina" : "medi"; for (var fi = 0; fi < flist.length; fi++) { if (flist[fi].tag != feat) continue; for (var ti = 0; ti < flist[fi].tab.length; ti++) { var tab = llist[flist[fi].tab[ti]]; if (tab.ltype != 1) continue; Typr.U._applyType1(gls, ci, tab); } } } var cligs = ["rlig", "liga", "mset"]; for (var ci = 0; ci < gls.length; ci++) { var gl = gls[ci]; var rlim = Math.min(3, gls.length - ci - 1); for (var fi = 0; fi < flist.length; fi++) { var fl = flist[fi]; if (cligs.indexOf(fl.tag) == -1) continue; for (var ti = 0; ti < fl.tab.length; ti++) { var tab = llist[fl.tab[ti]]; for (var j = 0; j < tab.tabs.length; j++) { if (tab.tabs[j] == null) continue; var ind = Typr._lctf.coverageIndex(tab.tabs[j].coverage, gl); if (ind == -1) continue; if (tab.ltype == 4) { var vals = tab.tabs[j].vals[ind]; for (var k = 0; k < vals.length; k++) { var lig = vals[k], rl = lig.chain.length; if (rl > rlim) continue; var good = true; for (var l = 0; l < rl; l++) if (lig.chain[l] != gls[ci + (1 + l)]) good = false; if (!good) continue; gls[ci] = lig.nglyph; for (var l = 0; l < rl; l++) gls[ci + l + 1] = -1; } } else if (tab.ltype == 5) { var ltab = tab.tabs[j]; if (ltab.fmt != 2) continue; var cind = Typr._lctf.getInterval(ltab.cDef, gl); var cls = ltab.cDef[cind + 2], scs = ltab.scset[cls]; for (var i = 0; i < scs.length; i++) { var sc = scs[i], inp = sc.input; if (inp.length > rlim) continue; var good = true; for (var l = 0; l < inp.length; l++) { var cind2 = Typr._lctf.getInterval(ltab.cDef, gls[ci + 1 + l]); if (cind == -1 && ltab.cDef[cind2 + 2] != inp[l]) { good = false; break; } } if (!good) continue; var lrs = sc.substLookupRecords; for (var k = 0; k < lrs.length; k += 2) { lrs[k]; lrs[k + 1]; } } } } } } } return gls; }; Typr.U._applyType1 = function(gls, ci, tab) { var gl = gls[ci]; for (var j = 0; j < tab.tabs.length; j++) { var ttab = tab.tabs[j]; var ind = Typr._lctf.coverageIndex(ttab.coverage, gl); if (ind == -1) continue; if (ttab.fmt == 1) gls[ci] = gls[ci] + ttab.delta; else gls[ci] = ttab.newg[ind]; } }; Typr.U.glyphsToPath = function(font, gls, clr) { var tpath = { cmds: [], crds: [] }; var x = 0; for (var i = 0; i < gls.length; i++) { var gid = gls[i]; if (gid == -1) continue; var gid2 = i < gls.length - 1 && gls[i + 1] != -1 ? gls[i + 1] : 0; var path = Typr.U.glyphToPath(font, gid); for (var j = 0; j < path.crds.length; j += 2) { tpath.crds.push(path.crds[j] + x); tpath.crds.push(path.crds[j + 1]); } if (clr) tpath.cmds.push(clr); for (var j = 0; j < path.cmds.length; j++) tpath.cmds.push(path.cmds[j]); if (clr) tpath.cmds.push("X"); x += font.hmtx.aWidth[gid]; if (i < gls.length - 1) x += Typr.U.getPairAdjustment(font, gid, gid2); } return tpath; }; Typr.U.pathToSVG = function(path, prec) { if (prec == null) prec = 5; var out = [], co = 0, lmap = { M: 2, L: 2, Q: 4, C: 6 }; for (var i = 0; i < path.cmds.length; i++) { var cmd = path.cmds[i], cn = co + (lmap[cmd] ? lmap[cmd] : 0); out.push(cmd); while (co < cn) { var c = path.crds[co++]; out.push(parseFloat(c.toFixed(prec)) + (co == cn ? "" : " ")); } } return out.join(""); }; Typr.U.pathToContext = function(path, ctx) { var c = 0, crds = path.crds; for (var j = 0; j < path.cmds.length; j++) { var cmd = path.cmds[j]; if (cmd == "M") { ctx.moveTo(crds[c], crds[c + 1]); c += 2; } else if (cmd == "L") { ctx.lineTo(crds[c], crds[c + 1]); c += 2; } else if (cmd == "C") { ctx.bezierCurveTo(crds[c], crds[c + 1], crds[c + 2], crds[c + 3], crds[c + 4], crds[c + 5]); c += 6; } else if (cmd == "Q") { ctx.quadraticCurveTo(crds[c], crds[c + 1], crds[c + 2], crds[c + 3]); c += 4; } else if (cmd.charAt(0) == "#") { ctx.beginPath(); ctx.fillStyle = cmd; } else if (cmd == "Z") { ctx.closePath(); } else if (cmd == "X") { ctx.fill(); } } }; Typr.U.P = {}; Typr.U.P.moveTo = function(p, x, y) { p.cmds.push("M"); p.crds.push(x, y); }; Typr.U.P.lineTo = function(p, x, y) { p.cmds.push("L"); p.crds.push(x, y); }; Typr.U.P.curveTo = function(p, a, b, c, d, e, f) { p.cmds.push("C"); p.crds.push(a, b, c, d, e, f); }; Typr.U.P.qcurveTo = function(p, a, b, c, d) { p.cmds.push("Q"); p.crds.push(a, b, c, d); }; Typr.U.P.closePath = function(p) { p.cmds.push("Z"); }; Typr.U._drawCFF = function(cmds, state, font, p) { var stack = state.stack; var nStems = state.nStems, haveWidth = state.haveWidth, width = state.width, open = state.open; var i = 0; var x = state.x, y = state.y, c1x = 0, c1y = 0, c2x = 0, c2y = 0, c3x = 0, c3y = 0, c4x = 0, c4y = 0, jpx = 0, jpy = 0; var o = { val: 0, size: 0 }; while (i < cmds.length) { Typr.CFF.getCharString(cmds, i, o); var v = o.val; i += o.size; if (v == "o1" || v == "o18") { var hasWidthArg; hasWidthArg = stack.length % 2 !== 0; if (hasWidthArg && !haveWidth) { width = stack.shift() + font.Private.nominalWidthX; } nStems += stack.length >> 1; stack.length = 0; haveWidth = true; } else if (v == "o3" || v == "o23") { var hasWidthArg; hasWidthArg = stack.length % 2 !== 0; if (hasWidthArg && !haveWidth) { width = stack.shift() + font.Private.nominalWidthX; } nStems += stack.length >> 1; stack.length = 0; haveWidth = true; } else if (v == "o4") { if (stack.length > 1 && !haveWidth) { width = stack.shift() + font.Private.nominalWidthX; haveWidth = true; } if (open) Typr.U.P.closePath(p); y += stack.pop(); Typr.U.P.moveTo(p, x, y); open = true; } else if (v == "o5") { while (stack.length > 0) { x += stack.shift(); y += stack.shift(); Typr.U.P.lineTo(p, x, y); } } else if (v == "o6" || v == "o7") { var count = stack.length; var isX = v == "o6"; for (var j = 0; j < count; j++) { var sval = stack.shift(); if (isX) x += sval; else y += sval; isX = !isX; Typr.U.P.lineTo(p, x, y); } } else if (v == "o8" || v == "o24") { var count = stack.length; var index = 0; while (index + 6 <= count) { c1x = x + stack.shift(); c1y = y + stack.shift(); c2x = c1x + stack.shift(); c2y = c1y + stack.shift(); x = c2x + stack.shift(); y = c2y + stack.shift(); Typr.U.P.curveTo(p, c1x, c1y, c2x, c2y, x, y); index += 6; } if (v == "o24") { x += stack.shift(); y += stack.shift(); Typr.U.P.lineTo(p, x, y); } } else if (v == "o11") break; else if (v == "o1234" || v == "o1235" || v == "o1236" || v == "o1237") { if (v == "o1234") { c1x = x + stack.shift(); c1y = y; c2x = c1x + stack.shift(); c2y = c1y + stack.shift(); jpx = c2x + stack.shift(); jpy = c2y; c3x = jpx + stack.shift(); c3y = c2y; c4x = c3x + stack.shift(); c4y = y; x = c4x + stack.shift(); Typr.U.P.curveTo(p, c1x, c1y, c2x, c2y, jpx, jpy); Typr.U.P.curveTo(p, c3x, c3y, c4x, c4y, x, y); } if (v == "o1235") { c1x = x + stack.shift(); c1y = y + stack.shift(); c2x = c1x + stack.shift(); c2y = c1y + stack.shift(); jpx = c2x + stack.shift(); jpy = c2y + stack.shift(); c3x = jpx + stack.shift(); c3y = jpy + stack.shift(); c4x = c3x + stack.shift(); c4y = c3y + stack.shift(); x = c4x + stack.shift(); y = c4y + stack.shift(); stack.shift(); Typr.U.P.curveTo(p, c1x, c1y, c2x, c2y, jpx, jpy); Typr.U.P.curveTo(p, c3x, c3y, c4x, c4y, x, y); } if (v == "o1236") { c1x = x + stack.shift(); c1y = y + stack.shift(); c2x = c1x + stack.shift(); c2y = c1y + stack.shift(); jpx = c2x + stack.shift(); jpy = c2y; c3x = jpx + stack.shift(); c3y = c2y; c4x = c3x + stack.shift(); c4y = c3y + stack.shift(); x = c4x + stack.shift(); Typr.U.P.curveTo(p, c1x, c1y, c2x, c2y, jpx, jpy); Typr.U.P.curveTo(p, c3x, c3y, c4x, c4y, x, y); } if (v == "o1237") { c1x = x + stack.shift(); c1y = y + stack.shift(); c2x = c1x + stack.shift(); c2y = c1y + stack.shift(); jpx = c2x + stack.shift(); jpy = c2y + stack.shift(); c3x = jpx + stack.shift(); c3y = jpy + stack.shift(); c4x = c3x + stack.shift(); c4y = c3y + stack.shift(); if (Math.abs(c4x - x) > Math.abs(c4y - y)) { x = c4x + stack.shift(); } else { y = c4y + stack.shift(); } Typr.U.P.curveTo(p, c1x, c1y, c2x, c2y, jpx, jpy); Typr.U.P.curveTo(p, c3x, c3y, c4x, c4y, x, y); } } else if (v == "o14") { if (stack.length > 0 && !haveWidth) { width = stack.shift() + font.nominalWidthX; haveWidth = true; } if (stack.length == 4) { var adx = stack.shift(); var ady = stack.shift(); var bchar = stack.shift(); var achar = stack.shift(); var bind = Typr.CFF.glyphBySE(font, bchar); var aind = Typr.CFF.glyphBySE(font, achar); Typr.U._drawCFF(font.CharStrings[bind], state, font, p); state.x = adx; state.y = ady; Typr.U._drawCFF(font.CharStrings[aind], state, font, p); } if (open) { Typr.U.P.closePath(p); open = false; } } else if (v == "o19" || v == "o20") { var hasWidthArg; hasWidthArg = stack.length % 2 !== 0; if (hasWidthArg && !haveWidth) { width = stack.shift() + font.Private.nominalWidthX; } nStems += stack.length >> 1; stack.length = 0; haveWidth = true; i += nStems + 7 >> 3; } else if (v == "o21") { if (stack.length > 2 && !haveWidth) { width = stack.shift() + font.Private.nominalWidthX; haveWidth = true; } y += stack.pop(); x += stack.pop(); if (open) Typr.U.P.closePath(p); Typr.U.P.moveTo(p, x, y); open = true; } else if (v == "o22") { if (stack.length > 1 && !haveWidth) { width = stack.shift() + font.Private.nominalWidthX; haveWidth = true; } x += stack.pop(); if (open) Typr.U.P.closePath(p); Typr.U.P.moveTo(p, x, y); open = true; } else if (v == "o25") { while (stack.length > 6) { x += stack.shift(); y += stack.shift(); Typr.U.P.lineTo(p, x, y); } c1x = x + stack.shift(); c1y = y + stack.shift(); c2x = c1x + stack.shift(); c2y = c1y + stack.shift(); x = c2x + stack.shift(); y = c2y + stack.shift(); Typr.U.P.curveTo(p, c1x, c1y, c2x, c2y, x, y); } else if (v == "o26") { if (stack.length % 2) { x += stack.shift(); } while (stack.length > 0) { c1x = x; c1y = y + stack.shift(); c2x = c1x + stack.shift(); c2y = c1y + stack.shift(); x = c2x; y = c2y + stack.shift(); Typr.U.P.curveTo(p, c1x, c1y, c2x, c2y, x, y); } } else if (v == "o27") { if (stack.length % 2) { y += stack.shift(); } while (stack.length > 0) { c1x = x + stack.shift(); c1y = y; c2x = c1x + stack.shift(); c2y = c1y + stack.shift(); x = c2x + stack.shift(); y = c2y; Typr.U.P.curveTo(p, c1x, c1y, c2x, c2y, x, y); } } else if (v == "o10" || v == "o29") { var obj = v == "o10" ? font.Private : font; if (stack.length == 0) { console.log("error: empty stack"); } else { var ind = stack.pop(); var subr = obj.Subrs[ind + obj.Bias]; state.x = x; state.y = y; state.nStems = nStems; state.haveWidth = haveWidth; state.width = width; state.open = open; Typr.U._drawCFF(subr, state, font, p); x = state.x; y = state.y; nStems = state.nStems; haveWidth = state.haveWidth; width = state.width; open = state.open; } } else if (v == "o30" || v == "o31") { var count, count1 = stack.length; var index = 0; var alternate = v == "o31"; count = count1 & ~2; index += count1 - count; while (index < count) { if (alternate) { c1x = x + stack.shift(); c1y = y; c2x = c1x + stack.shift(); c2y = c1y + stack.shift(); y = c2y + stack.shift(); if (count - index == 5) { x = c2x + stack.shift(); index++; } else x = c2x; alternate = false; } else { c1x = x; c1y = y + stack.shift(); c2x = c1x + stack.shift(); c2y = c1y + stack.shift(); x = c2x + stack.shift(); if (count - index == 5) { y = c2y + stack.shift(); index++; } else y = c2y; alternate = true; } Typr.U.P.curveTo(p, c1x, c1y, c2x, c2y, x, y); index += 4; } } else if ((v + "").charAt(0) == "o") { console.log("Unknown operation: " + v, cmds); throw v; } else stack.push(v); } state.x = x; state.y = y; state.nStems = nStems; state.haveWidth = haveWidth; state.width = width; state.open = open; }; var typr_js = Typr; const Typr$1 = /* @__PURE__ */ getDefaultExportFromCjs(typr_js); const decode = () => { var _a; const styleElements = _unsafeWindow.document.querySelectorAll("style"); let tipElement = null; styleElements.forEach((styleElement) => { var _a2; if (((_a2 = styleElement.textContent) == null ? void 0 : _a2.indexOf("font-cxsecret")) !== -1) { tipElement = styleElement; } }); if (!tipElement) return; const fontMatch = (_a = tipElement.textContent) == null ? void 0 : _a.match(/base64,([\w\W]+?)'/); if (!fontMatch) return; const fontData = base64ToUint8Array(fontMatch[1]); const font = Typr$1.parse(fontData); const table = JSON.parse(_GM_getResourceText("ttf")); let text2 = {}; for (let i = 19968; i < 40870; i++) { let t = Typr$1.U.codeToGlyph(font, i); if (!t) continue; t = Typr$1.U.glyphToPath(font, t); t = md5Exports.md5(JSON.stringify(t)).slice(24); text2[i] = table[t]; } const fontElements = _unsafeWindow.document.querySelectorAll(".font-cxsecret"); fontElements.forEach((fontElement) => { let html2 = fontElement.innerHTML; Object.keys(text2).forEach((key2) => { const regex = new RegExp(String.fromCharCode(key2), "g"); html2 = html2.replace(regex, String.fromCharCode(text2[key2])); }); fontElement.innerHTML = html2; fontElement.classList.remove("font-cxsecret"); }); }; const base64ToUint8Array = (base64) => { const decodedData = atob(base64); const array = new Uint8Array(decodedData.length); for (let i = 0; i < decodedData.length; i++) { array[i] = decodedData.charCodeAt(i); } return array; }; const JSONparse = (str) => { let data = null; try { data = JSON.parse(str); } catch (e) { data = null; } _unsafeWindow.zhsques = data.rt.examBase.workExamParts[0].questionDtos; }; const rule = [ { type: "save", name: "国开答案收录", match: location.host === "lms.ouchn.cn" && /\/exam\/([0-9]+)\/subjects#\/submission\/([0-9]+)/i.test(location.href), question: { html: "li.subject", question: ".summary-title .subject-description", options: ".subject-options li .option-content", type: ".subject-point > span:eq(0)", workType: "guokai", pageType: "guokai" }, init: async () => { await waitUntil(function() { return $(".loading-gif").hasClass("ng-hide"); }); }, answerHook: (item) => { if ($(item.html).hasClass("text")) return; let subpoint = $(item.html).find(".subject-point > .ng-scope > .ng-binding").text(); let answerpoint = $(item.html).find(".subject-point > .ng-scope > .actual-score .ng-binding").text(); const isT = subpoint !== answerpoint || answerpoint === "0"; if (isT && item.type != "3") { return; } item.type = typeChange($(item.html).find(".subject-point > span:eq(0)").text()); switch (item.type) { case "1": case "0": item.answer = $(item.html).find(".subject-options li").map((index, element) => { let isChecked = $(element).find("input").prop("checked"); return isChecked && item.options[index]; }).get().filter((item2) => item2 !== false && item2 !== void 0 && item2 !== ""); break; case "3": let answerList = $(item.html).find(".subject-options li").map((index, element) => { let isChecked = $(element).find("input").prop("checked"); return isChecked && item.options[index]; }).get().filter((item2) => item2 !== false && item2 !== void 0 && item2 !== ""); if (answerList.length === 1) { let answer = answerList[0]; if (isFalse(answer)) item.answer = "错误"; else if (isTrue(answer)) item.answer = "正确"; else return; if (["正确", "错误"].includes(item.answer) && isT) { console.log("答案错误"); item.answer = item.answer === "正确" ? "错误" : "正确"; } } else return; break; } return item; } }, // 国开答案收录规则 { type: "save", name: "国开答案收录", match: /mod\/quiz\/review\.php/i.test(location.pathname) && ["moodle.syxy.ouchn.cn", "xczxzdbf.moodle.qwbx.ouchn.cn", "elearning.bjou.edu.cn", "whkpc.hnqtyq.cn:5678", "course.ougd.cn", "study.ouchn.cn"].includes(location.host), question: { html: ".que", question: ".qtext", options: ".answer > div", type: "", answer: ".rightanswer", workType: "guokai", pageType: "guokai" }, answerHook: (item) => { const quesStatus = $(item.html).find(".info .state").text(); item.type = $(item.html).attr("class").split(" ")[1]; $(item.html).find(".qtext .accesshide").remove(); item.question = removeHtml1($(item.html).find(".qtext").html()); switch (item.type) { case "truefalse": item.type = "3"; item.$options = $(item.html).find("input[type=radio]"); item.options = $(item.html).find(".answer > div").map((index, element) => { let optionText = removeHtml1($(element).html()); return optionText.trim(); }).get(); item.answer = []; item.answer = $(item.html).find(".answer > div").map((index, element) => { if (item.$options.eq(index).prop("checked")) { return item.options[index]; } else { return ""; } }).get(); item.answer = item.answer.filter((item2) => item2 !== ""); console.log(item.answer, item.answer.length); if (item.answer.length === 0) ; else { if (!quesStatus.includes("正确")) { item.answer = item.options.filter((zzz) => !zzz.includes(item.answer[0])); } } break; case "multichoice": case "multichoiceset": item.type = "1"; item.$options = $(item.html).find("input[type=checkbox]"); if (item.$options.length === 0) { item.type = "0"; item.$options = $(item.html).find("input[type=radio]"); } item.options = $(item.html).find(".answer > div").map((index, element) => { let inx = $(element).find(".answernumber").text().trim(); let optionText = removeHtml1($(element).html()); return optionText.split(inx)[1].trim(); }).get(); if (quesStatus.includes("正确")) { item.answer = []; item.answer = $(item.html).find(".answer > div").map((index, element) => { let inx = $(element).find(".answernumber").text().trim(); let optionText = removeHtml1($(element).html()); if (item.$options.eq(index).prop("checked") && $(element).find(".text-success").length > 0) { return optionText.split(inx)[1].trim(); } else { return ""; } }).get(); item.answer = item.answer.filter((item2) => item2 !== ""); } else { item.temp = removeHtml1($(item.html).find(".rightanswer").html()).replace("正确答案是:", "").trim(); item.answer = item.options.filter((optionText) => { if (item.temp.includes(",")) { if (item.temp.includes("," + optionText)) { return optionText; } if (item.temp.indexOf(optionText) === 0) { return optionText; } } else { if (optionText === item.temp) { return optionText; } } return ""; }); } break; case "shortanswer": item.type = "4"; item.$options = $(item.html).find("input[type=text]"); break; case "match": item.type = "24"; item.match = $(".answer tr td.text").map((index, element) => { return removeHtml1($(element).html()); }).get(); item.$options = $(".answer tr td.control select"); item.selects = $(".answer tr td.control select").map((index, element) => { let option = $(element).find("option").map((index2, element2) => { let value = $(element2).val(); let text2 = $(element2).text(); return { value, text: text2 }; }).get(); console.log(option); return [option]; }).get(); console.log(item.selects); break; case "description": return; } return item; } }, { type: "ask", name: "智慧树章节", match: location.href.includes("zhihuishu.com") && (!location.href.includes("checkHomework") && location.host.includes("zhihuishu") && (location.pathname === "/stuExamWeb.html" || location.href.includes("/webExamList/dohomework/") || location.href.includes("/webExamList/doexamination/"))), hook: () => { let baseSend = XMLHttpRequest.prototype.send; XMLHttpRequest.prototype.send = function() { this.addEventListener("readystatechange", function() { if (this.readyState === 4 && this.response.includes("workExamParts")) { JSONparse(this.response); } }, false); return baseSend.apply(this, arguments); }; }, init: async () => { await waitUntil(function() { return !$(".yidun_popup").hasClass("yidun_popup--light") && _unsafeWindow.zhsques && _unsafeWindow.zhsques.length > 0; }); }, next: () => { $(".switch-btn-box button:eq(1)").click(); }, question: { html: ".examPaper_subject", question: ".subject_describe.dynamic-fonts:eq(0) div:eq(0)", options: ".subject_node .nodeLab .label.clearfix .node_detail", type: ".subject_type span:first-child", workType: "zhs", pageType: "zhs" }, questionHook: (item, inx) => { const quesData = _unsafeWindow.zhsques[inx]; item.type = typeChange(quesData.questionType.name); item.question = removeHtml1(quesData.name); item.options = quesData.questionOptions.map((item2) => removeHtml1(item2.content)); return item; }, setAnswerHook: (item) => { } }, { type: "ask", name: "广开形考", tips: "广开仅支持基础题型,特殊题型请手动完成", match: /mod\/quiz\/attempt\.php/i.test(location.pathname) && ["moodle.syxy.ouchn.cn", "xczxzdbf.moodle.qwbx.ouchn.cn", "elearning.bjou.edu.cn", "whkpc.hnqtyq.cn:5678", "course.ougd.cn", "study.ouchn.cn"].includes(location.host), question: { html: ".que", question: ".qtext", options: ".answer > div", type: "", workType: "guangkai", pageType: "guangkai" }, questionHook: (item) => { item.type = $(item.html).attr("class").split(" ")[1]; $(item.html).find(".qtext .accesshide").remove(); item.question = removeHtml1($(item.html).find(".qtext").html()); switch (item.type) { case "truefalse": item.type = "3"; item.$options = $(item.html).find("input[type=radio]"); break; case "multichoice": case "multichoiceset": item.type = "1"; item.$options = $(item.html).find("input[type=checkbox]"); if (item.$options.length === 0) { item.type = "0"; item.$options = $(item.html).find("input[type=radio]"); } item.options = $(item.html).find(".answer > div").map((index, element) => { let inx = $(element).find(".answernumber").text().trim(); let optionText = removeHtml1($(element).html()); return optionText.split(inx)[1].trim(); }).get(); break; case "shortanswer": item.type = "4"; item.$options = $(item.html).find("input[type=text]"); break; case "match": item.type = "24"; item.match = $(".answer tr td.text").map((index, element) => { return removeHtml1($(element).html()); }).get(); item.$options = $(".answer tr td.control select"); item.selects = $(".answer tr td.control select").map((index, element) => { let option = $(element).find("option").map((index2, element2) => { let value = $(element2).val(); let text2 = $(element2).text(); return { value, text: text2 }; }).get(); return [option]; }).get(); break; case "description": return; } return item; }, setAnswer: (item) => { switch (item.type) { case "4": $(item.html).find("input.form-control").each(function(index, element) { $(element).val(item.answer[index]); }); return false; default: return true; } }, finish: (item) => { console.log(item); console.log("finish"); } }, { type: "ask", name: "学习通新版作业", match: /\/mooc2\/work\/dowork/i.test(location.pathname), hook: () => { console.log("页面加载前hook页面"); }, question: { html: ".questionLi", question: "h3", options: "ul:eq(0) li .after, .answer_p", type: "input[name^=answertype]:eq(0)", workType: "zy", pageType: "cx" }, questionHook: (item) => { const type = removeHtml1($(item.html).find(".colorShallow").html()); item.question = item.question.split(type)[1].trim(); item.$options = $(item.html).find(".answerBg"); return item; }, setAnswerHook: (item) => { qc(item.html); qc1(item.html); } }, { type: "ask", name: "学习通新版考试", match: /exam\/preview/i.test(location.pathname) || /exam\/test\/reVersionTestStartNew/i.test(location.pathname), question: { html: ".questionLi", question: "h3", options: "ul:eq(0) li .after, .answer_p", type: "input[name^=type]:not([name=type])", workType: "ks", pageType: "cx" }, questionHook: (item) => { const type = removeHtml1($(item.html).find(".colorShallow").html()); item.question = item.question.split(type)[1].trim(); item.$options = $(item.html).find(".answerBg"); return item; }, setAnswerHook: (item) => { qc(item.html); qc1(item.html); }, next: () => { $('.nextDiv .jb_btn:contains("下一题")').click(); } }, { type: "ask", name: "学习通旧版作业", match: /work\/doHomeWorkNew/i.test(location.pathname) && location.href.includes("mooc2=1") == false, init: () => { decode(); }, question: { html: ".TiMu", question: ".clearfix.fontLabel", options: "ul:eq(0) li .after", type: "input[name^=answertype]:eq(0), .answer_p", workType: "zy", pageType: "cx" }, questionHook: (item) => { if (location.href.includes("mooc=1") == true) ; item.$options = $(item.html).find(".fl.before"); if (item.type === "3") { item.options = $(item.html).find("ul:eq(0) li").map((index, element) => { if ($(element).find(".ri").length > 0) { return "正确"; } if ($(element).find(".wr").length > 0) { return "错误"; } if (isTrue($(element).attr("aria-label"))) { return "正确"; } if (isFalse($(element).attr("aria-label"))) { return "错误"; } }); item.$options = $(item.html).find("input[type=radio]"); } return item; }, setAnswerHook: (item) => { qc(item.html); qc1(item.html); } }, { type: "ask", name: "学习通新版章节", match: /work\/doHomeWorkNew/i.test(location.pathname) && location.href.includes("mooc2=1"), init: () => { decode(); }, question: { html: ".TiMu", question: ".clearfix.fontLabel", options: "ul:eq(0) li .after, .answer_p", type: "input[name^=answertype]:eq(0)", workType: "zj", pageType: "cx" }, questionHook: (item) => { if (item.type === "3") { item.options = $(item.html).find("ul:eq(0) li").map((index, element) => { if ($(element).find(".num_option").attr("data") === "true") { return "正确"; } if ($(element).find(".num_option").attr("data") === "false") { return "错误"; } }); } return item; }, setAnswerHook: (item) => { qc(item.html); qc1(item.html); } }, { type: "ask", name: "国开专题测验", match: location.host === "lms.ouchn.cn" && /\/exam\/([0-9]+)\/subjects/i.test(location.pathname), question: { html: "li.subject", question: ".summary-title .subject-description", options: ".subject-options li .option-content", type: ".summary-sub-title span:eq(0)", workType: "guokai", pageType: "guokai" }, init: async () => { await waitUntil(function() { return $(".loading-gif").hasClass("ng-hide") && $(".hd .examinee .submit-label").eq(0).text() === ""; }); }, ischecked: (item) => { return Boolean(item.parent().find("input").eq(-1).prop("checked")); }, questionHook: (item) => { if ($(item.html).hasClass("text")) { return; } item.type = typeChange($(item.html).find(".summary-sub-title span:eq(0)").text()); return item; } }, { type: "hook", name: "智普清言token获取", match: /chatglm.cn\/main\//i.test(location.href), main: (data) => { const app = data.app; const cookies = document.cookie.split(";"); let chatglm_refresh_token = ""; cookies.forEach((cookie) => { if (/chatglm_refresh_token/i.test(cookie)) { chatglm_refresh_token = cookie.split("=")[1]; } }); if (chatglm_refresh_token) { app.app.gpt.forEach((item) => { if (item.name === "GLM") { item.key = chatglm_refresh_token; } }); app.setConfig(app.app); msg("智普清言token获取成功"); } } } ]; const parseRuleHook = (rule2) => { rule2.filter((item) => item.match && item.hook).forEach((item) => { console.log(item.name); item.hook(); }); }; const parseRule = async (rule2) => { await waitUntil(() => _unsafeWindow[key] !== void 0); const matchedRule = rule2.filter((item) => item.match); if (!matchedRule.length) { console.log("未匹配到任何任务"); return; } const app = wapp(); for (const item of matchedRule) { console.log(item.name); if (item.init) await item.init(); if (item.type === "hook") item.main(app); if (item.type === "ask") askParser(item, app); if (item.type === "save") saveParser(item, app); } }; const saveParser = (rule2, data) => { console.log(rule2, data); const app = data.app; const ask = data.ask; ask.rule = rule2; rule2.tips && (ask.tips = rule2.tips); app.app.showFloat = true; console.log("收录解析器"); app.setPage("question"); const quesList = questionSaveParser(rule2.question, rule2.answerHook || null).filter((item) => { return item.answer.length > 0 || item.answer !== ""; }); console.log(quesList); ask.saveQuestionData = quesList; quesList.forEach((item) => { Answer.cacheAnswer(item); }); msg(`题库收录完成,共缓存${quesList.length}道题目`, "success"); }; const askParser = (rule2, data) => { const app = data.app; const ask = data.ask; ask.rule = rule2; rule2.tips && (ask.tips = rule2.tips); app.app.showFloat = true; app.setPage("ask"); ask.clearQuestion(); const quesList = questionParser(rule2.question, rule2.questionHook || null); console.log(quesList); quesList.forEach((item) => { ask.addQuestion(item); }); ask.autoAnswer && ask.toggleStart(); }; const questionSaveParser = (item, hook) => { const quesLIst = $(item.html).map((index, element) => { const questionText = removeHtml1($(element).find(item.question).html()); const options = $(element).find(item.options).map((index2, element2) => { return removeHtml1($(element2).html()); }).get(); const questionTypeId = $(element).find(item.type).val(); const html2 = $(element)[0]; let questionData = { question: titleClean(questionText ?? ""), options, $options: $(element).find(item.options), $answer: $(element).find(item.answer), answer: [], type: questionTypeId, html: html2 }; hook && (questionData = hook(questionData, index)); return questionData; }); return quesLIst.get(); }; const questionParser = (item, hook) => { const quesLIst = $(item.html).map((index, element) => { const questionText = removeHtml1($(element).find(item.question).html()); const options = $(element).find(item.options).map((index2, element2) => { return removeHtml1($(element2).html()); }).get(); const questionTypeId = $(element).find(item.type).val(); const workType = item.workType; const html2 = $(element)[0]; let questionData = { question: titleClean(questionText ?? ""), options, $options: $(element).find(item.options), type: questionTypeId, html: html2, workType, pageType: item.pageType }; hook && (questionData = hook(questionData, index)); return questionData; }); return quesLIst.get(); }; const defaultSetAnswer = async (type, answer, html2, ques, rule2) => { var _a; rule2.setAnswerHook && rule2.setAnswerHook({ type, answer, html: html2, ques }); switch (type) { case "xx": for (var i = 0; i < answer.length; i++) { let index = answer[i]; console.log(index, ques.$options.eq(index)); if (rule2.ischecked && rule2.ischecked(ques.$options.eq(index))) { continue; } ques.$options.eq(index).click(); await sleep(Math.floor(Math.random() * 300 + 200)); } break; case "pd": let bold = answer; console.log(ques.$options, bold); ques.$options.each((index, element) => { if (isTrue(bold) && isTrue(ques.options[index])) { console.log(index, element); $(element).click(); } if (isFalse(bold) && isFalse(ques.options[index])) { console.log(index, element); $(element).click(); } }); break; case "jd": $(html2).find("textarea").each(function(index) { _unsafeWindow.UE.getEditor($(this).attr("name")).ready(function() { this.setContent(answer[index].replace(/第.空:/g, "")); }); }); (_a = $(html2).find(".savebtndiv>a")) == null ? void 0 : _a.click(); break; } }; const ApiAnswerMatch = (res, ques) => { const data = wapp(); const ask = data.ask; let setHook = true; let type = ques.type, html2 = ques.html; let matchArr = []; switch (type) { case "0": case "1": for (let i = 0; i < res.length; i++) { let answer2 = res[i].answer; let matchArr2 = matchAnswer(answer2, ques.options); res[i].match = matchArr2; } matchArr = res.filter((item) => item.match.length > 0); if (matchArr.length === 0) { return { res, haveAnswer: false }; } if (matchArr.length > 1) { let isSame = matchArr.every((item) => item.match.length === matchArr[0].match.length); if (!isSame) { let max = matchArr[0]; for (let i = 1; i < matchArr.length; i++) { if (matchArr[i].match.length > max.match.length) { max = matchArr[i]; } } matchArr = [max]; } } let selectM = matchArr[0].match; console.log(selectM); if (ask.rule.setAnswer && typeof ask.rule.setAnswer === "function") { setHook = ask.rule.setAnswer({ type, answer: selectM, html: html2, ques, rule: ask.rule }); } setHook && defaultSetAnswer("xx", selectM, html2, ques, ask.rule); break; case "3": matchArr = res.map((item) => { let answer2 = item.answer; if (typeof answer2 === "object") { answer2 = answer2[0]; } if (isTrue(answer2)) { item.answer = "正确"; } else if (isFalse(answer2)) { item.answer = "错误"; } else { item.answer = ""; } return item; }); matchArr = res.filter((item) => item.answer !== ""); if (matchArr.length === 0) { return { res, haveAnswer: false }; } if (ask.rule.setAnswer && typeof ask.rule.setAnswer === "function") { setHook = ask.rule.setAnswer({ type, answer: matchArr[0].answer, html: html2, ques, rule: ask.rule }); } setHook && defaultSetAnswer("pd", matchArr[0].answer, html2, ques, ask.rule); break; case "2": case "9": case "4": case "5": case "6": case "7": const blankNum = $(html2).find("textarea").length; matchArr = res.filter((item) => item.answer.length > 0); if (matchArr.length === 0) { return { res, haveAnswer: false }; } let answer = matchArr[0].answer; if (typeof answer === "string") { answer = [answer]; } if (ask.rule.setAnswer && typeof ask.rule.setAnswer === "function") { setHook = ask.rule.setAnswer({ type, answer, html: html2, ques, rule: ask.rule }); } if (setHook) { matchArr = matchArr.filter((item) => (typeof item.answer === "string" ? 1 : item.answer.length) === blankNum); if (matchArr.length === 0) { return { res, haveAnswer: false }; } defaultSetAnswer("jd", answer, html2, ques, ask.rule); } break; default: return { res, haveAnswer: false }; } return { res, // 采用答案 form: matchArr ? matchArr[0] : [], haveAnswer: true }; }; const randomAnswerMatch = (res, ques) => { console.log("随机选择一个答案"); const data = wapp(); const ask = data.ask; let setHook = true; let type = ques.type, html2 = ques.html; switch (type) { case "0": case "1": let selectM = ques.$options.eq(Math.floor(Math.random() * ques.$options.length)); console.log(selectM); if (ask.rule.setAnswer && typeof ask.rule.setAnswer === "function") { setHook = ask.rule.setAnswer({ type, answer: selectM, html: html2, ques, rule: ask.rule }); } setHook && defaultSetAnswer("xx", selectM, html2, ques, ask.rule); break; case "3": let bold = Math.random() > 0.5 ? "正确" : "错误"; if (ask.rule.setAnswer && typeof ask.rule.setAnswer === "function") { setHook = ask.rule.setAnswer({ type, answer: bold, html: html2, ques, rule: ask.rule }); } setHook && defaultSetAnswer("pd", bold, html2, ques, ask.rule); break; } return; }; const comHook = () => { Function.prototype.__constructor_back = Function.prototype.constructor; Function.prototype.constructor = function() { if (arguments && typeof arguments[0] === "string") { if ("debugger" === arguments[0]) { return; } } return Function.prototype.__constructor_back.apply(this, arguments); }; if (/onlineexamh5new.zhihuishu.com/i.test(location.href)) { let enableWebpackHook = function() { let originCall = Function.prototype.call; Function.prototype.call = function(...args) { var _a, _b, _c, _d; const result = originCall.apply(this, args); if (((_b = (_a = args[2]) == null ? void 0 : _a.default) == null ? void 0 : _b.version) === "2.5.2") { (_d = (_c = args[2]) == null ? void 0 : _c.default) == null ? void 0 : _d.mixin({ mounted: function() { this.$el["__Ivue__"] = this; } }); } return result; }; }; enableWebpackHook(); } }; const appConfig = { debug: true, // 第三方接口 searchApi: [], // 默认显示悬浮窗 showFloat: false, // 右下角看板 showBoard: true, // 检测更新 checkUpdate: true, // key key: "", gpt: [ { "name": "GLM", "desc": "智普清言4.0", "api": "http://82.157.105.20:8002/v1/chat/completions", "key": "" } ] }; const appCache = Cache.get("app") || appConfig; Object.keys(appConfig).forEach((key2) => { if (appCache[key2] === void 0) { appCache[key2] = appConfig[key2]; } setApp(appCache); }); function getApp() { return Cache.get("app") || appConfig; } function setApp(config) { Cache.set("app", config); } const scriptInfo = _GM_info.script; const ConfigInput = { "base": [ { "type": "switch", "label": "显示悬浮窗", "name": "showFloat", "value": appCache.showFloat, "desc": "打开页面时是否显示悬浮窗", "options": [] }, { "type": "switch", "label": "看板小图标", "name": "showBoard", "value": appCache.showBoard, "desc": "打开页面时是否显示右下角看板", "options": [] }, { "type": "switch", "label": "检测更新", "name": "checkUpdate", "value": appCache.checkUpdate, "desc": "打开页面时是否检测更新", "options": [] } ] }; const useAppStore = defineStore("app", { state: () => ({ app: appCache, script: scriptInfo, page: "home", ConfigInput }), actions: { setConfig(config) { this.app = config; Cache.set("app", config); }, // 修改页面 setPage(page) { this.page = page; } } }); const useAskStore = defineStore("ask", { state: () => ({ questionList: [], questionInx: 0, // 当前索引 inx: 0, Interval: 0, // 开启答题 start: false, // 跳过已答题 skipFinish: Cache.get("skipFinish", false), // 自动跳转 autoNext: Cache.get("autoNext", false), // 默认开启自动答题 autoAnswer: Cache.get("autoAnswer", true), // 免费题库优先 freeFirst: Cache.get("freeFirst", true), // 无答案随机答题 randomAnswer: Cache.get("randomAnswer", false), // 运行锁 lock: false, // 统计题库 formMap: {}, // 问答类型 type: "cx", // 加载状态 loading: false, // 默认msg tips: "本脚本仅供学习研究,请勿用于非法用途", saveQuestionData: [] }), actions: { addQuestion(questionData) { this.questionList.push({ ...questionData, answer: [], status: 0, aiMsg: "" }); }, // 清空问题列表 clearQuestion() { this.questionList = []; }, getQuestion() { return this.questionList[this.questionInx]; }, nextQuestion() { if (this.questionInx === this.questionList.length - 1) { clearInterval(this.Interval); this.start = false; return; } this.questionInx++; }, prevQuestion() { if (this.questionInx === 0) { return; } this.questionInx--; }, // 切换到指定问题 toQuestion(inx) { this.questionInx = inx; let ques = this.questionList[inx]; ques.html.scrollIntoView({ block: "center" }); if (_unsafeWindow.self !== _unsafeWindow.top) { let el = document.querySelector(".el-dialog"); if (el) { el.style.transform = "none"; let rect = ques.html.getBoundingClientRect(); el.style.top = `${rect.top - 700}px`; if (inx === 0) { el.style.top = "0px"; } if (inx === this.questionList.length - 1) { if (document.documentElement.scrollHeight > 2e3) { el.style.top = `${rect.top - 900}px`; } } } } ques.html.style.boxShadow = "0 0 10px rgba(0, 0, 0, 0.15)"; setTimeout(() => { ques.html.style.boxShadow = ""; }, 500); }, // 修改题目状态 setQuestionStatus(inx, status) { this.questionList[inx].status = status; }, // 切换答题状态 async toggleStart() { if (this.lock) return; this.start = !this.start; if (!this.start) return; this.lock = true; for (let i = this.questionInx; i < this.questionList.length && this.start; i++) { if (this.skipFinish && this.questionList[i].status === 1) { continue; } this.questionInx = i; let ques = this.questionList[i]; if (ques.type === "8") { this.setQuestionStatus(i, 2); continue; } this.reAnswer(i); await sleep(1e3 + Math.random() * 1e3); this.autoNext && this.rule.next && this.rule.next(); console.log(i, this.questionList.length); } this.autoNext && this.rule.finish && this.rule.finish({ "question": this.questionList }); this.start = false; this.lock = false; this.formMap = {}; this.questionList.forEach((item) => { var _a; if ((_a = item.form) == null ? void 0 : _a.form) { let key2 = item.form.form; if (key2) { this.formMap[key2] = this.formMap[key2] ? this.formMap[key2] + 1 : 1; } } else { this.formMap["无答案"] = this.formMap["无答案"] ? this.formMap["无答案"] + 1 : 1; } }); }, // 重答指定题 async reAnswer(inx) { let ques = this.questionList[inx]; this.loading = true; let res = await Answer.getAnswersFree(ques); let m = ApiAnswerMatch(res, ques); res = Answer.getCacheAnswer(ques); console.log(res, "cache"); m = ApiAnswerMatch([res], ques); if (!m.haveAnswer) { if (this.freeFirst) { res = await Answer.getAnswersFree(ques); m = ApiAnswerMatch(res, ques); if (!m.haveAnswer) { let res1 = await Answer.getAnswers(ques); res1 = res.concat(res1); m = ApiAnswerMatch(res1, ques); } } else { res = await Answer.getAllAnswers(ques); m = ApiAnswerMatch(res, ques); } } ques.answer = m.res; ques.form = m.form; if (!m.haveAnswer) { this.randomAnswer && randomAnswerMatch(res, ques); this.setQuestionStatus(inx, 2); } else { this.setQuestionStatus(inx, 1); } this.loading = false; }, // ai答题 async aiAnswer(inx) { const errorMsg = `AI响应异常,可能是没有获取KEY,请按下方步骤操作 1. 打开[智普清言](https://chatglm.cn/main/alltoolsdetail) 2. 登录后随便发一条消息即可 3. 返回答题页刷新页面 `; let ques = this.questionList[inx]; this.loading = true; let text2 = ""; ques.aiMsg = ""; text2 += `[${typeChange2(ques.type)}]${ques.question} `; ques.options.forEach((item, inx2) => { text2 += `${item} `; }); switch (ques.type) { case "24": ques.match.forEach((item, inx2) => { text2 += `第一列${item} `; }); ques.selects[0].forEach((item, inx2) => { text2 += `第二列${item.text} `; }); break; } console.log(text2); let res = await aiAsk(text2, (msg2) => { ques.aiMsg += msg2; if (ques.aiMsg.length > 0) { this.loading = false; } }, () => { console.log("finish"); this.loading = false; if (ques.aiMsg.length <= 0) { ques.aiMsg = errorMsg; } }); console.log(res); }, pause() { this.start = false; }, restart() { this.questionInx = 0; this.start = true; this.toggleStart(); } }, getters: { // 当前问题 current() { return this.questionList[this.questionInx]; }, currentAiMd() { const md = markdownit({ highlight: function(str, lang) { if (lang && hljs.getLanguage(lang)) { try { return '
' + hljs.highlight(str, { language: lang, ignoreIllegals: true }).value + "
"; } catch (__) { } } return '
' + md.utils.escapeHtml(str) + "
"; } }); return md.render(this.questionList[this.questionInx].aiMsg); } } }); const ApiCache = Cache.get("apiList", []); const DefApi = { name: "", url: "", method: "GET", params: [], response: [], request: [], headers: [] }; const DefParam = { name: "", value: "", type: "sys" }; const testQuestionData = { "question": "急性吗啡中毒的拮抗剂是:", "options": ["纳酪酮", "曲马朵", "尼莫地平", "阿托品", "肾上腺素"], "type": "0", "questionData": "", "workType": "ks" }; const useApiStore = defineStore("api", { state: () => ({ apiList: ApiCache, // 当前编辑的接口 currentApi: DefApi, currentParam: DefParam }), actions: { // 删除接口 deleteApi(index) { this.apiList.splice(index, 1); Cache.set("apiList", this.apiList); }, // 添加接口 addApi() { this.apiList.push(this.currentApi); console.log(this.currentParam); Cache.set("apiList", this.apiList); }, // 更新接口 updateApi(index, api) { this.apiList[index] = api; Cache.set("apiList", this.apiList); }, // 添加参数 addParam() { this.currentApi.params.push({ name: this.currentParam.name, value: this.currentParam.value, type: this.currentParam.type }); this.currentParam = DefParam; }, // 删除参数 deleteParam(index) { this.currentApi.params.splice(index, 1); }, // 恢复默认 reset() { this.currentApi = DefApi; this.currentParam = DefParam; }, // 编辑接口 editApi(index) { this.currentApi = this.apiList[index]; }, // 编辑参数 editParam(index) { this.currentParam = this.currentApi.params[index]; }, // 测试API testApi(index) { let api = this.apiList[index]; console.log(api); let data = {}; api.params.forEach((item) => { console.log(item.value); switch (item.value) { case "$question": data[item.name] = testQuestionData.question; console.log(testQuestionData.question); break; case "$options": data[item.name] = testQuestionData.options; break; case "$typeid": data[item.name] = testQuestionData.type; break; case "$questionData": data[item.name] = testQuestionData.questionData; break; case "$workType": data[item.name] = testQuestionData.workType; break; case "$timestamp": data[item.name] = (/* @__PURE__ */ new Date()).getTime(); break; case "$random": data[item.name] = Math.random(); break; default: data[item.name] = item.value; } }); console.log(api.url, api.method, data); return requestFetch(api.url, api.method, data, {}); } }, getters: {} }); const mini = "data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20t='1702363595473'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='9984'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='200'%20height='200'%3e%3cpath%20d='M253.360825%201024l-115.279176-58.836014v-53.205773c-64.888522-68.266667-62.917938-94.728797%2014.075602-153.424055-23.506254-17.594502-63.762474%202.674364-77.275052-36.315051%2047.434777-42.930584%2070.378007-101.062818%2087.972509-162.010172a326.694708%20326.694708%200%200%201%20208.037388-226.617182c4.644948-89.380069%2086.84646-143.430378%20178.478626-112.604811l-35.611272%2090.36536c105.144742%207.319313%20192.413471%2045.041924%20256.316701%20123.302268%2040.537732%2015.483162%2038.84866-34.766735%2069.251959-40.819244l11.964261%2058.27299%2050.390653-27.306667c28.151203%2018.72055-5.207973%2031.951615-10.415945%2052.220482%2014.779381%2020.12811%2028.995739%2040.537732%2044.4789%2060.243573a142.867354%20142.867354%200%200%201%2028.995739%20114.153128c-12.527285%2077.838076-30.262543%20154.831615-41.100756%20233.091958a1276.938557%201276.938557%200%200%200-5.207972%20139.48921h-21.113402l-89.239313-70.378007%209.993677-10.415945-17.735258%2036.878076L731.931271%20959.956014l-39.411683%2023.787766-42.226804-21.113402c-28.151203%2014.075601-52.501993%2036.03354-86.564949%2027.306667l-9.008385-37.863368H332.747216l-26.602886%2071.926323z%20m-9.993677-380.041237l-0.844536%200.985292%20126.680412%2019.705842%2010.838213%2010.978969c-29.277251%2032.373883-19.846598%2074.178419-29.699519%20110.493471L384.404674%20816.38488l-35.189004%2094.869553a412.274364%20412.274364%200%200%200%20233.514227%202.11134l9.712165-26.602886%2012.808797%2015.905429-11.823505%2050.672165%205.348728%204.644949c16.749966-11.682749%2033.218419-24.210034%2050.812921-34.62598a84.453608%2084.453608%200%200%201%2026.039863-5.348728l7.460069%2033.922199L731.931271%20928.145155l52.924262%2014.075601c-1.829828-43.212096-2.955876-80.934708-5.911753-118.516564%200-4.92646-9.852921-9.289897-15.060893-14.075601l-5.630241-23.224742%2014.075601-100.922062h18.72055l3.237389-1.266804c-11.964261%20106.411546%208.023093%20202.266392%2087.127972%20281.512027%208.726873-48.842337%2016.60921-93.321237%2024.632302-137.659381%207.460069-40.96%2015.060893-81.92%2022.520963-122.88%2010.556701-48.420069%2025.476838-97.262405-10.978969-140.756014L886.762887%20602.435739c0-16.468454%201.126048-33.077663%201.126048-49.546117%200-70.378007-53.205773-104.722474-115.982956-76.289759a232.951203%20232.951203%200%200%201-32.936907%209.430652c16.046186-32.373883-3.5189-52.924261-25.476838-70.378006a292.209485%20292.209485%200%200%200-209.304193-70.378007c-11.401237%200.70378-22.802474%200-40.25622%200l45.182681-104.581718c-40.396976%2010.978969-74.037663%2014.779381-94.728798%2045.464192s14.920137%2045.88646%2020.831891%2069.674227C325.005636%20360.194639%20232.528935%20436.343643%20198.606735%20548.948454l-70.378006%20172.707628%2049.123848%203.518901%205.630241%2054.191065c32.514639-26.039863%2026.039863-61.08811%2030.262543-92.898969h17.876014v58.413746l30.966323%206.33402c1.40756-6.615533%202.392852-11.682749%203.659656-16.468453%209.149141-34.625979-19.705842-59.117526-22.380206-91.491409zM205.50378%20822.859656l-6.474777%2020.83189-25.336082%2084.453609c1.548316%208.867629%200%2023.224742%205.067216%2025.476838%2032.373883%2016.046186%2065.733058%2029.277251%20104.159451%2045.745705%2021.113402-65.451546%2063.621718-114.434639%2069.53347-180.871478C315.152715%20802.309278%20281.512027%20786.966873%20247.730584%20774.158076c-17.031478-6.756289-36.315052-10.978969-35.048247%2019.002061z%20m121.753952-38.848659l10.556701-90.224605-48.138557-6.193265v78.964124z%20m-168.907217%2096.980893l23.083987-73.474639c-28.151203-10.415945-47.575533-9.289897-56.302406%2015.483161s2.674364%2042.789828%2032.936907%2057.991478z'%20fill='%23353947'%20p-id='9985'%3e%3c/path%3e%3cpath%20d='M198.606735%20548.948454c33.922199-112.604811%20126.680412-188.472302%20235.907079-192.272715-5.911753-23.787766-41.100756-39.55244-20.83189-69.674227s54.331821-34.485223%2094.728798-45.464192l-45.182681%20104.581718h40.25622a292.209485%20292.209485%200%200%201%20209.304193%2070.378007c21.957938%2017.735258%2042.226804%2038.285636%2025.476838%2070.378007l0.985292-0.985293c-30.966323%2026.743643-32.796151%2059.399038-19.846598%2095.151066l25.195327%2040.96-40.819244-6.193265-103.174158-14.075601-62.214158-93.039725-31.670104%2050.672165c-19.42433-5.630241-26.602887%200.844536-20.691134%2020.691134L464.494845%20579.210997a165.669828%20165.669828%200%200%200-100.077525-17.172234l-10.415945-86.564949L316.560275%20506.721649l-44.338144%2042.226805z%20m255.190653-62.917939l-10.556701-10.556701c-17.172234-17.031478-35.048247-15.060893-47.29402%203.378145s-4.785704%2036.73732%2012.105017%2050.249897c20.12811%2016.046186%2034.907491%209.712165%2045.745704-11.541993%2014.216357-10.838213%2015.201649-21.394914%200-31.81086z'%20fill='%23F5F5F6'%20p-id='9986'%20data-spm-anchor-id='a313x.search_index.0.i5.dc0f3a810XA6r8'%20class='selected'%3e%3c/path%3e%3cpath%20d='M592.442062%20886.762887l-9.712165%2026.602886a412.274364%20412.274364%200%200%201-233.514227-2.11134l35.189004-94.869553-34.062956-30.544055c9.852921-36.315052%200-78.119588%2029.699519-110.493471a198.184467%20198.184467%200%200%200%20105.426254-94.869553c16.327698%202.392852%2026.039863-1.689072%2020.691134-20.691134l31.670104-4.926461L600.887423%20633.402062c0%207.882337-1.970584%2018.01677%201.970584%2023.083986%2030.966323%2038.707904%2023.787766%2080.934708%2014.075601%20123.865292-8.586117%2036.03354-16.468454%2071.363299-24.491546%20106.411547zM442.818419%20663.523849c0%2014.075601-2.81512%2023.64701%200%2026.884398%2020.268866%2020.691134%2020.83189%2045.604948%2019.565086%2071.926323a96.840137%2096.840137%200%200%200%203.237388%2031.107079c5.911753%2020.409622%2012.668041%2041.382268%2038.426392%2044.056633A48.560825%2048.560825%200%200%200%20557.393814%20802.309278a696.601512%20696.601512%200%200%200%2018.579794-80.371683c6.052509-6.474777%2035.470515-2.533608%2018.157526-36.596564z'%20fill='%23F5F5F6'%20p-id='9987'%3e%3c/path%3e%3cpath%20d='M600.605911%20602.013471l103.174158%2014.075601%2040.819244%205.348729c37.863368%209.993677%2022.94323%2041.241512%2026.46213%2065.170034l-14.075601%20100.922062-49.827629%2078.119588-21.394914%2031.529347-10.134433%2021.394914a84.453608%2084.453608%200%200%200-26.039863%205.348728c-17.594502%2010.415945-34.062955%2022.94323-50.812921%2034.62598v-5.207973h-5.067216l11.823505-50.672165c16.046186-61.932646%2032.936907-123.724536%2047.716289-185.938694%205.348729-22.661718-25.476838-68.266667-51.938969-82.62378zM927.300619%20706.735945c-7.460069%2040.96-15.060893%2081.92-22.520963%20122.88-8.023093%2044.338144-15.90543%2088.817045-24.632302%20137.659381-79.10488-79.386392-98.52921-175.241237-87.127973-281.512027z'%20fill='%23B3DCF8'%20p-id='9988'%3e%3c/path%3e%3cpath%20d='M199.029003%20843.691546l6.474777-20.83189h45.604949c2.11134-39.270928-20.972646-30.262543-38.426392-30.121787-1.548316-29.981031%2018.01677-25.758351%2035.048247-18.579793%2034.062955%2013.231065%2067.422131%2028.151203%20104.722474%2044.4789-5.911753%2066.436838-48.420069%20115.419931-69.53347%20180.871478-38.426392-16.186942-71.926323-29.418007-104.159451-45.182681-4.785704-2.252096-3.5189-16.60921-5.067216-25.476838h33.499931l26.321375-70.378007z'%20fill='%2387BC85'%20p-id='9989'%3e%3c/path%3e%3cpath%20d='M738.265292%20486.030515a232.951203%20232.951203%200%200%200%2032.936907-9.430652c62.777182-28.151203%20116.405223%206.615533%20115.982956%2076.289759%200%2016.468454-0.70378%2033.077663-1.126048%2049.546117l1.126048-0.985292-12.105018-2.674365-21.53567%2016.749966-29.981031%208.304605A86.564948%2086.564948%200%200%201%20731.931271%20564.572371c2.392852-26.462131%204.644948-52.924261%207.037801-79.527148z%20m113.730859%2061.79189l-61.369622-52.501993c-3.941168%2035.752027-6.615533%2059.821306-10.275189%2093.180481z'%20fill='%23F5F5F6'%20p-id='9990'%20data-spm-anchor-id='a313x.search_index.0.i3.dc0f3a810XA6r8'%20class=''%3e%3c/path%3e%3cpath%20d='M198.606735%20548.948454h73.615396c-28.151203%2042.226804-74.178419%2076.852784-59.117526%20137.659381-4.22268%2031.810859%202.252096%2066.859107-30.262543%2092.898969l-6.052509-54.472577-49.123849-3.518901z'%20fill='%23AED4EF'%20p-id='9991'%3e%3c/path%3e%3cpath%20d='M927.300619%20706.735945l-134.281238-21.113402-3.237388%201.266804%206.897045-37.863368%2027.025154-7.74158%2031.247835-8.867629%2029.840275-20.691134%202.392853-10.275189-0.422268%200.985292%2030.262543-36.73732c35.752027%2043.77512%2020.83189%2092.617457%2010.275189%20141.037526zM369.625292%20663.946117l-126.680412-19.705842a171.300069%20171.300069%200%200%201%2016.749965-41.100756c21.817182-29.277251%2046.167973-56.302405%2069.533471-84.453608%203.237388%209.149141%206.756289%2018.157526%209.571409%2027.306666q15.623918%2049.123849%2030.966323%2098.52921z'%20fill='%23F5F5F6'%20p-id='9992'%3e%3c/path%3e%3cpath%20d='M763.179107%20810.473127c5.207973%204.644948%2014.075601%209.008385%2015.060893%2014.075602%202.955876%2037.581856%204.081924%2075.304467%205.911753%20118.516563l-52.924262-14.075601-47.9978%2023.787766-7.600825-34.766735c14.075601-1.970584%2020.550378-7.882337%2010.978969-21.817182%2021.394914%2011.682749%2023.787766-9.993677%2033.359175-19.002062z'%20fill='%23AED4EF'%20p-id='9993'%3e%3c/path%3e%3cpath%20d='M601.168935%20634.105842c26.462131%2014.075601%2057.287698%2059.962062%2051.938969%2082.62378-14.075601%2062.214158-31.670103%20124.006048-47.716289%20185.938694L592.442062%20886.762887c8.023093-35.329759%2015.90543-70.378007%2024.35079-105.989279%2010.134433-42.930584%2017.31299-85.157388-14.075601-123.865292-3.5189-4.785704-0.985292-14.920137-1.548316-22.802474zM328.806048%20518.404399c-23.365498%2028.151203-47.716289%2055.457869-69.533471%2084.453608a171.300069%20171.300069%200%200%200-16.749965%2041.100756l0.844536-0.985292-12.386529%2043.07134h-17.876014C198.043711%20625.660481%20243.507904%20591.175258%20272.222131%20548.948454l44.338144-42.226805z'%20fill='%23484F5E'%20p-id='9994'%3e%3c/path%3e%3cpath%20d='M327.257732%20784.010997l-37.581856-17.453746v-78.964124l48.138557%206.193265z'%20fill='%23D55375'%20p-id='9995'%3e%3c/path%3e%3cpath%20d='M823.704192%20641.284399l-27.025154%207.74158-6.897045%2037.863368h-18.72055c-3.5189-23.928522%2011.401237-55.176357-26.46213-65.170034l-25.195327-40.96%2012.527285-16.186942a86.564948%2086.564948%200%200%200%2091.350653%2059.258282zM369.625292%20663.946117v-19.846598l12.245773-12.949553c8.445361%201.266804%2020.409622%206.897045%2024.773059%203.237388%2020.550378-17.031478%2038.989416-36.455808%2058.132233-55.176357l20.972646%201.548316A198.184467%20198.184467%200%200%201%20380.041237%20675.628866z'%20fill='%23484F5E'%20p-id='9996'%3e%3c/path%3e%3cpath%20d='M199.029003%20843.691546l34.485224%2014.075602-26.321375%2070.378007h-33.499931z'%20fill='%23CAE7AF'%20p-id='9997'%3e%3c/path%3e%3cpath%20d='M230.980619%20686.326323l12.386529-43.07134c2.674364%2031.670103%2031.529347%2056.302405%2022.23945%2091.350653-1.266804%204.785704-2.252096%209.852921-3.659656%2016.468453l-30.966323-6.33402z'%20fill='%23F5F5F6'%20p-id='9998'%3e%3c/path%3e%3cpath%20d='M763.179107%20810.473127l-44.056633%2067.703643-11.964261-12.527285%2050.390653-78.4011z'%20fill='%23484F5E'%20p-id='9999'%3e%3c/path%3e%3cpath%20d='M212.682337%20792.737869c17.453746%200%2040.537732-9.149141%2038.426392%2030.121787H205.50378z'%20fill='%23CDEAB1'%20p-id='10000'%3e%3c/path%3e%3cpath%20d='M598.916838%20957.98543l-5.348728-4.644949h5.067216z'%20fill='%23484F5E'%20p-id='10001'%3e%3c/path%3e%3cpath%20d='M464.494845%20579.210997c-19.142818%2018.72055-37.581856%2038.14488-58.132233%2055.176357-4.363436%203.659656-16.327698-1.970584-24.773059-3.237388l-17.172233-69.111203A165.669828%20165.669828%200%200%201%20464.494845%20579.210997z'%20fill='%23AED4EF'%20p-id='10002'%3e%3c/path%3e%3cpath%20d='M364.41732%20562.038763l17.172233%2069.111203-12.245773%2012.949553q-15.342405-49.123849-30.966323-98.52921c-2.81512-9.149141-6.334021-18.157526-9.571409-27.306666l-12.245773-11.541994%2037.4411-30.966323z'%20fill='%23353947'%20p-id='10003'%3e%3c/path%3e%3cpath%20d='M600.605911%20602.013471v31.670103l-62.214158-79.245636-31.670104%204.926461%2031.388592-50.390653z'%20fill='%23484F5E'%20p-id='10004'%3e%3c/path%3e%3cpath%20d='M453.797388%20517.278351c-10.838213%2021.254158-25.617595%2028.151203-45.745704%2011.541993-16.890722-14.075601-24.632302-31.529347-12.105017-50.249897s30.121787-20.409622%2047.29402-3.378145c-23.506254%200.985292-34.766735%2011.541993-29.136495%2039.411684l39.693196%203.096633z'%20fill='%23AED4EF'%20p-id='10005'%3e%3c/path%3e%3cpath%20d='M731.931271%20564.572371l-12.808797%2015.623918c-12.949553-35.752027-11.119725-68.407423%2019.846598-95.151066-2.11134%2026.602887-4.363436%2053.065017-7.037801%2079.527148z'%20fill='%23353947'%20p-id='10006'%3e%3c/path%3e%3cpath%20d='M506.721649%20559.786667c5.348729%2019.002062-4.363436%2023.083986-20.691134%2020.691134-6.193265-19.846598%200.985292-26.321375%2020.691134-20.691134z'%20fill='%23484F5E'%20p-id='10007'%3e%3c/path%3e%3cpath%20d='M453.797388%20485.749003c15.201649%2010.415945%2014.075601%2020.972646%200%2031.529348v-31.81086zM443.240687%20475.192302l10.556701%2010.556701-10.556701-10.556701z'%20fill='%23AED4EF'%20p-id='10008'%3e%3c/path%3e%3cpath%20d='M442.818419%20663.523849l151.312715%2022.098694c17.31299%2034.062955-12.105017%2030.121787-18.157526%2036.596564A696.601512%20696.601512%200%200%201%20557.393814%20802.309278a48.560825%2048.560825%200%200%201-52.783505%2034.907492c-25.758351-2.674364-32.514639-23.64701-38.426391-44.056633a96.840137%2096.840137%200%200%201-3.237389-31.107079c1.266804-26.321375%200-51.235189-19.565086-71.926323-3.378144-2.955876-0.563024-12.386529-0.563024-26.602886z%20m66.296083%20153.987079c41.523024-26.462131%2042.226804-60.38433%2034.766735-98.52921l-55.317113-10.275189c-0.422268%2038.707904-15.201649%2075.163711%2020.550378%20108.804399zM707.158213%20865.649485l11.964261%2012.527285c-9.571409%209.008385-11.964261%2030.684811-33.359175%2019.002062z'%20fill='%23353947'%20p-id='10009'%3e%3c/path%3e%3cpath%20d='M686.185567%20896.756564c9.571409%2014.075601%202.955876%2019.846598-10.978969%2021.817182zM851.996151%20547.822405l-71.644811%2040.678488c3.659656-33.359175%206.334021-57.428454%2010.275189-93.180481z'%20fill='%23353947'%20p-id='10010'%3e%3c/path%3e%3cpath%20d='M884.792302%20611.725636l-29.840275%2020.691134-1.40756-16.890722%2021.53567-16.749966z'%20fill='%23484F5E'%20p-id='10011'%20data-spm-anchor-id='a313x.search_index.0.i4.dc0f3a810XA6r8'%20class='selected'%3e%3c/path%3e%3cpath%20d='M853.544467%20615.526048l1.40756%2016.890722-31.247835%208.867629v-17.453746zM884.792302%20611.725636l-9.712165-12.949554%2012.105018%202.674365z'%20fill='%23353947'%20p-id='10012'%3e%3c/path%3e%3cpath%20d='M443.522199%20474.91079l10.556701%2010.556701v31.951616l-39.693196-3.096633c-6.193265-27.869691%205.630241-38.426392%2029.136495-39.411684z'%20fill='%23F5F5F6'%20p-id='10013'%3e%3c/path%3e%3cpath%20d='M509.114502%20817.510928c-35.752027-33.640687-20.972646-70.378007-20.550378-108.804399l55.317113%2010.275189c7.882337%2038.14488%206.756289%2072.067079-34.766735%2098.52921z'%20fill='%23E25679'%20p-id='10014'%3e%3c/path%3e%3c/svg%3e"; const _withScopeId = (n) => (vue.pushScopeId("data-v-906f2363"), n = n(), vue.popScopeId(), n); const _hoisted_1$5 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ vue.createElementVNode("p", null, "本脚本仅供学习交流,请勿用作任何非法用途。", -1)); const _hoisted_2$3 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ vue.createElementVNode("p", null, "如果有其他平台需要答题功能,请反馈给作者,会根据需求量酌情增加", -1)); const _hoisted_3$3 = { class: "aah_plat" }; const _hoisted_4$2 = { key: 0 }; const _sfc_main$7 = /* @__PURE__ */ vue.defineComponent({ __name: "Home", setup(__props) { const appStore = useAppStore(); scriptInfo$1.script.downloadURL ?? "#"; const debug = vue.ref(true); return (_ctx, _cache) => { const _component_el_alert = vue.resolveComponent("el-alert"); const _component_el_divider = vue.resolveComponent("el-divider"); const _component_el_tag = vue.resolveComponent("el-tag"); const _component_el_button = vue.resolveComponent("el-button"); const _component_el_col = vue.resolveComponent("el-col"); const _component_el_row = vue.resolveComponent("el-row"); return vue.openBlock(), vue.createBlock(_component_el_row, null, { default: vue.withCtx(() => [ vue.createVNode(_component_el_col, { span: 24 }, { default: vue.withCtx(() => [ vue.createVNode(_component_el_alert, { type: "info", closable: false }, { title: vue.withCtx(() => [ _hoisted_1$5, _hoisted_2$3 ]), _: 1 }), vue.createVNode(_component_el_divider, null, { default: vue.withCtx(() => [ vue.createTextVNode("功能列表") ]), _: 1 }), vue.createElementVNode("div", _hoisted_3$3, [ vue.createVNode(_component_el_tag, null, { default: vue.withCtx(() => [ vue.createTextVNode("多平台答案检索") ]), _: 1 }), vue.createVNode(_component_el_tag, null, { default: vue.withCtx(() => [ vue.createTextVNode("AI辅助答题") ]), _: 1 }), vue.createVNode(_component_el_tag, null, { default: vue.withCtx(() => [ vue.createTextVNode("解除复制限制") ]), _: 1 }), vue.createVNode(_component_el_tag, null, { default: vue.withCtx(() => [ vue.createTextVNode("更多功能待添加..") ]), _: 1 }) ]), debug.value ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_4$2, [ vue.createVNode(_component_el_button, { type: "primary", plain: "", onClick: _cache[0] || (_cache[0] = ($event) => vue.unref(appStore).setPage("Base")) }, { default: vue.withCtx(() => [ vue.createTextVNode("基础配置") ]), _: 1 }), vue.createVNode(_component_el_button, { type: "primary", plain: "", onClick: _cache[1] || (_cache[1] = ($event) => vue.unref(appStore).setPage("api")) }, { default: vue.withCtx(() => [ vue.createTextVNode("题库配置") ]), _: 1 }), vue.createVNode(_component_el_button, { type: "primary", plain: "", onClick: _cache[2] || (_cache[2] = ($event) => vue.unref(appStore).setPage("ask")) }, { default: vue.withCtx(() => [ vue.createTextVNode("答题页") ]), _: 1 }), vue.createVNode(_component_el_button, { type: "primary", plain: "", onClick: _cache[3] || (_cache[3] = ($event) => vue.unref(appStore).setPage("question")) }, { default: vue.withCtx(() => [ vue.createTextVNode("本地题库") ]), _: 1 }), vue.createVNode(_component_el_button, { type: "primary", plain: "", onClick: _cache[4] || (_cache[4] = ($event) => vue.unref(appStore).setPage("ai")) }, { default: vue.withCtx(() => [ vue.createTextVNode("AI") ]), _: 1 }) ])) : vue.createCommentVNode("", true) ]), _: 1 }) ]), _: 1 }); }; } }); const _export_sfc = (sfc, props) => { const target = sfc.__vccOpts || sfc; for (const [key2, val] of props) { target[key2] = val; } return target; }; const Home = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["__scopeId", "data-v-906f2363"]]); const _sfc_main$6 = {}; function _sfc_render$1(_ctx, _cache) { return vue.openBlock(), vue.createElementBlock("h1", null, "这是一个公告"); } const Note = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["render", _sfc_render$1]]); const _hoisted_1$4 = { style: { "margin": "10px" } }; const _sfc_main$5 = /* @__PURE__ */ vue.defineComponent({ __name: "Base", setup(__props) { const appStore = useAppStore(); vue.watch(appStore.app, (newVal) => { console.log(newVal); appStore.setConfig(newVal); }); vue.watch(appStore.ConfigInput, (newVal) => { for (let key2 in newVal) { for (let key1 in newVal[key2]) { let item = newVal[key2][key1]; appStore.app[item.name] = item.value; } } console.log(appStore.app); appStore.setConfig(appStore.app); }); const ConfigInput2 = appStore.ConfigInput; return (_ctx, _cache) => { const _component_el_alert = vue.resolveComponent("el-alert"); const _component_el_col = vue.resolveComponent("el-col"); const _component_el_switch = vue.resolveComponent("el-switch"); const _component_el_input = vue.resolveComponent("el-input"); const _component_el_input_number = vue.resolveComponent("el-input-number"); const _component_el_option = vue.resolveComponent("el-option"); const _component_el_select = vue.resolveComponent("el-select"); const _component_el_checkbox = vue.resolveComponent("el-checkbox"); const _component_el_checkbox_group = vue.resolveComponent("el-checkbox-group"); const _component_el_tooltip = vue.resolveComponent("el-tooltip"); const _component_el_row = vue.resolveComponent("el-row"); return vue.openBlock(), vue.createElementBlock(vue.Fragment, null, [ vue.createVNode(_component_el_alert, { title: "配置修改后会自动保存,直接刷新页面即可", type: "info", closable: false, "show-icon": "" }), (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(vue.unref(ConfigInput2).base, (item1) => { return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$4, [ vue.createVNode(_component_el_row, { class: "row-bg", justify: "space-between", align: "middle" }, { default: vue.withCtx(() => [ vue.createVNode(_component_el_col, { span: 6 }, { default: vue.withCtx(() => [ vue.createTextVNode(vue.toDisplayString(item1.label), 1) ]), _: 2 }, 1024), vue.createVNode(_component_el_col, { span: 18, style: { "text-align": "right" } }, { default: vue.withCtx(() => [ vue.createVNode(_component_el_tooltip, { class: "grid-content ep-bg-purple-light", effect: "dark", content: item1.desc || "", placement: "top" }, { default: vue.withCtx(() => [ item1.type === "switch" ? (vue.openBlock(), vue.createBlock(_component_el_switch, { key: 0, modelValue: item1.value, "onUpdate:modelValue": ($event) => item1.value = $event }, null, 8, ["modelValue", "onUpdate:modelValue"])) : item1.type === "input" ? (vue.openBlock(), vue.createBlock(_component_el_input, { key: 1, modelValue: item1.value, "onUpdate:modelValue": ($event) => item1.value = $event }, null, 8, ["modelValue", "onUpdate:modelValue"])) : item1.type === "number" ? (vue.openBlock(), vue.createBlock(_component_el_input_number, { key: 2, modelValue: item1.value, "onUpdate:modelValue": ($event) => item1.value = $event }, null, 8, ["modelValue", "onUpdate:modelValue"])) : item1.type === "select" ? (vue.openBlock(), vue.createBlock(_component_el_select, { key: 3, modelValue: item1.value, "onUpdate:modelValue": ($event) => item1.value = $event, placeholder: "请选择" }, { default: vue.withCtx(() => [ (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(item1.options, (item2) => { return vue.openBlock(), vue.createBlock(_component_el_option, { key: item2.value, label: item2.label, value: item2.value }, null, 8, ["label", "value"]); }), 128)) ]), _: 2 }, 1032, ["modelValue", "onUpdate:modelValue"])) : item1.type === "checkbox" ? (vue.openBlock(), vue.createBlock(_component_el_checkbox_group, { key: 4, modelValue: item1.value, "onUpdate:modelValue": ($event) => item1.value = $event }, { default: vue.withCtx(() => [ (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(item1.options, (item2) => { return vue.openBlock(), vue.createBlock(_component_el_checkbox, { key: item2.value, label: item2.value, name: item2.value }, { default: vue.withCtx(() => [ vue.createTextVNode(vue.toDisplayString(item2.label), 1) ]), _: 2 }, 1032, ["label", "name"]); }), 128)) ]), _: 2 }, 1032, ["modelValue", "onUpdate:modelValue"])) : vue.createCommentVNode("", true) ]), _: 2 }, 1032, ["content"]) ]), _: 2 }, 1024) ]), _: 2 }, 1024) ]); }), 256)) ], 64); }; } }); function makeShadow(el, option) { return makeShadowRaw(el, el.childNodes, option); } function makeShadowRaw(rootEl, childNodes, { mode = "open", delegatesFocus = false } = { mode: "open" }) { try { const oldroot = rootEl.shadowRoot; if (oldroot != null) { console.error("[shadow] Attach shadow multiple times", rootEl, childNodes, oldroot); return; } else { const shadow_root = rootEl.attachShadow({ mode, delegatesFocus }); if (childNodes) putDomIntoShadow(shadow_root, childNodes); return shadow_root; } } catch (e) { console.error("[shadow] make shadow-root failed", rootEl, childNodes); console.error(e); } } function putDomIntoShadow(shadow_root, childNodes) { const fragment = document.createDocumentFragment(); for (const node of childNodes) { fragment.appendChild(node); } shadow_root.appendChild(fragment); } const virtual_root = document.createDocumentFragment(); const ShadowStyle = vue.defineComponent({ props: { media: String, nonce: String }, setup(props, { slots }) { return () => { var _a; return vue.h("style", { media: props.media, nonce: props.nonce }, (_a = slots.default) == null ? void 0 : _a.call(slots)); }; } }); const ShadowRoot = withType()(vue.defineComponent({ props: { mode: { type: String, default: "open" }, delegatesFocus: { type: Boolean, default: false }, abstract: { type: Boolean, default: false }, tag: { type: String, default: "div" }, adoptedStyleSheets: { type: Array } }, emits: ["error"], setup(props, { slots, expose, emit }) { const abstract = vue.ref(false); const el = vue.ref(); const teleport_el = vue.ref(); const shadow_root = vue.ref(); const teleport_target = vue.computed(() => shadow_root.value ?? virtual_root); const ex = vue.reactive({ shadow_root }); expose(ex); vue.onBeforeMount(() => { abstract.value = props.abstract; }); vue.onMounted(() => { var _a; try { if (abstract.value) { if (teleport_el.value.parentElement.shadowRoot) { shadow_root.value = teleport_el.value.parentElement.shadowRoot; } else { shadow_root.value = makeShadowRaw(teleport_el.value.parentElement, void 0, { mode: props.mode, delegatesFocus: props.delegatesFocus }); } } else { shadow_root.value = makeShadowRaw(el.value, void 0, { mode: props.mode, delegatesFocus: props.delegatesFocus }); } (_a = shadow_root.value) == null ? void 0 : _a.styleSheets; } catch (e) { console.error(e); emit("error", e); } }); vue.watch([shadow_root, () => props.adoptedStyleSheets], ([shadow_root2, adoptedStyleSheets]) => { if (!shadow_root2 || !adoptedStyleSheets) return; try { ; shadow_root2.adoptedStyleSheets = adoptedStyleSheets; } catch (e) { console.error(e); emit("error", e); } }); return () => { var _a; const child_part = vue.h(vue.Teleport, { ref: teleport_el, to: teleport_target.value }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]); if (abstract.value) return child_part; return vue.h(props.tag, { ref: el }, child_part); }; }, install, Style: ShadowStyle })); function withType() { return (obj) => obj; } function install(app) { app.component("shadow-root", ShadowRoot); app.directive("shadow", { beforeMount(el) { console.warn("[VueShadowDom] Deprecated v-shadow directive, use component"); makeShadow(el); } }); } var shadow = { ShadowRoot, ShadowStyle, shadow_root: ShadowRoot, shadow_style: ShadowStyle, install }; const _hoisted_1$3 = /* @__PURE__ */ vue.createElementVNode("div", { class: "aah_bomHet50" }, [ /* @__PURE__ */ vue.createElementVNode("span", { class: "dq" }, [ /* @__PURE__ */ vue.createElementVNode("i"), /* @__PURE__ */ vue.createTextVNode("当前题目") ]), /* @__PURE__ */ vue.createElementVNode("span", { class: "yp" }, [ /* @__PURE__ */ vue.createElementVNode("i"), /* @__PURE__ */ vue.createTextVNode("已作答") ]), /* @__PURE__ */ vue.createElementVNode("span", { class: "wp" }, [ /* @__PURE__ */ vue.createElementVNode("i"), /* @__PURE__ */ vue.createTextVNode("无答案") ]), /* @__PURE__ */ vue.createElementVNode("span", { class: "zp" }, [ /* @__PURE__ */ vue.createElementVNode("i"), /* @__PURE__ */ vue.createTextVNode("未作答") ]) ], -1); const _hoisted_2$2 = ["innerHTML"]; const _hoisted_3$2 = ["innerHTML"]; const _hoisted_4$1 = { key: 0 }; const _hoisted_5$1 = { style: { "width": "100%" } }; const _hoisted_6$1 = ["innerHTML"]; const _hoisted_7 = ["value"]; const _hoisted_8 = { key: 1, style: { "color": "green" } }; const _hoisted_9 = { key: 2, style: { "color": "red" } }; const _hoisted_10 = { key: 0 }; const _hoisted_11 = { key: 1 }; const _hoisted_12 = ["innerHTML"]; const _hoisted_13 = { key: 0 }; const _hoisted_14 = ["innerHTML"]; const _sfc_main$4 = /* @__PURE__ */ vue.defineComponent({ __name: "Ask", setup(__props) { const ask = useAskStore(); const app = useAppStore(); const getOptionIndex = (inx) => { return String.fromCharCode(65 + inx); }; vue.watch(app.app, (newVal) => { console.log(newVal); app.setConfig(newVal); }); const watchAutoNext = () => { console.log(ask.autoNext); Cache.set("autoNext", ask.autoNext); }; const watchSkipFinish = () => { console.log(ask.skipFinish); Cache.set("skipFinish", ask.skipFinish); }; const watchAutoAnswer = () => { console.log(ask.autoAnswer); Cache.set("autoAnswer", ask.autoAnswer); }; const watchFreeFirst = () => { console.log(ask.freeFirst); Cache.set("freeFirst", ask.freeFirst); }; const watchRandomAnswer = () => { console.log(ask.randomAnswer); Cache.set("randomAnswer", ask.randomAnswer); }; return (_ctx, _cache) => { const _component_el_alert = vue.resolveComponent("el-alert"); const _component_el_button = vue.resolveComponent("el-button"); const _component_el_col = vue.resolveComponent("el-col"); const _component_el_checkbox = vue.resolveComponent("el-checkbox"); const _component_el_input = vue.resolveComponent("el-input"); const _component_el_form_item = vue.resolveComponent("el-form-item"); const _component_el_form = vue.resolveComponent("el-form"); const _component_el_tag = vue.resolveComponent("el-tag"); const _component_el_divider = vue.resolveComponent("el-divider"); const _component_el_row = vue.resolveComponent("el-row"); const _component_el_empty = vue.resolveComponent("el-empty"); const _directive_loading = vue.resolveDirective("loading"); return vue.openBlock(), vue.createElementBlock(vue.Fragment, null, [ vue.createVNode(_component_el_alert, { style: { "margin-bottom": "10px" }, title: vue.unref(ask).tips, type: "info", "show-icon": "" }, null, 8, ["title"]), vue.unref(ask).current ? (vue.openBlock(), vue.createBlock(_component_el_row, { key: 0 }, { default: vue.withCtx(() => [ vue.createVNode(_component_el_col, { span: 12 }, { default: vue.withCtx(() => [ vue.createVNode(_component_el_button, { onClick: _cache[0] || (_cache[0] = ($event) => vue.unref(ask).start ? vue.unref(ask).pause() : vue.unref(ask).toggleStart()), size: "small", class: "aah_btn", type: "primary", plain: "" }, { default: vue.withCtx(() => [ vue.createTextVNode(vue.toDisplayString(vue.unref(ask).start ? "暂停答题" : "开始答题"), 1) ]), _: 1 }) ]), _: 1 }), vue.createVNode(_component_el_col, { span: 12 }, { default: vue.withCtx(() => [ vue.createVNode(_component_el_button, { onClick: _cache[1] || (_cache[1] = ($event) => vue.unref(ask).restart()), size: "small", class: "aah_btn", type: "primary", plain: "" }, { default: vue.withCtx(() => [ vue.createTextVNode("重新答题") ]), _: 1 }) ]), _: 1 }), vue.createVNode(_component_el_col, { span: 24 }, { default: vue.withCtx(() => [ _hoisted_1$3 ]), _: 1 }), (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(vue.unref(ask).questionList, (val, inx) => { return vue.openBlock(), vue.createBlock(_component_el_col, { span: 3 }, { default: vue.withCtx(() => [ (vue.openBlock(), vue.createBlock(_component_el_button, { class: vue.normalizeClass(inx == vue.unref(ask).questionInx ? "aah_active" : ""), style: { "width": "30px", "margin-bottom": "4px" }, key: inx, onClick: ($event) => vue.unref(ask).toQuestion(inx), size: "small", type: val.status == 1 ? "primary" : val.status == 2 ? "danger" : "", plain: "" }, { default: vue.withCtx(() => [ vue.createTextVNode(vue.toDisplayString(inx + 1), 1) ]), _: 2 }, 1032, ["class", "onClick", "type"])) ]), _: 2 }, 1024); }), 256)), vue.createVNode(_component_el_col, { span: 24 }, { default: vue.withCtx(() => [ vue.createVNode(_component_el_form, { "label-width": "auto" }, { default: vue.withCtx(() => [ vue.createVNode(_component_el_checkbox, { onChange: watchSkipFinish, modelValue: vue.unref(ask).skipFinish, "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => vue.unref(ask).skipFinish = $event), label: "跳过已作答" }, null, 8, ["modelValue"]), vue.createVNode(_component_el_checkbox, { onChange: watchAutoAnswer, modelValue: vue.unref(ask).autoAnswer, "onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => vue.unref(ask).autoAnswer = $event), label: "自动答题" }, null, 8, ["modelValue"]), vue.createVNode(_component_el_checkbox, { onChange: watchAutoNext, modelValue: vue.unref(ask).autoNext, "onUpdate:modelValue": _cache[4] || (_cache[4] = ($event) => vue.unref(ask).autoNext = $event), label: "自动跳转" }, null, 8, ["modelValue"]), vue.createVNode(_component_el_checkbox, { onChange: watchFreeFirst, modelValue: vue.unref(ask).freeFirst, "onUpdate:modelValue": _cache[5] || (_cache[5] = ($event) => vue.unref(ask).freeFirst = $event), label: "免费题库优先" }, null, 8, ["modelValue"]), vue.createVNode(_component_el_checkbox, { onChange: watchRandomAnswer, modelValue: vue.unref(ask).randomAnswer, "onUpdate:modelValue": _cache[6] || (_cache[6] = ($event) => vue.unref(ask).randomAnswer = $event), label: "无答案随机答题" }, null, 8, ["modelValue"]), vue.createVNode(_component_el_form_item, { label: "秘钥" }, { default: vue.withCtx(() => [ vue.createVNode(_component_el_input, { class: "aah_password", placeholder: "请输入你购买的秘钥", modelValue: vue.unref(app).app.key, "onUpdate:modelValue": _cache[7] || (_cache[7] = ($event) => vue.unref(app).app.key = $event), "show-password": "" }, null, 8, ["modelValue"]) ]), _: 1 }) ]), _: 1 }) ]), _: 1 }), vue.unref(ask).formMap ? (vue.openBlock(), vue.createBlock(_component_el_col, { key: 0, span: 24 }, { default: vue.withCtx(() => [ (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(vue.unref(ask).formMap, (val, key2) => { return vue.openBlock(), vue.createBlock(_component_el_tag, { key: key2, style: { "margin-right": "10px" } }, { default: vue.withCtx(() => [ vue.createTextVNode(vue.toDisplayString(key2) + ":" + vue.toDisplayString(val) + " 次", 1) ]), _: 2 }, 1024); }), 128)) ]), _: 1 })) : vue.createCommentVNode("", true), vue.createVNode(_component_el_divider, null, { default: vue.withCtx(() => [ vue.createTextVNode("当前题目"), vue.createVNode(_component_el_button, { onClick: _cache[8] || (_cache[8] = ($event) => vue.unref(ask).reAnswer(vue.unref(ask).questionInx)), style: { "color": "red", "font-size": "10px" }, link: "" }, { default: vue.withCtx(() => [ vue.createTextVNode("重答") ]), _: 1 }), vue.createVNode(_component_el_divider, { direction: "vertical" }), vue.createVNode(_component_el_button, { onClick: _cache[9] || (_cache[9] = ($event) => vue.unref(ask).aiAnswer(vue.unref(ask).questionInx)), style: { "color": "red", "font-size": "10px" }, link: "" }, { default: vue.withCtx(() => [ vue.createTextVNode("AI答题") ]), _: 1 }) ]), _: 1 }), vue.createVNode(_component_el_col, { span: 24 }, { default: vue.withCtx(() => [ vue.createElementVNode("div", { class: "aah_title", innerHTML: "[" + vue.unref(typeChange2)(vue.unref(ask).current.type ?? "") + "]" + vue.unref(ask).current.question }, null, 8, _hoisted_2$2), (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(vue.unref(ask).current.options, (val, inx) => { return vue.openBlock(), vue.createElementBlock("p", { style: vue.normalizeStyle(vue.unref(ask).current.form && vue.unref(ask).current.form.match && vue.unref(ask).current.form.match.includes(inx) ? "color:green;" : ""), class: "aah_options", innerHTML: getOptionIndex(inx) + ". " + val }, null, 12, _hoisted_3$2); }), 256)), vue.unref(ask).current.type == "24" ? (vue.openBlock(), vue.createElementBlock("p", _hoisted_4$1, [ vue.createVNode(vue.unref(ShadowRoot), null, { default: vue.withCtx(() => [ vue.createElementVNode("table", _hoisted_5$1, [ (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(vue.unref(ask).current.match, (val, inx) => { return vue.openBlock(), vue.createElementBlock("tr", null, [ vue.createElementVNode("td", { innerHTML: val }, null, 8, _hoisted_6$1), vue.createElementVNode("td", null, [ vue.createElementVNode("select", null, [ (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(vue.unref(ask).current.selects[inx], (item) => { return vue.openBlock(), vue.createElementBlock("option", { value: item.value }, vue.toDisplayString(item.text), 9, _hoisted_7); }), 256)) ]) ]) ]); }), 256)) ]) ]), _: 1 }) ])) : vue.createCommentVNode("", true), vue.unref(ask).current.form ? (vue.openBlock(), vue.createElementBlock("p", _hoisted_8, " 采用【" + vue.toDisplayString(vue.unref(ask).current.form.form) + "】的答案 ", 1)) : vue.createCommentVNode("", true), vue.unref(ask).current.type == "8" ? (vue.openBlock(), vue.createElementBlock("p", _hoisted_9, " 当前题型暂不支持,请反馈给作者吧 ")) : vue.createCommentVNode("", true) ]), _: 1 }), vue.withDirectives((vue.openBlock(), vue.createBlock(_component_el_col, { span: 24, "element-loading-text": "正在搜索中" }, { default: vue.withCtx(() => [ (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(vue.unref(ask).current.answer, (item) => { return vue.openBlock(), vue.createElementBlock("div", null, [ vue.createVNode(_component_el_divider, null, { default: vue.withCtx(() => [ vue.createTextVNode(vue.toDisplayString(`${item.form}(${item.duration}ms)`), 1) ]), _: 2 }, 1024), typeof item.answer === "object" ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_10, [ (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(item.answer, (ans) => { return vue.openBlock(), vue.createElementBlock("p", null, [ vue.createVNode(_component_el_input, { value: ans, readonly: "", style: { "width": "100%" } }, null, 8, ["value"]) ]); }), 256)) ])) : (vue.openBlock(), vue.createElementBlock("div", _hoisted_11, [ vue.createElementVNode("div", { innerHTML: item.answer ? item.answer : item.msg ?? "暂无答案" }, null, 8, _hoisted_12) ])) ]); }), 256)), vue.unref(ask).current.aiMsg ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_13, [ vue.createVNode(_component_el_divider, null, { default: vue.withCtx(() => [ vue.createTextVNode("AI回答(仅供参考)") ]), _: 1 }), vue.createElementVNode("div", { innerHTML: vue.unref(ask).currentAiMd }, null, 8, _hoisted_14) ])) : vue.createCommentVNode("", true) ]), _: 1 })), [ [_directive_loading, vue.unref(ask).loading] ]) ]), _: 1 })) : (vue.openBlock(), vue.createBlock(_component_el_empty, { key: 1, description: "暂无题目数据" })) ], 64); }; } }); const _sfc_main$3 = /* @__PURE__ */ vue.defineComponent({ __name: "Api", setup(__props) { const apiStore = useApiStore(); const deleteRow = (index) => { apiStore.deleteApi(index); }; const paramVisible = vue.ref(false); const addParam = () => { if (apiStore.currentParam.name == "") { ElementPlus.ElNotification({ title: "参数效验不通过", message: "参数名不能为空", type: "error" }); return; } if (apiStore.currentParam.value == "") { ElementPlus.ElNotification({ title: "参数效验不通过", message: "参数值不能为空", type: "error" }); return; } const index = apiStore.currentApi.params.findIndex((item) => item.name == apiStore.currentParam.name); if (index != -1) { apiStore.currentApi.params[index] = apiStore.currentParam; ElementPlus.ElNotification({ title: "更新成功", message: "参数已更新", type: "success" }); paramVisible.value = false; return; } apiStore.addParam(); paramVisible.value = false; }; const addApi = () => { if (apiStore.currentApi.name == "") { ElementPlus.ElNotification({ title: "参数效验不通过", message: "接口名不能为空", type: "error" }); return; } if (apiStore.currentApi.url == "") { ElementPlus.ElNotification({ title: "参数效验不通过", message: "接口地址不能为空", type: "error" }); return; } if (apiStore.currentApi.params.length == 0) { ElementPlus.ElNotification({ title: "参数效验不通过", message: "参数不能为空", type: "error" }); return; } const index = apiStore.apiList.findIndex((item) => item.name == apiStore.currentApi.name); if (index != -1) { apiStore.updateApi(index, apiStore.currentApi); ElementPlus.ElNotification({ title: "更新成功", message: "接口已更新", type: "success" }); } apiStore.addApi(); apiStore.reset(); }; const editApi = (index) => { apiStore.editApi(index); }; const editParam = (index) => { apiStore.editParam(index); paramVisible.value = true; }; const testApi = (index) => { apiStore.testApi(index).then((res) => { console.log(res); }).catch((err) => { console.log(err); ElementPlus.ElNotification({ title: "请求失败", message: err, type: "error" }); }); }; return (_ctx, _cache) => { const _component_el_alert = vue.resolveComponent("el-alert"); const _component_el_input = vue.resolveComponent("el-input"); const _component_el_form_item = vue.resolveComponent("el-form-item"); const _component_el_option = vue.resolveComponent("el-option"); const _component_el_select = vue.resolveComponent("el-select"); const _component_el_button = vue.resolveComponent("el-button"); const _component_el_form = vue.resolveComponent("el-form"); const _component_el_dialog = vue.resolveComponent("el-dialog"); const _component_el_table_column = vue.resolveComponent("el-table-column"); const _component_el_table = vue.resolveComponent("el-table"); const _component_el_col = vue.resolveComponent("el-col"); const _component_el_row = vue.resolveComponent("el-row"); return vue.openBlock(), vue.createElementBlock(vue.Fragment, null, [ vue.createVNode(_component_el_alert, { title: "当前功能开发中,若您有急需添加的API可以先反馈给作者", type: "error" }), vue.createVNode(_component_el_dialog, { modelValue: paramVisible.value, "onUpdate:modelValue": _cache[4] || (_cache[4] = ($event) => paramVisible.value = $event), title: "添加参数", style: { "width": "400px" } }, { default: vue.withCtx(() => [ vue.createVNode(_component_el_form, { model: vue.unref(apiStore).currentParam, "label-width": "auto" }, { default: vue.withCtx(() => [ vue.createVNode(_component_el_form_item, { label: "参数名" }, { default: vue.withCtx(() => [ vue.createVNode(_component_el_input, { modelValue: vue.unref(apiStore).currentParam.name, "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => vue.unref(apiStore).currentParam.name = $event), autocomplete: "off" }, null, 8, ["modelValue"]) ]), _: 1 }), vue.createVNode(_component_el_form_item, { label: "参数类型" }, { default: vue.withCtx(() => [ vue.createVNode(_component_el_select, { modelValue: vue.unref(apiStore).currentParam.type, "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => vue.unref(apiStore).currentParam.type = $event), placeholder: "请选择" }, { default: vue.withCtx(() => [ vue.createVNode(_component_el_option, { label: "内置参数", value: "sys" }), vue.createVNode(_component_el_option, { label: "自定义参数", value: "diy" }) ]), _: 1 }, 8, ["modelValue"]) ]), _: 1 }), vue.createVNode(_component_el_form_item, { label: "参数值" }, { default: vue.withCtx(() => [ vue.unref(apiStore).currentParam.type == "diy" ? (vue.openBlock(), vue.createBlock(_component_el_input, { key: 0, modelValue: vue.unref(apiStore).currentParam.value, "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => vue.unref(apiStore).currentParam.value = $event), autocomplete: "off" }, null, 8, ["modelValue"])) : (vue.openBlock(), vue.createBlock(_component_el_select, { key: 1, modelValue: vue.unref(apiStore).currentParam.value, "onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => vue.unref(apiStore).currentParam.value = $event), placeholder: "请选择" }, { default: vue.withCtx(() => [ vue.createVNode(_component_el_option, { label: "题型(字符串)", value: "$type" }), vue.createVNode(_component_el_option, { label: "题型(数字)", value: "$typeid" }), vue.createVNode(_component_el_option, { label: "题干(题目)", value: "$question" }), vue.createVNode(_component_el_option, { label: "选项", value: "$options" }), vue.createVNode(_component_el_option, { label: "时间戳", value: "$timestamp" }), vue.createVNode(_component_el_option, { label: "随机数", value: "$random" }) ]), _: 1 }, 8, ["modelValue"])) ]), _: 1 }), vue.createVNode(_component_el_form_item, null, { default: vue.withCtx(() => [ vue.createVNode(_component_el_button, { onClick: addParam, plain: "", style: { "width": "100%" } }, { default: vue.withCtx(() => [ vue.createTextVNode("添加") ]), _: 1 }) ]), _: 1 }) ]), _: 1 }, 8, ["model"]) ]), _: 1 }, 8, ["modelValue"]), vue.createVNode(_component_el_table, { data: vue.unref(apiStore).apiList, style: { "width": "100%", "margin-bottom": "10px" }, "empty-text": "暂无数据" }, { default: vue.withCtx(() => [ vue.createVNode(_component_el_table_column, { prop: "name", label: "接口名", width: "120" }), vue.createVNode(_component_el_table_column, { prop: "url", label: "接口地址", width: "120" }), vue.createVNode(_component_el_table_column, { prop: "method", label: "请求方式", width: "120" }), vue.createVNode(_component_el_table_column, { fixed: "right", label: "操作", width: "120" }, { default: vue.withCtx((scope) => [ vue.createVNode(_component_el_button, { link: "", type: "primary", size: "small", onClick: vue.withModifiers(($event) => deleteRow(scope.$index), ["prevent"]) }, { default: vue.withCtx(() => [ vue.createTextVNode(" 删除 ") ]), _: 2 }, 1032, ["onClick"]), vue.createVNode(_component_el_button, { link: "", type: "primary", size: "small", onClick: vue.withModifiers(($event) => editApi(scope.$index), ["prevent"]) }, { default: vue.withCtx(() => [ vue.createTextVNode(" 编辑 ") ]), _: 2 }, 1032, ["onClick"]), vue.createVNode(_component_el_button, { link: "", type: "primary", size: "small", onClick: vue.withModifiers(($event) => testApi(scope.$index), ["prevent"]) }, { default: vue.withCtx(() => [ vue.createTextVNode(" 测试 ") ]), _: 2 }, 1032, ["onClick"]) ]), _: 1 }) ]), _: 1 }, 8, ["data"]), vue.createVNode(_component_el_row, null, { default: vue.withCtx(() => [ vue.createVNode(_component_el_col, { span: 24 }, { default: vue.withCtx(() => [ vue.createVNode(_component_el_form, { model: vue.unref(apiStore).currentApi, "label-width": "80px" }, { default: vue.withCtx(() => [ vue.createVNode(_component_el_form_item, { label: "接口名" }, { default: vue.withCtx(() => [ vue.createVNode(_component_el_input, { modelValue: vue.unref(apiStore).currentApi.name, "onUpdate:modelValue": _cache[5] || (_cache[5] = ($event) => vue.unref(apiStore).currentApi.name = $event), placeholder: "请输入接口名" }, null, 8, ["modelValue"]) ]), _: 1 }), vue.createVNode(_component_el_form_item, { label: "接口地址" }, { default: vue.withCtx(() => [ vue.createVNode(_component_el_input, { modelValue: vue.unref(apiStore).currentApi.url, "onUpdate:modelValue": _cache[6] || (_cache[6] = ($event) => vue.unref(apiStore).currentApi.url = $event), placeholder: "请输入接口地址" }, null, 8, ["modelValue"]) ]), _: 1 }), vue.createVNode(_component_el_form_item, { label: "请求方式" }, { default: vue.withCtx(() => [ vue.createVNode(_component_el_select, { modelValue: vue.unref(apiStore).currentApi.method, "onUpdate:modelValue": _cache[7] || (_cache[7] = ($event) => vue.unref(apiStore).currentApi.method = $event), placeholder: "请选择" }, { default: vue.withCtx(() => [ vue.createVNode(_component_el_option, { label: "GET", value: "GET" }), vue.createVNode(_component_el_option, { label: "POST", value: "POST" }) ]), _: 1 }, 8, ["modelValue"]) ]), _: 1 }), vue.createVNode(_component_el_form_item, { label: "请求参数" }, { default: vue.withCtx(() => [ vue.createVNode(_component_el_table, { data: vue.unref(apiStore).currentApi.params, style: { "width": "100%" }, "empty-text": "暂无参数" }, { default: vue.withCtx(() => [ vue.createVNode(_component_el_table_column, { prop: "name", label: "参数名", width: "120" }), vue.createVNode(_component_el_table_column, { prop: "value", label: "参数值", width: "120" }), vue.createVNode(_component_el_table_column, { fixed: "right", label: "操作", width: "120" }, { default: vue.withCtx((scope) => [ vue.createVNode(_component_el_button, { link: "", type: "primary", size: "small", onClick: vue.withModifiers(($event) => vue.unref(apiStore).deleteParam(scope.$index), ["prevent"]) }, { default: vue.withCtx(() => [ vue.createTextVNode(" 删除 ") ]), _: 2 }, 1032, ["onClick"]), vue.createVNode(_component_el_button, { link: "", type: "primary", size: "small", onClick: vue.withModifiers(($event) => editParam(scope.$index), ["prevent"]) }, { default: vue.withCtx(() => [ vue.createTextVNode(" 编辑 ") ]), _: 2 }, 1032, ["onClick"]) ]), _: 1 }) ]), _: 1 }, 8, ["data"]), vue.createVNode(_component_el_button, { type: "primary", onClick: _cache[8] || (_cache[8] = ($event) => paramVisible.value = true), text: "" }, { default: vue.withCtx(() => [ vue.createTextVNode("添加参数") ]), _: 1 }) ]), _: 1 }), vue.createVNode(_component_el_form_item, null, { default: vue.withCtx(() => [ vue.createVNode(_component_el_button, { type: "primary", onClick: addApi, plain: "" }, { default: vue.withCtx(() => [ vue.createTextVNode("添加") ]), _: 1 }) ]), _: 1 }) ]), _: 1 }, 8, ["model"]) ]), _: 1 }) ]), _: 1 }) ], 64); }; } }); const _sfc_main$2 = {}; const _hoisted_1$2 = { src: "https://chatglm.cn/miniapp/home", width: "100%", height: "600px", frameborder: "0", style: { "border": "none", "overflow": "hidden" } }; function _sfc_render(_ctx, _cache) { return vue.openBlock(), vue.createElementBlock("iframe", _hoisted_1$2); } const Ai = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["render", _sfc_render]]); const _hoisted_1$1 = /* @__PURE__ */ vue.createElementVNode("br", null, null, -1); const _hoisted_2$1 = /* @__PURE__ */ vue.createElementVNode("br", null, null, -1); const _hoisted_3$1 = /* @__PURE__ */ vue.createElementVNode("p", { style: { "color": "red" } }, "且并非所有网站都支持,需要作者适配,若您的平台不支持可以反馈给作者", -1); const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({ __name: "Question", setup(__props) { const ask = useAskStore(); let questionList = Cache.get("questionList", []); const clearCache = () => { Cache.set("questionList", []); questionList = []; msg("清除成功", "success"); }; const exportCsv = () => { const header = ["题型", "题目", "选项", "答案"]; const data = ask.saveQuestionData.map((item) => [typeChange2(item.type), item.question, item.options.join("###"), item.answer.join("###")]); const csv = [header, ...data].map((item) => item.join(",")).join("\n"); const blob = new Blob([csv], { type: "text/csv" }); const url = URL.createObjectURL(blob); const a = document.createElement("a"); a.href = url; a.download = "question.csv"; const title = document.title; const random = Math.random().toString(36).slice(-8); a.download = `${title}的试题导出${random}.csv`; a.click(); }; const exportCsv1 = () => { const header = ["题型", "题目", "选项", "答案"]; const data = questionList.map((item) => [typeChange2(item.type), item.question, item.options.join("###"), item.answer.join("###")]); const csv = [header, ...data].map((item) => item.join(",")).join("\n"); const blob = new Blob([csv], { type: "text/csv" }); const url = URL.createObjectURL(blob); const a = document.createElement("a"); a.href = url; a.download = "question.csv"; a.click(); }; const changeT = (item) => { return typeChange2(item.type); }; return (_ctx, _cache) => { const _component_el_alert = vue.resolveComponent("el-alert"); const _component_el_statistic = vue.resolveComponent("el-statistic"); const _component_el_col = vue.resolveComponent("el-col"); const _component_el_row = vue.resolveComponent("el-row"); const _component_el_button = vue.resolveComponent("el-button"); const _component_el_table_column = vue.resolveComponent("el-table-column"); const _component_el_table = vue.resolveComponent("el-table"); const _component_el_watermark = vue.resolveComponent("el-watermark"); return vue.openBlock(), vue.createElementBlock(vue.Fragment, null, [ vue.createVNode(_component_el_alert, { type: "info", closable: false }, { default: vue.withCtx(() => [ vue.createTextVNode(" 本脚本支持将存在答案的题目收录到本地,以供后续答题检索,可减少接口请求次数,以及提高答案正确率"), _hoisted_1$1, vue.createTextVNode(" 在支持重复答题且答完题显示答案的情况下可以无需使用接口搜索答案"), _hoisted_2$1, _hoisted_3$1 ]), _: 1 }), vue.createVNode(_component_el_watermark, { content: ["爱问答助手", "AiAskHelper"] }, { default: vue.withCtx(() => [ vue.createVNode(_component_el_row, null, { default: vue.withCtx(() => [ vue.createVNode(_component_el_col, { span: 6 }, { default: vue.withCtx(() => [ vue.createVNode(_component_el_statistic, { title: "缓存题目数量", value: vue.unref(questionList).length }, null, 8, ["value"]) ]), _: 1 }) ]), _: 1 }), vue.createVNode(_component_el_button, { type: "danger", onClick: clearCache }, { default: vue.withCtx(() => [ vue.createTextVNode("清除缓存") ]), _: 1 }), vue.createVNode(_component_el_button, { type: "primary", onClick: exportCsv }, { default: vue.withCtx(() => [ vue.createTextVNode("导出当前") ]), _: 1 }), vue.createVNode(_component_el_button, { type: "primary", onClick: exportCsv1 }, { default: vue.withCtx(() => [ vue.createTextVNode("导出所有") ]), _: 1 }), vue.createVNode(_component_el_table, { data: vue.unref(ask).saveQuestionData, style: { "width": "100%" }, "empty-text": "当前页暂无数据" }, { default: vue.withCtx(() => [ vue.createVNode(_component_el_table_column, { prop: "type", label: "题型", formatter: changeT }), vue.createVNode(_component_el_table_column, { prop: "question", label: "题目" }), vue.createVNode(_component_el_table_column, { prop: "options", label: "选项" }), vue.createVNode(_component_el_table_column, { prop: "answer", label: "答案" }) ]), _: 1 }, 8, ["data"]) ]), _: 1 }) ], 64); }; } }); const _hoisted_1 = { class: "aah_wrapper" }; const _hoisted_2 = ["src"]; const _hoisted_3 = ["id"]; const _hoisted_4 = { key: 0, class: "aah_breadcrumb" }; const _hoisted_5 = /* @__PURE__ */ vue.createElementVNode("strong", null, "home", -1); const _hoisted_6 = ["src"]; const _sfc_main = /* @__PURE__ */ vue.defineComponent({ __name: "App", setup(__props) { const appStore = useAppStore(); const askStore = useAskStore(); _unsafeWindow[key] = { "app": appStore, "ask": askStore }; document.onkeydown = function(e) { if (e.ctrlKey && e.key == "p") { appStore.app.showFloat = !appStore.app.showFloat; } }; return (_ctx, _cache) => { const _component_el_button = vue.resolveComponent("el-button"); const _component_el_breadcrumb_item = vue.resolveComponent("el-breadcrumb-item"); const _component_el_breadcrumb = vue.resolveComponent("el-breadcrumb"); const _component_el_scrollbar = vue.resolveComponent("el-scrollbar"); const _component_el_dialog = vue.resolveComponent("el-dialog"); return vue.openBlock(), vue.createElementBlock("div", _hoisted_1, [ vue.createVNode(_component_el_dialog, { modelValue: vue.unref(appStore).app.showFloat, "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => vue.unref(appStore).app.showFloat = $event), title: "爱问答助手", draggable: "", overflow: "", "show-close": true, modal: false, "close-on-click-modal": false, style: vue.normalizeStyle(vue.unref(appStore).page === "ai" ? "width: 70vh;" : "width: 400px;") }, { header: vue.withCtx(({ close, titleId, titleClass }) => [ vue.createElementVNode("img", { src: vue.unref(scriptInfo$1).script.icon, alt: "icon", style: { "width": "20px", "height": "20px", "margin-right": "10px", "vertical-align": "middle" } }, null, 8, _hoisted_2), vue.createElementVNode("span", { id: titleId, class: vue.normalizeClass(titleClass) }, vue.toDisplayString(`${vue.unref(scriptInfo$1).script.name} - ${vue.unref(scriptInfo$1).script.version}`), 11, _hoisted_3), vue.createTextVNode("   "), vue.createVNode(_component_el_button, { link: "" }, { default: vue.withCtx(() => [ vue.createTextVNode("log") ]), _: 1 }) ]), default: vue.withCtx(() => [ vue.createVNode(_component_el_scrollbar, { "max-height": "55vh" }, { default: vue.withCtx(() => [ vue.unref(appStore).page != "home" ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_4, [ vue.createVNode(_component_el_breadcrumb, { separator: "/" }, { default: vue.withCtx(() => [ vue.createVNode(_component_el_breadcrumb_item, { onClick: _cache[0] || (_cache[0] = ($event) => vue.unref(appStore).setPage("home")) }, { default: vue.withCtx(() => [ _hoisted_5 ]), _: 1 }), vue.createVNode(_component_el_breadcrumb_item, null, { default: vue.withCtx(() => [ vue.createTextVNode(vue.toDisplayString(vue.unref(appStore).page), 1) ]), _: 1 }) ]), _: 1 }) ])) : vue.createCommentVNode("", true), vue.unref(appStore).page == "home" ? (vue.openBlock(), vue.createBlock(Home, { key: 1 })) : vue.unref(appStore).page == "note" ? (vue.openBlock(), vue.createBlock(Note, { key: 2 })) : vue.unref(appStore).page == "Base" ? (vue.openBlock(), vue.createBlock(_sfc_main$5, { key: 3 })) : vue.unref(appStore).page == "ask" ? (vue.openBlock(), vue.createBlock(_sfc_main$4, { key: 4 })) : vue.unref(appStore).page == "api" ? (vue.openBlock(), vue.createBlock(_sfc_main$3, { key: 5 })) : vue.unref(appStore).page == "ai" ? (vue.openBlock(), vue.createBlock(Ai, { key: 6 })) : vue.unref(appStore).page == "question" ? (vue.openBlock(), vue.createBlock(_sfc_main$1, { key: 7 })) : vue.createCommentVNode("", true) ]), _: 1 }) ]), _: 1 }, 8, ["modelValue", "style"]), vue.withDirectives(vue.createElementVNode("div", { class: "minimized-dialog", onClick: _cache[4] || (_cache[4] = ($event) => vue.unref(appStore).app.showFloat = true) }, [ vue.createElementVNode("div", { onClick: _cache[3] || (_cache[3] = ($event) => vue.unref(appStore).app.showFloat = true) }, [ vue.createElementVNode("img", { width: "104vh", src: vue.unref(mini), onClick: _cache[2] || (_cache[2] = ($event) => vue.unref(appStore).app.showFloat = true) }, null, 8, _hoisted_6) ]) ], 512), [ [vue.vShow, !vue.unref(appStore).app.showFloat] ]) ]); }; } }); const cssLoader = (e) => { const t = GM_getResourceText(e); return GM_addStyle(t), t; }; cssLoader("ElementPlus"); const LoadVue = () => { const pinia = createPinia(); const app = vue.createApp(_sfc_main); app.use(ElementPlus); app.use(pinia); app.use(shadow); app.mount( (() => { const app2 = document.createElement("div"); app2.id = "AiAskApp"; document.body.append(app2); return app2; })() ); }; comHook(); parseRuleHook(rule); _unsafeWindow.onload = async () => { allowCopy(); if (_unsafeWindow !== _unsafeWindow.top && !/\/work\/doHomeWorkNew/i.test(location.pathname)) { return; } LoadVue(); parseRule(rule); _unsafeWindow.console.log = () => { }; }; } })(Vue, ElementPlus, $, markdownit, hljs);