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

2 lines
5.9 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.
const _0x512633=_0x2c07;(function(_0x38de7f,_0x58e628){const _0x242fae=_0x2c07,_0x726b89=_0x38de7f();while(!![]){try{const _0x83b47d=-parseInt(_0x242fae(0x151))/0x1+parseInt(_0x242fae(0x130))/0x2*(parseInt(_0x242fae(0x153))/0x3)+-parseInt(_0x242fae(0x148))/0x4*(-parseInt(_0x242fae(0x13c))/0x5)+-parseInt(_0x242fae(0x12e))/0x6*(parseInt(_0x242fae(0x140))/0x7)+-parseInt(_0x242fae(0x14b))/0x8+parseInt(_0x242fae(0x141))/0x9+parseInt(_0x242fae(0x152))/0xa;if(_0x83b47d===_0x58e628)break;else _0x726b89['push'](_0x726b89['shift']());}catch(_0x19238c){_0x726b89['push'](_0x726b89['shift']());}}}(_0x31eb,0xbb13d));import{extension_settings}from'/scripts/extensions.js';function _0x31eb(){const _0x205107=['authorized','9824200mkdDpy','服务器验证连接失败,尝试本地验证...','setDate','<small>当前授权有效期至:\x20','toLocaleDateString','POST','328661hYuqxU','12482190jSbKZQ','3806637cdKNyS','expiryDate','getDate','plugin_valid_until','每日授权激活成功!有效期至:\x20','ceil','getFullYear','log','</small>','removeItem','enabled','stringify','26622lWPioR','plugin_activated','2NXXmmS','json','toISOString','expired','true','setItem','天\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<small>有效期至:\x20','授权码无效或服务器连接失败','application/json','plugin_auth_code','2025-12-31','getItem','25WoFFjZ','plugin_auto_login','success','http://accdn.silencelurker.xyz:2086','2296IuuMiR','1143882LldiPm','padStart','error','plugin_user_type','Amily-','激活失败','授权激活成功!用户类型:\x20','907276yfOcAB','slideUp'];_0x31eb=function(){return _0x205107;};return _0x31eb();}import{saveSettings,extensionName}from'./settings.js';import{updateUI}from'../ui/state.js';export const pluginAuthStatus={'authorized':![],'expired':![]};const SERVER_URL=_0x512633(0x13f),AUTH_CONFIG={'expiryDate':new Date(_0x512633(0x13a))};export function getPasswordForDate(_0x117972){const _0x52661f=_0x512633,_0x70bc0d=_0x117972[_0x52661f(0x159)](),_0x45b6a1=String(_0x117972['getMonth']()+0x1)[_0x52661f(0x142)](0x2,'0'),_0x2206ce=String(_0x117972[_0x52661f(0x155)]())[_0x52661f(0x142)](0x2,'0');return _0x52661f(0x145)+_0x70bc0d+_0x45b6a1+_0x2206ce;}function _0x2c07(_0x2c9f6e,_0x501a5a){const _0x31eb16=_0x31eb();return _0x2c07=function(_0x2c0711,_0x3bc7ad){_0x2c0711=_0x2c0711-0x12c;let _0x20bafe=_0x31eb16[_0x2c0711];return _0x20bafe;},_0x2c07(_0x2c9f6e,_0x501a5a);}export function checkAuthorization(){const _0x338a87=_0x512633,_0x6ea34f=new Date(),_0x218c05=localStorage['getItem']('plugin_valid_until');if(_0x218c05){const _0x4330a4=new Date(_0x218c05);_0x6ea34f>_0x4330a4?pluginAuthStatus[_0x338a87(0x133)]=!![]:pluginAuthStatus[_0x338a87(0x133)]=![];}else pluginAuthStatus['expired']=_0x6ea34f>AUTH_CONFIG[_0x338a87(0x154)];pluginAuthStatus[_0x338a87(0x133)]&&(localStorage[_0x338a87(0x15c)](_0x338a87(0x12f)),localStorage['removeItem'](_0x338a87(0x139)),localStorage[_0x338a87(0x15c)](_0x338a87(0x144)),localStorage[_0x338a87(0x15c)](_0x338a87(0x156)),console[_0x338a87(0x15a)]('[Amily2号]\x20检测到授权已过期已清理本地存储。'));const _0x495903=localStorage[_0x338a87(0x13b)](_0x338a87(0x12f))===_0x338a87(0x134);return pluginAuthStatus[_0x338a87(0x14a)]=_0x495903&&!pluginAuthStatus[_0x338a87(0x133)],pluginAuthStatus[_0x338a87(0x14a)];}export async function activatePluginAuthorization(_0x529320){const _0x398aff=_0x512633;try{const _0x18b86b=await fetch(SERVER_URL+'/verify',{'method':_0x398aff(0x150),'headers':{'Content-Type':_0x398aff(0x138)},'body':JSON[_0x398aff(0x12d)]({'code':_0x529320})}),_0x39e943=await _0x18b86b[_0x398aff(0x131)]();if(_0x39e943['success'])return localStorage[_0x398aff(0x135)]('plugin_auth_code',_0x529320),localStorage['setItem'](_0x398aff(0x12f),_0x398aff(0x134)),localStorage[_0x398aff(0x135)](_0x398aff(0x13d),'true'),localStorage['setItem'](_0x398aff(0x144),_0x39e943['type']),localStorage[_0x398aff(0x15c)](_0x398aff(0x156)),toastr[_0x398aff(0x13e)](_0x398aff(0x147)+_0x39e943['type'],'Amily2号启用'),pluginAuthStatus['authorized']=!![],enablePluginUI(),!![];}catch(_0x169c8c){console['warn'](_0x398aff(0x14c),_0x169c8c);}const _0x43ffc9=getPasswordForDate(new Date());if(_0x529320===_0x43ffc9){const _0x92650e=new Date();return _0x92650e[_0x398aff(0x14d)](_0x92650e[_0x398aff(0x155)]()+0x7),localStorage[_0x398aff(0x135)](_0x398aff(0x139),_0x529320),localStorage['setItem'](_0x398aff(0x12f),_0x398aff(0x134)),localStorage['setItem'](_0x398aff(0x13d),_0x398aff(0x134)),localStorage[_0x398aff(0x135)]('plugin_user_type','1'),localStorage[_0x398aff(0x135)](_0x398aff(0x156),_0x92650e[_0x398aff(0x132)]()),toastr[_0x398aff(0x13e)](_0x398aff(0x157)+_0x92650e[_0x398aff(0x14f)](),'Amily2号启用'),pluginAuthStatus['authorized']=!![],enablePluginUI(),!![];}return toastr[_0x398aff(0x143)](_0x398aff(0x137),_0x398aff(0x146)),![];}function enablePluginUI(){const _0x524dfa=_0x512633;$('#auth_panel')[_0x524dfa(0x149)](0x190,function(){$('.plugin-features')['slideDown'](0x190),updateUI();}),extension_settings[extensionName][_0x524dfa(0x12c)]=!![],saveSettings();}export function displayExpiryInfo(){const _0x4551f3=_0x512633,_0x3541a5=new Date(),_0x589d2e=Math[_0x4551f3(0x158)]((AUTH_CONFIG['expiryDate']-_0x3541a5)/(0x3e8*0x3c*0x3c*0x18)),_0x2279a4=localStorage[_0x4551f3(0x13b)](_0x4551f3(0x156));if(pluginAuthStatus[_0x4551f3(0x133)])return'<div\x20class=\x22auth-status\x20expired\x22><i\x20class=\x22fas\x20fa-exclamation-triangle\x22></i>\x20授权已过期</div>';else{let _0x5c3abd='';if(_0x2279a4){const _0x9ba980=new Date(_0x2279a4);_0x5c3abd=_0x4551f3(0x14e)+_0x9ba980[_0x4551f3(0x14f)]()+_0x4551f3(0x15b);}return'\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'+_0x589d2e+_0x4551f3(0x136)+AUTH_CONFIG[_0x4551f3(0x154)][_0x4551f3(0x14f)]()+'</small>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20'+_0x5c3abd+'\x0a\x20\x20\x20\x20\x20\x20</div>\x0a\x20\x20\x20\x20';}}