Files
ST-Amily2-Chat-Optimisation/ui/historiography-bindings.js

2 lines
12 KiB
JavaScript

(function(_0x2150fd,_0x2a55f1){const _0x572882=_0x4bc0,_0x4b8612=_0x2150fd();while(!![]){try{const _0x16022a=-parseInt(_0x572882(0xda))/0x1+-parseInt(_0x572882(0xfd))/0x2*(-parseInt(_0x572882(0xd9))/0x3)+-parseInt(_0x572882(0xce))/0x4*(-parseInt(_0x572882(0xcd))/0x5)+-parseInt(_0x572882(0xe1))/0x6+-parseInt(_0x572882(0xf1))/0x7+-parseInt(_0x572882(0xd1))/0x8+parseInt(_0x572882(0xe9))/0x9;if(_0x16022a===_0x2a55f1)break;else _0x4b8612['push'](_0x4b8612['shift']());}catch(_0x5b1151){_0x4b8612['push'](_0x4b8612['shift']());}}}(_0x6e5c,0xb5ec5));function _0x4bc0(_0x3e304a,_0x2ea3c6){const _0x6e5cd2=_0x6e5c();return _0x4bc0=function(_0x4bc03c,_0x8e0e35){_0x4bc03c=_0x4bc03c-0xae;let _0x452af9=_0x6e5cd2[_0x4bc03c];return _0x452af9;},_0x4bc0(_0x3e304a,_0x2ea3c6);}import{extension_settings}from'/scripts/extensions.js';import{extensionName,defaultSettings,saveSettings}from'../utils/settings.js';function _0x6e5c(){const _0x4a6564=['amily2_mhb_small_trigger_count','28470735jlshdP','paused','amily2_mhb_large_refine_execute','historiographySmallTriggerThreshold','</h4>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<div\x20class=\x22popup-content\x22\x20style=\x22height:\x2070vh;\x22><div\x20class=\x22height100p\x20wide100p\x20flex-container\x22><textarea\x20class=\x22height100p\x20wide100p\x20maximized_textarea\x20text_pole\x22></textarea></div></div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<div\x20class=\x22popup-controls\x22><div\x20class=\x22popup-button-ok\x20menu_button\x20menu_button_primary\x20interactable\x22>保存并关闭</div><div\x20class=\x22popup-button-cancel\x20menu_button\x20interactable\x22\x20style=\x22margin-left:\x2010px;\x22>取消</div></div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20</div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20</dialog>','menu_button\x20small_button\x20interactable\x20success','detail','amily2_mhb_small_auto_enabled','1555414JWXZqU','请先选择一个国史馆及其中的史册条目!','amily2_mhb_large_refresh_worldbooks','target','amily2_mhb_','请输入有效的起始和结束楼层!','forEach','<option\x20value=\x22\x22>正在遍览帝国疆域...</option>','historiographyIngestToRag','remove','checked','info','206hHWgXc','amily2_mhb_small_expedition_execute','warning','createElement','idle','comment','historiographyLargeRefinePrompt','running','<i\x20class=\x22fas\x20fa-flag-checkered\x22></i>\x20开始远征','圣谕不全','historiographySmallAutoEnable','amily2-expedition-state-change','addEventListener','<option\x20value=\x22\x22>请先选择国史馆</option>','className','menu_button\x20small_button\x20interactable','value','amily2_mhb_small_manual_execute','[Amily2号-工部]\x20【敕史局】的专属工匠已就位...','<option\x20value=\x22\x22>正在检阅史册...</option>','historiographySmallJailbreakPrompt','body','option','historiographyWriteToLorebook','historiography_ingest_to_rag','small','_restore_button','close','宏史卷','state','_editor','微言录','amily2_mhb_large_refresh_lores','showModal','dataset','_expand_editor','.popup-button-ok','已镌刻!','jailbreak','_prompt_selector','340phUpAE','7916BcxuOn','success','innerHTML','8430168nscUjq','<i\x20class=\x22fas\x20fa-stop-circle\x22></i>\x20停止远征','error','dispatchEvent','historiographyLargeJailbreakPrompt','key','amily2_mhb_small_start_floor','远征阈值必须是大于0的数字。已重置。','405OjbeTs','1286712uoFINW','options','appendTo','<option\x20value=\x22\x22>此国史馆为空</option>','find','change','textarea','24300jhQFdJ','<i\x20class=\x22fas\x20fa-play-circle\x22></i>\x20继续远征','<option\x20value=\x22\x22>未发现任何国史馆</option>','textContent','click','getElementById','large'];_0x6e5c=function(){return _0x4a6564;};return _0x6e5c();}import{getAvailableWorldbooks,getLoresForWorldbook,executeManualSummary,executeRefinement,executeExpedition,stopExpedition}from'../core/historiographer.js';function setupPromptEditor(_0x3ba447){const _0x289e89=_0x4bc0,_0x2de562=document['getElementById'](_0x289e89(0xf5)+_0x3ba447+_0x289e89(0xcc)),_0x29886b=document[_0x289e89(0xe6)](_0x289e89(0xf5)+_0x3ba447+_0x289e89(0xc3)),_0x90ac00=document[_0x289e89(0xe6)](_0x289e89(0xf5)+_0x3ba447+'_save_button'),_0x37921f=document[_0x289e89(0xe6)](_0x289e89(0xf5)+_0x3ba447+_0x289e89(0xbf)),_0x587ee0=_0x3ba447===_0x289e89(0xbe)?_0x289e89(0xb9):_0x289e89(0xd5),_0x3e0495=_0x3ba447===_0x289e89(0xbe)?'historiographySmallSummaryPrompt':_0x289e89(0x103),_0x47a7d8=()=>{const _0x487d0d=_0x289e89,_0x1445e9=_0x2de562[_0x487d0d(0xb5)];_0x1445e9===_0x487d0d(0xcb)?_0x29886b[_0x487d0d(0xb5)]=extension_settings[extensionName][_0x587ee0]:_0x29886b[_0x487d0d(0xb5)]=extension_settings[extensionName][_0x3e0495];};_0x2de562['addEventListener'](_0x289e89(0xdf),_0x47a7d8),_0x90ac00[_0x289e89(0xb1)]('click',()=>{const _0x29744=_0x289e89,_0x688347=_0x2de562[_0x29744(0xb5)];_0x688347===_0x29744(0xcb)?extension_settings[extensionName][_0x587ee0]=_0x29886b[_0x29744(0xb5)]:extension_settings[extensionName][_0x3e0495]=_0x29886b[_0x29744(0xb5)],saveSettings()&&toastr[_0x29744(0xcf)]((_0x3ba447===_0x29744(0xbe)?_0x29744(0xc4):_0x29744(0xc1))+'的'+(_0x688347===_0x29744(0xcb)?'破限谕旨':'纲要')+'已保存!');}),_0x37921f['addEventListener'](_0x289e89(0xe5),()=>{const _0x1bb233=_0x289e89,_0x4b02c7=_0x2de562['value'];_0x4b02c7===_0x1bb233(0xcb)?_0x29886b[_0x1bb233(0xb5)]=defaultSettings[_0x587ee0]:_0x29886b[_0x1bb233(0xb5)]=defaultSettings[_0x3e0495],toastr[_0x1bb233(0xfc)]('已恢复为默认谕旨,请点击“保存当前”以确认。');}),_0x47a7d8();const _0x4189bf=document[_0x289e89(0xe6)](_0x289e89(0xf5)+_0x3ba447+_0x289e89(0xc8));_0x4189bf[_0x289e89(0xb1)](_0x289e89(0xe5),()=>{const _0x117c06=_0x289e89,_0x295555=_0x2de562['value'],_0x2882be=_0x2de562[_0x117c06(0xdb)][_0x2de562['selectedIndex']]['text'],_0x51dd7b=_0x29886b[_0x117c06(0xb5)],_0x53e3c6='\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<dialog\x20class=\x22popup\x20wide_dialogue_popup\x20large_dialogue_popup\x22>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<div\x20class=\x22popup-body\x22>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<h4\x20style=\x22margin-top:0;\x20color:\x20#eee;\x20border-bottom:\x201px\x20solid\x20rgba(255,255,255,0.2);\x20padding-bottom:\x2010px;\x22>正在编辑:\x20'+_0x2882be+_0x117c06(0xed),_0x11a25c=$(_0x53e3c6)[_0x117c06(0xdc)](_0x117c06(0xba)),_0x16d02c=_0x11a25c[_0x117c06(0xde)](_0x117c06(0xe0));_0x16d02c['val'](_0x51dd7b);const _0x5431d0=()=>{const _0xe61106=_0x117c06;_0x11a25c[0x0][_0xe61106(0xc0)](),_0x11a25c[_0xe61106(0xfa)]();};_0x11a25c[_0x117c06(0xde)](_0x117c06(0xc9))['on'](_0x117c06(0xe5),()=>{const _0x165ddc=_0x117c06,_0x570c71=_0x16d02c['val']();_0x29886b['value']=_0x570c71,_0x295555===_0x165ddc(0xcb)?extension_settings[extensionName][_0x587ee0]=_0x570c71:extension_settings[extensionName][_0x3e0495]=_0x570c71,saveSettings()&&toastr[_0x165ddc(0xcf)]((_0x3ba447==='small'?_0x165ddc(0xc4):_0x165ddc(0xc1))+'的'+_0x2882be+_0x165ddc(0xca)),_0x5431d0();}),_0x11a25c[_0x117c06(0xde)]('.popup-button-cancel')['on']('click',_0x5431d0),_0x11a25c[0x0][_0x117c06(0xc6)]();});}export function bindHistoriographyEvents(){const _0x16e187=_0x4bc0;console['log'](_0x16e187(0xb7)),setupPromptEditor(_0x16e187(0xbe)),setupPromptEditor(_0x16e187(0xe7));const _0x21d9ad=document[_0x16e187(0xe6)](_0x16e187(0xd7)),_0x203ba6=document[_0x16e187(0xe6)]('amily2_mhb_small_end_floor'),_0x305792=document[_0x16e187(0xe6)](_0x16e187(0xb6)),_0x34437d=document[_0x16e187(0xe6)](_0x16e187(0xf0)),_0x21a57b=document[_0x16e187(0xe6)](_0x16e187(0xe8)),_0x45378f=document['getElementById']('historiography_write_to_lorebook'),_0x48ab5c=document[_0x16e187(0xe6)](_0x16e187(0xbd));_0x305792[_0x16e187(0xb1)](_0x16e187(0xe5),()=>{const _0xdc8828=_0x16e187,_0x56efcb=parseInt(_0x21d9ad[_0xdc8828(0xb5)],0xa),_0x30a575=parseInt(_0x203ba6[_0xdc8828(0xb5)],0xa);if(isNaN(_0x56efcb)||isNaN(_0x30a575)||_0x56efcb<=0x0||_0x30a575<=0x0||_0x56efcb>_0x30a575){toastr[_0xdc8828(0xd3)](_0xdc8828(0xf6),'圣谕有误');return;}executeManualSummary(_0x56efcb,_0x30a575);}),_0x34437d[_0x16e187(0xb1)](_0x16e187(0xdf),_0x31ef6b=>{const _0x5d240b=_0x16e187;extension_settings[extensionName][_0x5d240b(0xaf)]=_0x31ef6b[_0x5d240b(0xf4)][_0x5d240b(0xfb)],saveSettings();}),_0x21a57b['addEventListener'](_0x16e187(0xdf),_0x3cef51=>{const _0x3d7325=_0x16e187,_0x1c3bcf=parseInt(_0x3cef51[_0x3d7325(0xf4)][_0x3d7325(0xb5)],0xa);if(isNaN(_0x1c3bcf)||_0x1c3bcf<0x1){_0x3cef51[_0x3d7325(0xf4)][_0x3d7325(0xb5)]=defaultSettings['historiographySmallTriggerThreshold'],toastr[_0x3d7325(0xff)](_0x3d7325(0xd8),'圣谕有误');return;}extension_settings[extensionName][_0x3d7325(0xec)]=_0x1c3bcf,saveSettings();}),_0x45378f[_0x16e187(0xb1)](_0x16e187(0xdf),_0x26b454=>{const _0x38e8b7=_0x16e187;extension_settings[extensionName][_0x38e8b7(0xbc)]=_0x26b454[_0x38e8b7(0xf4)]['checked'],saveSettings();}),_0x48ab5c[_0x16e187(0xb1)](_0x16e187(0xdf),_0x376fdc=>{const _0x2c3b4b=_0x16e187;extension_settings[extensionName][_0x2c3b4b(0xf9)]=_0x376fdc['target'][_0x2c3b4b(0xfb)],saveSettings();}),_0x34437d[_0x16e187(0xfb)]=extension_settings[extensionName][_0x16e187(0xaf)]??![],_0x21a57b[_0x16e187(0xb5)]=extension_settings[extensionName][_0x16e187(0xec)]??0x1e,_0x45378f['checked']=extension_settings[extensionName][_0x16e187(0xbc)]??!![],_0x48ab5c[_0x16e187(0xfb)]=extension_settings[extensionName][_0x16e187(0xf9)]??![];const _0x874f28=document[_0x16e187(0xe6)](_0x16e187(0xfe)),_0x573040=_0x451c8e=>{const _0x1f83ac=_0x16e187;_0x874f28[_0x1f83ac(0xc7)][_0x1f83ac(0xc2)]=_0x451c8e;switch(_0x451c8e){case _0x1f83ac(0x104):_0x874f28[_0x1f83ac(0xd0)]=_0x1f83ac(0xd2),_0x874f28[_0x1f83ac(0xb3)]='menu_button\x20small_button\x20interactable\x20danger';break;case _0x1f83ac(0xea):_0x874f28[_0x1f83ac(0xd0)]=_0x1f83ac(0xe2),_0x874f28[_0x1f83ac(0xb3)]=_0x1f83ac(0xee);break;case _0x1f83ac(0x101):default:_0x874f28[_0x1f83ac(0xd0)]=_0x1f83ac(0x105),_0x874f28['className']=_0x1f83ac(0xb4);break;}};document[_0x16e187(0xb1)](_0x16e187(0xb0),_0x2b69eb=>{const _0x4fb4fb=_0x16e187,{isRunning:_0x761d6c,manualStop:_0x1f6d10}=_0x2b69eb[_0x4fb4fb(0xef)];if(_0x761d6c)_0x573040(_0x4fb4fb(0x104));else _0x1f6d10?_0x573040(_0x4fb4fb(0xea)):_0x573040(_0x4fb4fb(0x101));}),_0x874f28[_0x16e187(0xb1)](_0x16e187(0xe5),()=>{const _0x3e2a90=_0x16e187,_0x26d986=_0x874f28[_0x3e2a90(0xc7)]['state']||_0x3e2a90(0x101);_0x26d986==='running'?stopExpedition():executeExpedition();}),_0x573040(_0x16e187(0x101));const _0x4b654e=document[_0x16e187(0xe6)]('amily2_mhb_large_worldbook_selector'),_0x11bc75=document[_0x16e187(0xe6)]('amily2_mhb_large_lore_selector'),_0x32b2e3=document[_0x16e187(0xe6)](_0x16e187(0xf3)),_0x404f24=document[_0x16e187(0xe6)](_0x16e187(0xc5)),_0x43ebae=document[_0x16e187(0xe6)](_0x16e187(0xeb)),_0x55e465=async()=>{const _0xdafde=_0x16e187;_0x4b654e[_0xdafde(0xd0)]=_0xdafde(0xf8);const _0x4cbbea=await getAvailableWorldbooks();_0x4b654e[_0xdafde(0xd0)]='',_0x4cbbea&&_0x4cbbea['length']>0x0?(_0x4cbbea['forEach'](_0x431ea2=>{const _0x2c801f=_0xdafde,_0x459bb0=document[_0x2c801f(0x100)](_0x2c801f(0xbb));_0x459bb0['value']=_0x431ea2,_0x459bb0[_0x2c801f(0xe4)]=_0x431ea2,_0x4b654e['appendChild'](_0x459bb0);}),_0x4b654e[_0xdafde(0xd4)](new Event(_0xdafde(0xdf)))):_0x4b654e['innerHTML']=_0xdafde(0xe3);},_0x21756d=async()=>{const _0x400ae2=_0x16e187,_0x3d8501=_0x4b654e['value'];if(!_0x3d8501){_0x11bc75['innerHTML']=_0x400ae2(0xb2);return;}_0x11bc75['innerHTML']=_0x400ae2(0xb8);const _0x2bf78b=await getLoresForWorldbook(_0x3d8501);_0x11bc75[_0x400ae2(0xd0)]='',_0x2bf78b&&_0x2bf78b['length']>0x0?_0x2bf78b[_0x400ae2(0xf7)](_0x20c4ce=>{const _0x58e590=_0x400ae2,_0x14a1c5=document[_0x58e590(0x100)]('option');_0x14a1c5[_0x58e590(0xb5)]=_0x20c4ce[_0x58e590(0xd6)],_0x14a1c5[_0x58e590(0xe4)]='['+_0x20c4ce[_0x58e590(0xd6)]+']\x20'+_0x20c4ce[_0x58e590(0x102)],_0x11bc75['appendChild'](_0x14a1c5);}):_0x11bc75[_0x400ae2(0xd0)]=_0x400ae2(0xdd);};_0x32b2e3[_0x16e187(0xb1)](_0x16e187(0xe5),_0x55e465),_0x4b654e[_0x16e187(0xb1)](_0x16e187(0xdf),_0x21756d),_0x404f24[_0x16e187(0xb1)]('click',_0x21756d),_0x43ebae[_0x16e187(0xb1)](_0x16e187(0xe5),()=>{const _0x4db8d2=_0x16e187,_0x1b22cc=_0x4b654e[_0x4db8d2(0xb5)],_0x43d718=_0x11bc75[_0x4db8d2(0xb5)];if(!_0x1b22cc||!_0x43d718){toastr['error'](_0x4db8d2(0xf2),_0x4db8d2(0xae));return;}executeRefinement(_0x1b22cc,_0x43d718);});}