Files
ST-Amily2-Chat-Optimisation/utils/auth.js
2025-11-21 00:44:22 +08:00

2 lines
6.0 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
function _0x5943(_0x27efe6,_0x2b1f1f){const _0x488ccd=_0x488c();return _0x5943=function(_0x594375,_0x4f86c2){_0x594375=_0x594375-0x118;let _0x2779dd=_0x488ccd[_0x594375];return _0x2779dd;},_0x5943(_0x27efe6,_0x2b1f1f);}function _0x488c(){const _0x2d20da=['authorized','201ngwizO','</small>','toISOString','padStart','授权码无效或服务器连接失败','http://accdn.silencelurker.xyz:2086','ceil','removeItem','#auth_panel','[Amily2号]\x20检测到授权已过期已清理本地存储。','getDate','toLocaleDateString','3389600cJYYqr','<div\x20class=\x22auth-status\x20expired\x22><i\x20class=\x22fas\x20fa-exclamation-triangle\x22></i>\x20授权已过期</div>','slideDown','\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','getItem','setItem','.plugin-features','每日授权激活成功!有效期至:\x20','plugin_activated','plugin_auto_login','error','服务器验证连接失败,尝试本地验证...','Amily2号启用','12052894geKlDl','getFullYear','</small>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20','激活失败','241908eoKmcK','67624XnSnEI','success','expiryDate','getMonth','plugin_user_type','天\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<small>有效期至:\x20','json','3582815XhMPxt','2025-12-31','type','stringify','Amily-','793400xoeXih','true','<small>当前授权有效期至:\x20','plugin_valid_until','enabled','expired','warn','setDate','application/json','15540712FMwvFZ','plugin_auth_code','\x0a\x20\x20\x20\x20\x20\x20</div>\x0a\x20\x20\x20\x20'];_0x488c=function(){return _0x2d20da;};return _0x488c();}const _0x4de1b4=_0x5943;(function(_0x53ab51,_0x17120a){const _0x50342f=_0x5943,_0x2740dc=_0x53ab51();while(!![]){try{const _0x22b808=parseInt(_0x50342f(0x12c))/0x1+-parseInt(_0x50342f(0x145))/0x2+parseInt(_0x50342f(0x139))/0x3*(-parseInt(_0x50342f(0x120))/0x4)+-parseInt(_0x50342f(0x127))/0x5+parseInt(_0x50342f(0x11f))/0x6+parseInt(_0x50342f(0x11b))/0x7+parseInt(_0x50342f(0x135))/0x8;if(_0x22b808===_0x17120a)break;else _0x2740dc['push'](_0x2740dc['shift']());}catch(_0x5c6a26){_0x2740dc['push'](_0x2740dc['shift']());}}}(_0x488c,0xe8ee4));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=_0x4de1b4(0x13e),AUTH_CONFIG={'expiryDate':new Date(_0x4de1b4(0x128))};export function getPasswordForDate(_0x14c29d){const _0xa039e3=_0x4de1b4,_0x410c69=_0x14c29d[_0xa039e3(0x11c)](),_0x14b8f7=String(_0x14c29d[_0xa039e3(0x123)]()+0x1)[_0xa039e3(0x13c)](0x2,'0'),_0x3e019d=String(_0x14c29d[_0xa039e3(0x143)]())[_0xa039e3(0x13c)](0x2,'0');return _0xa039e3(0x12b)+_0x410c69+_0x14b8f7+_0x3e019d;}export function checkAuthorization(){const _0x58e269=_0x4de1b4,_0x110a46=new Date(),_0x2960ce=localStorage['getItem'](_0x58e269(0x12f));if(_0x2960ce){const _0x68cff9=new Date(_0x2960ce);_0x110a46>_0x68cff9?pluginAuthStatus[_0x58e269(0x131)]=!![]:pluginAuthStatus['expired']=![];}else pluginAuthStatus[_0x58e269(0x131)]=_0x110a46>AUTH_CONFIG[_0x58e269(0x122)];pluginAuthStatus[_0x58e269(0x131)]&&(localStorage[_0x58e269(0x140)](_0x58e269(0x14d)),localStorage[_0x58e269(0x140)](_0x58e269(0x136)),localStorage[_0x58e269(0x140)]('plugin_user_type'),localStorage[_0x58e269(0x140)](_0x58e269(0x12f)),console['log'](_0x58e269(0x142)));const _0x2ac23a=localStorage[_0x58e269(0x149)](_0x58e269(0x14d))===_0x58e269(0x12d);return pluginAuthStatus[_0x58e269(0x138)]=_0x2ac23a&&!pluginAuthStatus[_0x58e269(0x131)],pluginAuthStatus[_0x58e269(0x138)];}export async function activatePluginAuthorization(_0x4bebb3){const _0x27652b=_0x4de1b4;try{const _0x1caf49=await fetch(SERVER_URL+'/verify',{'method':'POST','headers':{'Content-Type':_0x27652b(0x134)},'body':JSON[_0x27652b(0x12a)]({'code':_0x4bebb3})}),_0x2a841d=await _0x1caf49[_0x27652b(0x126)]();if(_0x2a841d[_0x27652b(0x121)]){localStorage['setItem'](_0x27652b(0x136),_0x4bebb3),localStorage[_0x27652b(0x14a)]('plugin_activated',_0x27652b(0x12d)),localStorage['setItem'](_0x27652b(0x14e),'true'),localStorage['setItem'](_0x27652b(0x124),_0x2a841d[_0x27652b(0x129)]),localStorage[_0x27652b(0x140)](_0x27652b(0x12f));const _0x3df35d=_0x2a841d['note']||_0x2a841d[_0x27652b(0x129)];return toastr[_0x27652b(0x121)]('授权激活成功!用户类型:\x20'+_0x3df35d,_0x27652b(0x11a)),pluginAuthStatus[_0x27652b(0x138)]=!![],enablePluginUI(),!![];}}catch(_0x32088e){console[_0x27652b(0x132)](_0x27652b(0x119),_0x32088e);}const _0x27b709=getPasswordForDate(new Date());if(_0x4bebb3===_0x27b709){const _0x328a13=new Date();return _0x328a13[_0x27652b(0x133)](_0x328a13[_0x27652b(0x143)]()+0x7),localStorage[_0x27652b(0x14a)](_0x27652b(0x136),_0x4bebb3),localStorage['setItem'](_0x27652b(0x14d),_0x27652b(0x12d)),localStorage[_0x27652b(0x14a)](_0x27652b(0x14e),_0x27652b(0x12d)),localStorage[_0x27652b(0x14a)](_0x27652b(0x124),'1'),localStorage[_0x27652b(0x14a)](_0x27652b(0x12f),_0x328a13[_0x27652b(0x13b)]()),toastr['success'](_0x27652b(0x14c)+_0x328a13[_0x27652b(0x144)](),_0x27652b(0x11a)),pluginAuthStatus[_0x27652b(0x138)]=!![],enablePluginUI(),!![];}return toastr[_0x27652b(0x118)](_0x27652b(0x13d),_0x27652b(0x11e)),![];}function enablePluginUI(){const _0x52d670=_0x4de1b4;$(_0x52d670(0x141))['slideUp'](0x190,function(){const _0x4960ff=_0x52d670;$(_0x4960ff(0x14b))[_0x4960ff(0x147)](0x190),updateUI();}),extension_settings[extensionName][_0x52d670(0x130)]=!![],saveSettings();}export function displayExpiryInfo(){const _0x280be5=_0x4de1b4,_0x2c076c=new Date(),_0xf273e5=Math[_0x280be5(0x13f)]((AUTH_CONFIG[_0x280be5(0x122)]-_0x2c076c)/(0x3e8*0x3c*0x3c*0x18)),_0x36adfc=localStorage[_0x280be5(0x149)](_0x280be5(0x12f));if(pluginAuthStatus[_0x280be5(0x131)])return _0x280be5(0x146);else{let _0x406c1c='';if(_0x36adfc){const _0x7dcb49=new Date(_0x36adfc);_0x406c1c=_0x280be5(0x12e)+_0x7dcb49['toLocaleDateString']()+_0x280be5(0x13a);}return _0x280be5(0x148)+_0xf273e5+_0x280be5(0x125)+AUTH_CONFIG[_0x280be5(0x122)][_0x280be5(0x144)]()+_0x280be5(0x11d)+_0x406c1c+_0x280be5(0x137);}}