mirror of
https://github.com/SilenceLurker/ST-Amily2-Chat-Optimisation.git
synced 2026-06-06 12:25:51 +00:00
2 lines
6.0 KiB
JavaScript
2 lines
6.0 KiB
JavaScript
const _0x2fa4d3=_0x16f9;function _0x509b(){const _0x38a5f7=['22642704zvbZES','#auth_panel','getFullYear','getMonth','authorized','https://amilyservice.amily49.cc','removeItem','expired','expiryDate','\x0a\x20\x20\x20\x20\x20\x20</div>\x0a\x20\x20\x20\x20','ceil','plugin_user_type','true','success','getDate','Amily-','556588jIHnAe','padStart','note','2093270VxyNNi','log','application/json','2338143JBHgir','slideDown','每日授权激活成功!有效期至:\x20','<small>当前授权有效期至:\x20','.plugin-features','4092174ruUeaQ','enabled','getItem','stringify','服务器验证连接失败,尝试本地验证...','[Amily2号]\x20检测到授权已过期,已清理本地存储。','setItem','type','plugin_auth_code','8zdjtba','</small>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20','970960FUcxgD','warn','7931028WMdZcd','2025-12-31','激活失败','<div\x20class=\x22auth-status\x20expired\x22><i\x20class=\x22fas\x20fa-exclamation-triangle\x22></i>\x20授权已过期</div>','setDate','toLocaleDateString','Amily2号启用','\x0a\x20\x20\x20\x20\x20\x20<div\x20class=\x22auth-status\x20valid\x22>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<i\x20class=\x22fas\x20fa-lock-open\x22></i>\x20授权有效期:\x20','授权码无效或服务器连接失败','toISOString','plugin_activated','plugin_valid_until'];_0x509b=function(){return _0x38a5f7;};return _0x509b();}function _0x16f9(_0x42fc5b,_0x143a9e){const _0x509b7c=_0x509b();return _0x16f9=function(_0x16f92a,_0x153cf8){_0x16f92a=_0x16f92a-0x139;let _0x56c34b=_0x509b7c[_0x16f92a];return _0x56c34b;},_0x16f9(_0x42fc5b,_0x143a9e);}(function(_0x3f27ea,_0x45cfe4){const _0x2c0955=_0x16f9,_0x1ccd9b=_0x3f27ea();while(!![]){try{const _0x4b8205=parseInt(_0x2c0955(0x14f))/0x1+-parseInt(_0x2c0955(0x165))/0x2+parseInt(_0x2c0955(0x155))/0x3+parseInt(_0x2c0955(0x163))/0x4*(parseInt(_0x2c0955(0x152))/0x5)+parseInt(_0x2c0955(0x15a))/0x6+parseInt(_0x2c0955(0x167))/0x7+-parseInt(_0x2c0955(0x13f))/0x8;if(_0x4b8205===_0x45cfe4)break;else _0x1ccd9b['push'](_0x1ccd9b['shift']());}catch(_0x383e8e){_0x1ccd9b['push'](_0x1ccd9b['shift']());}}}(_0x509b,0xa42ec));import{extension_settings}from'/scripts/extensions.js';import{saveSettings,extensionName}from'./settings.js';import{updateUI}from'../ui/state.js';export const pluginAuthStatus={'authorized':![],'expired':![]};const SERVER_URL=_0x2fa4d3(0x144),AUTH_CONFIG={'expiryDate':new Date(_0x2fa4d3(0x168))};export function getPasswordForDate(_0x66610e){const _0x1d96dd=_0x2fa4d3,_0x4b1efa=_0x66610e[_0x1d96dd(0x141)](),_0x11c4b8=String(_0x66610e[_0x1d96dd(0x142)]()+0x1)['padStart'](0x2,'0'),_0x43c29d=String(_0x66610e[_0x1d96dd(0x14d)]())[_0x1d96dd(0x150)](0x2,'0');return _0x1d96dd(0x14e)+_0x4b1efa+_0x11c4b8+_0x43c29d;}export function checkAuthorization(){const _0x437588=_0x2fa4d3,_0x14ea85=new Date(),_0x4deb2b=localStorage['getItem'](_0x437588(0x13e));if(_0x4deb2b){const _0x42cb14=new Date(_0x4deb2b);_0x14ea85>_0x42cb14?pluginAuthStatus[_0x437588(0x146)]=!![]:pluginAuthStatus[_0x437588(0x146)]=![];}else pluginAuthStatus['expired']=_0x14ea85>AUTH_CONFIG[_0x437588(0x147)];pluginAuthStatus[_0x437588(0x146)]&&(localStorage[_0x437588(0x145)]('plugin_activated'),localStorage[_0x437588(0x145)]('plugin_auth_code'),localStorage['removeItem'](_0x437588(0x14a)),localStorage[_0x437588(0x145)](_0x437588(0x13e)),console[_0x437588(0x153)](_0x437588(0x15f)));const _0x59f2b4=localStorage[_0x437588(0x15c)](_0x437588(0x13d))===_0x437588(0x14b);return pluginAuthStatus[_0x437588(0x143)]=_0x59f2b4&&!pluginAuthStatus[_0x437588(0x146)],pluginAuthStatus[_0x437588(0x143)];}export async function activatePluginAuthorization(_0x10d045){const _0x4cd4d1=_0x2fa4d3;try{const _0x1768ff=await fetch(SERVER_URL+'/verify',{'method':'POST','headers':{'Content-Type':_0x4cd4d1(0x154)},'body':JSON[_0x4cd4d1(0x15d)]({'code':_0x10d045})}),_0x474ae7=await _0x1768ff['json']();if(_0x474ae7[_0x4cd4d1(0x14c)]){localStorage[_0x4cd4d1(0x160)](_0x4cd4d1(0x162),_0x10d045),localStorage['setItem']('plugin_activated','true'),localStorage[_0x4cd4d1(0x160)]('plugin_auto_login',_0x4cd4d1(0x14b)),localStorage[_0x4cd4d1(0x160)](_0x4cd4d1(0x14a),_0x474ae7[_0x4cd4d1(0x161)]),localStorage[_0x4cd4d1(0x145)](_0x4cd4d1(0x13e));const _0x204084=_0x474ae7[_0x4cd4d1(0x151)]||_0x474ae7['type'];return toastr[_0x4cd4d1(0x14c)]('授权激活成功!用户:\x20'+_0x204084,_0x4cd4d1(0x139)),pluginAuthStatus['authorized']=!![],enablePluginUI(),!![];}}catch(_0x1579d8){console[_0x4cd4d1(0x166)](_0x4cd4d1(0x15e),_0x1579d8);}const _0x5edd70=getPasswordForDate(new Date());if(_0x10d045===_0x5edd70){const _0x3ecc17=new Date();return _0x3ecc17[_0x4cd4d1(0x16b)](_0x3ecc17[_0x4cd4d1(0x14d)]()+0x7),localStorage[_0x4cd4d1(0x160)]('plugin_auth_code',_0x10d045),localStorage[_0x4cd4d1(0x160)]('plugin_activated',_0x4cd4d1(0x14b)),localStorage[_0x4cd4d1(0x160)]('plugin_auto_login',_0x4cd4d1(0x14b)),localStorage[_0x4cd4d1(0x160)](_0x4cd4d1(0x14a),'1'),localStorage[_0x4cd4d1(0x160)](_0x4cd4d1(0x13e),_0x3ecc17[_0x4cd4d1(0x13c)]()),toastr['success'](_0x4cd4d1(0x157)+_0x3ecc17[_0x4cd4d1(0x16c)](),'Amily2号启用'),pluginAuthStatus[_0x4cd4d1(0x143)]=!![],enablePluginUI(),!![];}return toastr['error'](_0x4cd4d1(0x13b),_0x4cd4d1(0x169)),![];}function enablePluginUI(){const _0x47ab2f=_0x2fa4d3;$(_0x47ab2f(0x140))['slideUp'](0x190,function(){const _0x4661b0=_0x47ab2f;$(_0x4661b0(0x159))[_0x4661b0(0x156)](0x190),updateUI();}),extension_settings[extensionName][_0x47ab2f(0x15b)]=!![],saveSettings();}export function displayExpiryInfo(){const _0x2662bd=_0x2fa4d3,_0x53cae0=new Date(),_0x190589=Math[_0x2662bd(0x149)]((AUTH_CONFIG['expiryDate']-_0x53cae0)/(0x3e8*0x3c*0x3c*0x18)),_0x40883e=localStorage[_0x2662bd(0x15c)](_0x2662bd(0x13e));if(pluginAuthStatus[_0x2662bd(0x146)])return _0x2662bd(0x16a);else{let _0x54dc36='';if(_0x40883e){const _0x1014f2=new Date(_0x40883e);_0x54dc36=_0x2662bd(0x158)+_0x1014f2['toLocaleDateString']()+'</small>';}return _0x2662bd(0x13a)+_0x190589+'天\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<small>有效期至:\x20'+AUTH_CONFIG[_0x2662bd(0x147)][_0x2662bd(0x16c)]()+_0x2662bd(0x164)+_0x54dc36+_0x2662bd(0x148);}}
|