mirror of
https://github.com/SilenceLurker/ST-Amily2-Chat-Optimisation.git
synced 2026-06-06 22:55:51 +00:00
2 lines
9.9 KiB
JavaScript
2 lines
9.9 KiB
JavaScript
function _0x34be(_0x263bcc,_0x4da51a){const _0x3a6175=_0x3a61();return _0x34be=function(_0x34be57,_0x2d539d){_0x34be57=_0x34be57-0x1b7;let _0x587cc6=_0x3a6175[_0x34be57];return _0x587cc6;},_0x34be(_0x263bcc,_0x4da51a);}(function(_0x52c305,_0x5a7f03){const _0x3c1401=_0x34be,_0x333ec6=_0x52c305();while(!![]){try{const _0x2470d9=-parseInt(_0x3c1401(0x1c3))/0x1+parseInt(_0x3c1401(0x222))/0x2*(-parseInt(_0x3c1401(0x1ba))/0x3)+parseInt(_0x3c1401(0x1bc))/0x4*(parseInt(_0x3c1401(0x223))/0x5)+parseInt(_0x3c1401(0x1c6))/0x6*(parseInt(_0x3c1401(0x203))/0x7)+parseInt(_0x3c1401(0x1c5))/0x8*(parseInt(_0x3c1401(0x20d))/0x9)+-parseInt(_0x3c1401(0x1c8))/0xa+-parseInt(_0x3c1401(0x205))/0xb*(parseInt(_0x3c1401(0x1b9))/0xc);if(_0x2470d9===_0x5a7f03)break;else _0x333ec6['push'](_0x333ec6['shift']());}catch(_0x42c359){_0x333ec6['push'](_0x333ec6['shift']());}}}(_0x3a61,0x44c9c));import{extension_settings}from'/scripts/extensions.js';import{characters,this_chid}from'/script.js';import{extensionName,defaultSettings}from'../utils/settings.js';import{pluginAuthStatus}from'../utils/auth.js';let availableModels=[],latestUpdateInfo=null,newVersionAvailable=![];export function setUpdateInfo(_0x172219,_0x289969){newVersionAvailable=_0x172219,latestUpdateInfo=_0x289969;}function _0x3a61(){const _0x184665=['loreActivationMode','#amily2_model_notes','plotOpt_worldbookSource','worldbookEnabled','historiographySmallAutoEnable','#amily2_optimization_exclusion_enabled',']\x20(state.js)\x20剧情优化UI已根据合并设置更新。','checked','showOptimizationToast','append','optimizationMode','<span\x20style=\x22color:\x20#ff9800;\x22>请检查API配置后点击\x22刷新模型\x22</span>','#amily2_api_provider','#amily2_system_prompt','forEach','val','#amily2_optimization_enabled','#amily2_output_format_prompt','已选择:\x20<strong>','suppressToast','#amily2_worldbook_enabled','text','summarizationPrompt','#amily2_show_optimization_toast','\x20个可用模型','#amily2_summarization_enabled','#amily2_lore_depth_input','input[name=\x22amily2_lorebook_target\x22][value=\x22','88809oLDqeh','#amily2_auto_hide_threshold','2618SYmkow','#amily2_opt_rate_erotic','#amily2_preset_selector','plotOpt_mainPrompt','empty','#amily2_opt_enabled','iconLocation','#auth_panel','585pSuQJB','outputFormatPrompt','#amily2_enabled','.plugin-features','plotOpt_enabled','#amily2_opt_worldbook_enabled','model','summarizationEnabled','attr','<option\x20value=\x22\x22>无可用模型,请刷新</option>','change','optimizationEnabled','#amily2_auto_hide_threshold_value','tavernProfile','plotOpt_worldbook_enabled','#amily2_update_indicator','contextMessages','#amily2_max_tokens','length','hide','authorized','112786bwRmnx','10VhTJeH','lorebookTarget','#amily2_opt_final_system_directive','plotOpt_rateErotic','loreDepth','#amily2_model','#amily2_opt_rate_main','type','#amily2_main_prompt','#amily2_suppress_toast','log','#amily2_lore_depth_container','data','24636TVhxQa','15Fejbze','已加载\x20','820384KoQXUj','#amily2_api_key','input[name=\x22amily2_icon_location\x22][value=\x22','#amily2_lore_insertion_position','plotOpt_worldbookCharLimit','show','#amily2_mhb_small_auto_enabled','100230BbiarU','html','29768BFvutY','264citSxE','historiographySmallTriggerThreshold','577200hazBjN','#amily2_optimization_target_tag','extensions','enabled','autoHideThreshold','<option></option>','maxTokens','#amily2_update_button_new','plotOpt_rateMain','selected','input[name=\x22amily2_optimization_mode\x22][value=\x22','#amily2_opt_system_prompt','#amily2_temperature','#amily2_temperature_value','#amily2_context_messages','apiKey','character','input[name=\x22amily2_opt_worldbook_source\x22][value=\x22','apiUrl','#amily2_context_messages_value','trigger','plotOpt_ratePersonal','mainPrompt','#amily2_opt_rate_cuckold','loreInsertionPosition','plotOpt_contextLimit','#amily2_opt_rate_personal','#amily2_api_url','undefined','prop','_value'];_0x3a61=function(){return _0x184665;};return _0x3a61();}export function applyUpdateIndicator(){const _0x5817d4=_0x34be;newVersionAvailable?($('#amily2_update_indicator')[_0x5817d4(0x1c1)](),$(_0x5817d4(0x1cf))[_0x5817d4(0x1c1)]()):($(_0x5817d4(0x21c))[_0x5817d4(0x220)](),$(_0x5817d4(0x1cf))['hide']());}export function getLatestUpdateInfo(){return latestUpdateInfo;}export function setAvailableModels(_0x26c506){availableModels=_0x26c506;}export function populateModelDropdown(){const _0x4febd3=_0x34be,_0x28bb7a=$(_0x4febd3(0x228)),_0x24b30b=$(_0x4febd3(0x1e8));_0x28bb7a[_0x4febd3(0x209)]();const _0x3117ca=extension_settings[extensionName]?.[_0x4febd3(0x213)]||'';if(availableModels['length']===0x0){_0x28bb7a['append'](_0x4febd3(0x216)),_0x24b30b['html'](_0x4febd3(0x1f2));return;}const _0x379984=$(_0x4febd3(0x1cd))[_0x4febd3(0x1f6)]('')[_0x4febd3(0x1fc)]('--\x20选择模型\x20--');_0x28bb7a['append'](_0x379984),availableModels[_0x4febd3(0x1f5)](_0x36e6f9=>{const _0x205c42=_0x4febd3,_0x1d698b=$(_0x205c42(0x1cd))[_0x205c42(0x1f6)](_0x36e6f9)[_0x205c42(0x1fc)](_0x36e6f9);_0x36e6f9===_0x3117ca&&_0x1d698b[_0x205c42(0x215)](_0x205c42(0x1d1),'selected'),_0x28bb7a[_0x205c42(0x1f0)](_0x1d698b);}),_0x3117ca&&_0x28bb7a[_0x4febd3(0x1f6)]()===_0x3117ca?_0x24b30b['html'](_0x4febd3(0x1f9)+_0x3117ca+'</strong>'):_0x24b30b[_0x4febd3(0x1c4)](_0x4febd3(0x1bb)+availableModels[_0x4febd3(0x21f)]+_0x4febd3(0x1ff));}export function updateUI(){const _0x3b2041=_0x34be;if(!pluginAuthStatus[_0x3b2041(0x221)])$('#auth_panel')[_0x3b2041(0x1c1)](),$(_0x3b2041(0x210))[_0x3b2041(0x220)]();else{$(_0x3b2041(0x20c))[_0x3b2041(0x220)](),$(_0x3b2041(0x210))[_0x3b2041(0x1c1)]();const _0x589bbd=extension_settings[extensionName];if(!_0x589bbd)return;$(_0x3b2041(0x20f))[_0x3b2041(0x1e5)](_0x3b2041(0x1ee),_0x589bbd[_0x3b2041(0x1cb)]),$(_0x3b2041(0x1f3))[_0x3b2041(0x1f6)](_0x589bbd['apiProvider']||'openai'),$(_0x3b2041(0x1e3))[_0x3b2041(0x1f6)](_0x589bbd[_0x3b2041(0x1da)]),$(_0x3b2041(0x1e3))['attr'](_0x3b2041(0x22a),'text'),$(_0x3b2041(0x1bd))[_0x3b2041(0x1f6)](_0x589bbd[_0x3b2041(0x1d7)]),$(_0x3b2041(0x228))[_0x3b2041(0x1f6)](_0x589bbd[_0x3b2041(0x213)]),$(_0x3b2041(0x207))['val'](_0x589bbd[_0x3b2041(0x21a)]),$(_0x3b2041(0x1f3))[_0x3b2041(0x1dc)](_0x3b2041(0x217)),$(_0x3b2041(0x21e))[_0x3b2041(0x1f6)](_0x589bbd[_0x3b2041(0x1ce)]),$('#amily2_max_tokens_value')[_0x3b2041(0x1fc)](_0x589bbd[_0x3b2041(0x1ce)]),$(_0x3b2041(0x1d4))['val'](_0x589bbd['temperature']),$(_0x3b2041(0x1d5))[_0x3b2041(0x1fc)](_0x589bbd['temperature']),$(_0x3b2041(0x1d6))['val'](_0x589bbd[_0x3b2041(0x21d)]),$(_0x3b2041(0x1db))[_0x3b2041(0x1fc)](_0x589bbd['contextMessages']),$(_0x3b2041(0x1c9))[_0x3b2041(0x1f6)](_0x589bbd['optimizationTargetTag']),$(_0x3b2041(0x1d2)+_0x589bbd[_0x3b2041(0x1f1)]+'\x22]')['prop']('checked',!![]),$(_0x3b2041(0x1f7))[_0x3b2041(0x1e5)]('checked',_0x589bbd[_0x3b2041(0x218)]),$(_0x3b2041(0x1ec))[_0x3b2041(0x1e5)]('checked',_0x589bbd['optimizationExclusionEnabled']),$(_0x3b2041(0x1fe))[_0x3b2041(0x1e5)](_0x3b2041(0x1ee),_0x589bbd[_0x3b2041(0x1ef)]),$(_0x3b2041(0x22c))[_0x3b2041(0x1e5)](_0x3b2041(0x1ee),_0x589bbd[_0x3b2041(0x1fa)]),$(_0x3b2041(0x1f4))[_0x3b2041(0x1f6)](_0x589bbd['systemPrompt']),$(_0x3b2041(0x22b))[_0x3b2041(0x1f6)](_0x589bbd[_0x3b2041(0x1de)]),$(_0x3b2041(0x1f8))['val'](_0x589bbd[_0x3b2041(0x20e)]),$('#amily2_summarization_prompt')[_0x3b2041(0x1f6)](_0x589bbd[_0x3b2041(0x1fd)]),$(_0x3b2041(0x1fb))[_0x3b2041(0x1e5)]('checked',_0x589bbd[_0x3b2041(0x1ea)]),$(_0x3b2041(0x200))['prop'](_0x3b2041(0x1ee),_0x589bbd[_0x3b2041(0x214)]),$(_0x3b2041(0x202)+_0x589bbd[_0x3b2041(0x224)]+'\x22]')[_0x3b2041(0x1e5)](_0x3b2041(0x1ee),!![]),$(_0x3b2041(0x1be)+_0x589bbd[_0x3b2041(0x20b)]+'\x22]')['prop'](_0x3b2041(0x1ee),!![]),$('#amily2_auto_hide_enabled')[_0x3b2041(0x1e5)](_0x3b2041(0x1ee),_0x589bbd['autoHideEnabled']),$(_0x3b2041(0x204))['val'](_0x589bbd[_0x3b2041(0x1cc)]),$(_0x3b2041(0x219))['text'](_0x589bbd[_0x3b2041(0x1cc)]),$('#amily2_lore_activation_mode')[_0x3b2041(0x1f6)](_0x589bbd[_0x3b2041(0x1e7)]),$(_0x3b2041(0x1bf))[_0x3b2041(0x1f6)](_0x589bbd[_0x3b2041(0x1e0)]),$(_0x3b2041(0x201))[_0x3b2041(0x1f6)](_0x589bbd[_0x3b2041(0x227)]),_0x589bbd[_0x3b2041(0x1e0)]==='at_depth'?$(_0x3b2041(0x1b7))[_0x3b2041(0x1c1)]():$('#amily2_lore_depth_container')[_0x3b2041(0x220)](),_0x589bbd['historiographySmallAutoEnable']!==undefined&&$(_0x3b2041(0x1c2))['prop'](_0x3b2041(0x1ee),_0x589bbd[_0x3b2041(0x1eb)]),_0x589bbd[_0x3b2041(0x1c7)]!==undefined&&$('#amily2_mhb_small_trigger_count')[_0x3b2041(0x1f6)](_0x589bbd[_0x3b2041(0x1c7)]),populateModelDropdown(),updatePlotOptimizationUI();}}function getMergedPlotOptSettings(){const _0x1f546e=_0x34be,_0x5042aa=characters&&typeof this_chid!==_0x1f546e(0x1e4)&&characters[this_chid]?characters[this_chid]:null,_0x3b170b=extension_settings[extensionName]||defaultSettings,_0x156e96=_0x5042aa?.[_0x1f546e(0x1b8)]?.[_0x1f546e(0x1ca)]?.[extensionName]||{};return{..._0x3b170b,..._0x156e96};}export function updatePlotOptimizationUI(){const _0x28ff4c=_0x34be,_0x5cd286=getMergedPlotOptSettings();if(!_0x5cd286)return;$(_0x28ff4c(0x20a))[_0x28ff4c(0x1e5)]('checked',_0x5cd286[_0x28ff4c(0x211)]),$(_0x28ff4c(0x212))['prop']('checked',_0x5cd286[_0x28ff4c(0x21b)]),$('#amily2_opt_main_prompt')['val'](_0x5cd286[_0x28ff4c(0x208)]),$(_0x28ff4c(0x1d3))['val'](_0x5cd286['plotOpt_systemPrompt']),$(_0x28ff4c(0x225))[_0x28ff4c(0x1f6)](_0x5cd286['plotOpt_finalSystemDirective']),$(_0x28ff4c(0x229))[_0x28ff4c(0x1f6)](_0x5cd286[_0x28ff4c(0x1d0)]),$(_0x28ff4c(0x1e2))['val'](_0x5cd286[_0x28ff4c(0x1dd)]),$(_0x28ff4c(0x206))[_0x28ff4c(0x1f6)](_0x5cd286[_0x28ff4c(0x226)]),$(_0x28ff4c(0x1df))[_0x28ff4c(0x1f6)](_0x5cd286['plotOpt_rateCuckold']);const _0x369bc7={'#amily2_opt_context_limit':_0x28ff4c(0x1e1),'#amily2_opt_worldbook_char_limit':_0x28ff4c(0x1c0)};for(const _0x4410ff in _0x369bc7){const _0xdc15d2=_0x369bc7[_0x4410ff],_0x114e24=_0x5cd286[_0xdc15d2],_0xa40bdc=_0x4410ff+_0x28ff4c(0x1e6);_0x114e24!==undefined&&($(_0x4410ff)[_0x28ff4c(0x1f6)](_0x114e24),$(_0xa40bdc)[_0x28ff4c(0x1fc)](_0x114e24));}const _0x38d64a=_0x5cd286[_0x28ff4c(0x1e9)]||_0x28ff4c(0x1d8);$(_0x28ff4c(0x1d9)+_0x38d64a+'\x22]')[_0x28ff4c(0x1e5)]('checked',!![]),console[_0x28ff4c(0x22d)]('['+extensionName+_0x28ff4c(0x1ed));}
|