Files
ST-Amily2-Chat-Optimisation…/utils/auth.js
2025-11-21 00:24:17 +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.
const _0x1cca60=_0x4741;(function(_0x373c63,_0x359802){const _0x5adf6c=_0x4741,_0x4651d2=_0x373c63();while(!![]){try{const _0xe58fe5=-parseInt(_0x5adf6c(0xf5))/0x1*(-parseInt(_0x5adf6c(0xe3))/0x2)+parseInt(_0x5adf6c(0xe1))/0x3+parseInt(_0x5adf6c(0xe8))/0x4*(-parseInt(_0x5adf6c(0xd3))/0x5)+parseInt(_0x5adf6c(0xc7))/0x6+-parseInt(_0x5adf6c(0xc2))/0x7*(parseInt(_0x5adf6c(0xeb))/0x8)+parseInt(_0x5adf6c(0xef))/0x9+-parseInt(_0x5adf6c(0xe6))/0xa;if(_0xe58fe5===_0x359802)break;else _0x4651d2['push'](_0x4651d2['shift']());}catch(_0x3cf3a8){_0x4651d2['push'](_0x4651d2['shift']());}}}(_0x312c,0xab192));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=_0x1cca60(0xbf),AUTH_CONFIG={'expiryDate':new Date(_0x1cca60(0xc5))};export function getPasswordForDate(_0xc0815c){const _0x1290b2=_0x1cca60,_0x24e0e0=_0xc0815c[_0x1290b2(0xe0)](),_0x322ac2=String(_0xc0815c[_0x1290b2(0xd4)]()+0x1)[_0x1290b2(0xd7)](0x2,'0'),_0x5b1b86=String(_0xc0815c[_0x1290b2(0xcf)]())[_0x1290b2(0xd7)](0x2,'0');return _0x1290b2(0xdf)+_0x24e0e0+_0x322ac2+_0x5b1b86;}export function checkAuthorization(){const _0x3e2dae=_0x1cca60,_0x2ae0a4=new Date(),_0x3eda3f=localStorage[_0x3e2dae(0xf3)](_0x3e2dae(0xd9));if(_0x3eda3f){const _0x11a837=new Date(_0x3eda3f);_0x2ae0a4>_0x11a837?pluginAuthStatus[_0x3e2dae(0xc8)]=!![]:pluginAuthStatus[_0x3e2dae(0xc8)]=![];}else pluginAuthStatus['expired']=_0x2ae0a4>AUTH_CONFIG[_0x3e2dae(0xe2)];pluginAuthStatus[_0x3e2dae(0xc8)]&&(localStorage[_0x3e2dae(0xe4)](_0x3e2dae(0xee)),localStorage[_0x3e2dae(0xe4)](_0x3e2dae(0xcc)),localStorage['removeItem']('plugin_user_type'),localStorage['removeItem']('plugin_valid_until'),console[_0x3e2dae(0xdc)](_0x3e2dae(0xe7)));const _0x1790e0=localStorage[_0x3e2dae(0xf3)]('plugin_activated')==='true';return pluginAuthStatus[_0x3e2dae(0xc6)]=_0x1790e0&&!pluginAuthStatus[_0x3e2dae(0xc8)],pluginAuthStatus[_0x3e2dae(0xc6)];}export async function activatePluginAuthorization(_0x413b03){const _0x1203a1=_0x1cca60;try{const _0xbd8a7f=await fetch(SERVER_URL+_0x1203a1(0xc3),{'method':_0x1203a1(0xf4),'headers':{'Content-Type':_0x1203a1(0xc1)},'body':JSON[_0x1203a1(0xf0)]({'code':_0x413b03})}),_0x25b7e5=await _0xbd8a7f[_0x1203a1(0xf1)]();if(_0x25b7e5[_0x1203a1(0xcd)]){localStorage[_0x1203a1(0xec)](_0x1203a1(0xcc),_0x413b03),localStorage['setItem'](_0x1203a1(0xee),_0x1203a1(0xdb)),localStorage[_0x1203a1(0xec)](_0x1203a1(0xd2),_0x1203a1(0xdb)),localStorage['setItem'](_0x1203a1(0xc9),_0x25b7e5[_0x1203a1(0xdd)]),localStorage['removeItem'](_0x1203a1(0xd9));const _0x78a255=_0x25b7e5['note']||_0x25b7e5[_0x1203a1(0xdd)];return toastr[_0x1203a1(0xcd)]('授权激活成功!用户类型:\x20'+_0x78a255,_0x1203a1(0xd1)),pluginAuthStatus[_0x1203a1(0xc6)]=!![],enablePluginUI(),!![];}}catch(_0x3ccb8b){console['warn']('服务器验证连接失败,尝试本地验证...',_0x3ccb8b);}const _0x2352b6=getPasswordForDate(new Date());if(_0x413b03===_0x2352b6){const _0x4c4c03=new Date();return _0x4c4c03[_0x1203a1(0xea)](_0x4c4c03['getDate']()+0x7),localStorage[_0x1203a1(0xec)](_0x1203a1(0xcc),_0x413b03),localStorage['setItem'](_0x1203a1(0xee),_0x1203a1(0xdb)),localStorage[_0x1203a1(0xec)](_0x1203a1(0xd2),_0x1203a1(0xdb)),localStorage[_0x1203a1(0xec)](_0x1203a1(0xc9),'1'),localStorage['setItem'](_0x1203a1(0xd9),_0x4c4c03[_0x1203a1(0xe9)]()),toastr[_0x1203a1(0xcd)](_0x1203a1(0xe5)+_0x4c4c03[_0x1203a1(0xc0)](),_0x1203a1(0xd1)),pluginAuthStatus['authorized']=!![],enablePluginUI(),!![];}return toastr['error'](_0x1203a1(0xce),_0x1203a1(0xd6)),![];}function _0x4741(_0x33d7a4,_0x3ecd85){const _0x312c0d=_0x312c();return _0x4741=function(_0x4741ad,_0x581deb){_0x4741ad=_0x4741ad-0xbf;let _0x2ef28a=_0x312c0d[_0x4741ad];return _0x2ef28a;},_0x4741(_0x33d7a4,_0x3ecd85);}function _0x312c(){const _0x303a1b=['plugin_valid_until','slideUp','true','log','type','\x0a\x20\x20\x20\x20\x20\x20</div>\x0a\x20\x20\x20\x20','Amily-','getFullYear','2682516MKUXgc','expiryDate','167086qkhIXw','removeItem','每日授权激活成功!有效期至:\x20','11247660HGuowg','[Amily2号]\x20检测到授权已过期已清理本地存储。','2692HwIUhs','toISOString','setDate','1107688TATumj','setItem','.plugin-features','plugin_activated','10028259ZRrllJ','stringify','json','slideDown','getItem','POST','1PLFZSK','<div\x20class=\x22auth-status\x20expired\x22><i\x20class=\x22fas\x20fa-exclamation-triangle\x22></i>\x20授权已过期</div>','http://accdn.silencelurker.xyz:2086','toLocaleDateString','application/json','49rsSRcu','/verify','\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','2025-12-31','authorized','8137968DRmGQU','expired','plugin_user_type','ceil','</small>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20','plugin_auth_code','success','授权码无效或服务器连接失败','getDate','天\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<small>有效期至:\x20','Amily2号启用','plugin_auto_login','4855MSkryl','getMonth','<small>当前授权有效期至:\x20','激活失败','padStart','</small>'];_0x312c=function(){return _0x303a1b;};return _0x312c();}function enablePluginUI(){const _0x3edf5d=_0x1cca60;$('#auth_panel')[_0x3edf5d(0xda)](0x190,function(){const _0x5a3212=_0x3edf5d;$(_0x5a3212(0xed))[_0x5a3212(0xf2)](0x190),updateUI();}),extension_settings[extensionName]['enabled']=!![],saveSettings();}export function displayExpiryInfo(){const _0x465d24=_0x1cca60,_0x3e0be9=new Date(),_0x215205=Math[_0x465d24(0xca)]((AUTH_CONFIG[_0x465d24(0xe2)]-_0x3e0be9)/(0x3e8*0x3c*0x3c*0x18)),_0x2b890b=localStorage[_0x465d24(0xf3)](_0x465d24(0xd9));if(pluginAuthStatus[_0x465d24(0xc8)])return _0x465d24(0xf6);else{let _0x10c38f='';if(_0x2b890b){const _0xba4af4=new Date(_0x2b890b);_0x10c38f=_0x465d24(0xd5)+_0xba4af4[_0x465d24(0xc0)]()+_0x465d24(0xd8);}return _0x465d24(0xc4)+_0x215205+_0x465d24(0xd0)+AUTH_CONFIG[_0x465d24(0xe2)][_0x465d24(0xc0)]()+_0x465d24(0xcb)+_0x10c38f+_0x465d24(0xde);}}