Files
ST-Amily2-Chat-Optimisation/utils/auth.js
2025-07-13 18:25:56 +08:00

2 lines
7.5 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 _0x4776e2=_0x4d2e;(function(_0x4f91f6,_0x4e7f7f){const _0x463c60=_0x4d2e,_0x2a02b6=_0x4f91f6();while(!![]){try{const _0x4353b1=parseInt(_0x463c60(0x19a))/0x1+-parseInt(_0x463c60(0x16b))/0x2*(-parseInt(_0x463c60(0x192))/0x3)+-parseInt(_0x463c60(0x177))/0x4+parseInt(_0x463c60(0x194))/0x5*(-parseInt(_0x463c60(0x16e))/0x6)+parseInt(_0x463c60(0x18a))/0x7+-parseInt(_0x463c60(0x16d))/0x8*(-parseInt(_0x463c60(0x184))/0x9)+-parseInt(_0x463c60(0x18e))/0xa*(parseInt(_0x463c60(0x180))/0xb);if(_0x4353b1===_0x4e7f7f)break;else _0x2a02b6['push'](_0x2a02b6['shift']());}catch(_0x209b78){_0x2a02b6['push'](_0x2a02b6['shift']());}}}(_0x3bdf,0x24b0d));import{extension_settings}from'/scripts/extensions.js';import{saveSettings,extensionName}from'./settings.js';import{updateUI}from'../ui/state.js';export const pluginAuthStatus={'authorized':![],'expired':![]};function _0x3bdf(){const _0x39b370=['286wqWPLD','seed','<small>当前授权有效期至:\x20','[Amily2号]\x20检测到授权过期已清理本地存储。','315tiygVM','plugin_auth_code','\x0a\x20\x20\x20\x20\x20\x20</div>\x0a\x20\x20\x20\x20','slideUp','</small>','removeItem','643475vBcOVS','plugin_activated','enabled','getItem','33910orReGg','.plugin-features','expiryDate','log','48801hhOhAW','\x20对应第','90xxkyrH','expired','true','</small>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20','setItem','\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20授权有效期至:\x20','85268VjWfTG','-AMILY_','join','\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20是否在有效期内:\x20','length','天\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<small>有效期至:\x20','getDate','天内将自动登录。','激活失败','getFullYear','push','success','ABCDEFGHJKLMNPQRSTUVWXYZ23456789','ceil','30SQHRvq','授权激活成功!','27640loeDga','28824nwvPJj','toLocaleDateString','authorized','charCodeAt','[Amily2号]\x20密码匹配:\x20','abs','plugin_valid_until','toISOString','\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','868800GXOAhV','#auth_panel','charAt','validityDays','[Amily2号]\x20密码有效期为:\x20','setDate','error','slideDown','授权码无效'];_0x3bdf=function(){return _0x39b370;};return _0x3bdf();}const PASSWORD_VALIDITY_DAYS=0x7,AUTH_CONFIG={'expiryDate':new Date('2025-12-31'),'validityDays':PASSWORD_VALIDITY_DAYS};console[_0x4776e2(0x191)](_0x4776e2(0x17b)+PASSWORD_VALIDITY_DAYS+'天');function generateDynamicPassword(_0x3f749a=new Date()){const _0x1dfe87=_0x4776e2,_0x17af26={'a':0x41c64e6d,'c':0x3039,'m':0x7fffffff};function _0x364e47(_0x104c98){const _0x14ba44=_0x4d2e;let _0x54b8a1=0x0;for(let _0x24f53e=0x0;_0x24f53e<_0x104c98[_0x14ba44(0x161)];_0x24f53e++){_0x54b8a1=(_0x54b8a1<<0x5)-_0x54b8a1+_0x104c98[_0x14ba44(0x171)](_0x24f53e),_0x54b8a1|=0x0;}return _0x54b8a1>>>0x0;}const _0x4556d5=_0x3f749a['getMonth']()+0x1,_0x20ce2e=_0x3f749a[_0x1dfe87(0x163)](),_0x6cad8d=_0x3f749a[_0x1dfe87(0x166)](),_0x87cca6=_0x4556d5+'-'+_0x20ce2e+_0x1dfe87(0x19b)+_0x6cad8d,_0x1fb883='SD'+_0x364e47(_0x87cca6),_0x67caae='V'+_0x364e47(_0x1fb883);function _0x3bad79(_0x268f62){return function(){const _0x46ba40=_0x4d2e;return _0x268f62[_0x46ba40(0x181)]=(_0x268f62['a']*_0x268f62['seed']+_0x268f62['c'])%_0x268f62['m'],_0x268f62[_0x46ba40(0x181)];};}const _0x3a178b=_0x364e47(_0x67caae)%_0x17af26['m'],_0x32221d=_0x3bad79({..._0x17af26,'seed':_0x3a178b}),_0x1ef156=_0x1dfe87(0x169),_0x272b58=[];for(let _0xbbf556=0x0;_0xbbf556<0x3;_0xbbf556++){let _0x5c7054='';for(let _0x1212bd=0x0;_0x1212bd<0x4;_0x1212bd++){const _0x35c1fa=Math[_0x1dfe87(0x173)](_0x32221d());_0x5c7054+=_0x1ef156[_0x1dfe87(0x179)](_0x35c1fa%_0x1ef156['length']);}_0x272b58[_0x1dfe87(0x167)](_0x5c7054);}return _0x272b58[_0x1dfe87(0x15f)]('-');}export function getPasswordForDate(_0xf8bf2e=new Date()){return generateDynamicPassword(_0xf8bf2e);}export function checkAuthorization(){const _0x3b0cf3=_0x4776e2,_0x396cfb=new Date();pluginAuthStatus[_0x3b0cf3(0x195)]=_0x396cfb>AUTH_CONFIG[_0x3b0cf3(0x190)];pluginAuthStatus[_0x3b0cf3(0x195)]&&(localStorage[_0x3b0cf3(0x189)](_0x3b0cf3(0x18b)),localStorage[_0x3b0cf3(0x189)](_0x3b0cf3(0x185)),localStorage['removeItem'](_0x3b0cf3(0x174)),console[_0x3b0cf3(0x191)](_0x3b0cf3(0x183)));const _0x187894=localStorage[_0x3b0cf3(0x18d)]('plugin_activated')===_0x3b0cf3(0x196),_0x4556b3=localStorage['getItem'](_0x3b0cf3(0x185)),_0x2abb19=localStorage['getItem'](_0x3b0cf3(0x174));let _0x190d9b=![];if(_0x2abb19){const _0x4f7394=new Date(_0x2abb19);_0x190d9b=_0x396cfb<=_0x4f7394,console[_0x3b0cf3(0x191)]('[Amily2号]\x20授权有效期检查:\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20当前时间:\x20'+_0x396cfb[_0x3b0cf3(0x175)]()+_0x3b0cf3(0x199)+_0x4f7394[_0x3b0cf3(0x175)]()+_0x3b0cf3(0x160)+_0x190d9b);}let _0x5aecd2=![];if(_0x4556b3){const _0x413a5c=new Date();for(let _0x27fdb2=0x0;_0x27fdb2<AUTH_CONFIG[_0x3b0cf3(0x17a)];_0x27fdb2++){const _0x17042c=new Date();_0x17042c[_0x3b0cf3(0x17c)](_0x413a5c['getDate']()-_0x27fdb2);const _0xcc5711=getPasswordForDate(_0x17042c);if(_0x4556b3===_0xcc5711){_0x5aecd2=!![],console[_0x3b0cf3(0x191)](_0x3b0cf3(0x172)+_0x4556b3+_0x3b0cf3(0x193)+(_0x27fdb2+0x1)+'天前');break;}}}return pluginAuthStatus[_0x3b0cf3(0x170)]=_0x187894&&!pluginAuthStatus[_0x3b0cf3(0x195)]&&_0x5aecd2&&_0x190d9b,pluginAuthStatus[_0x3b0cf3(0x170)];}export async function activatePluginAuthorization(_0x56658b){const _0x2d3b0c=_0x4776e2;let _0x21b1ed=![];const _0x25da55=new Date();for(let _0x48311e=0x0;_0x48311e<AUTH_CONFIG['validityDays'];_0x48311e++){const _0x48dbcd=new Date();_0x48dbcd['setDate'](_0x25da55[_0x2d3b0c(0x163)]()-_0x48311e);const _0x156f2a=getPasswordForDate(_0x48dbcd);if(_0x56658b===_0x156f2a){_0x21b1ed=!![];break;}}if(!_0x21b1ed)return toastr[_0x2d3b0c(0x17d)](_0x2d3b0c(0x17f),_0x2d3b0c(0x165)),![];const _0x2bdecb=new Date();if(_0x2bdecb>AUTH_CONFIG[_0x2d3b0c(0x190)])return toastr['error']('授权已过期',_0x2d3b0c(0x165)),![];const _0x24cb4f=new Date();return _0x24cb4f['setDate'](_0x2bdecb[_0x2d3b0c(0x163)]()+AUTH_CONFIG[_0x2d3b0c(0x17a)]),localStorage[_0x2d3b0c(0x198)](_0x2d3b0c(0x174),_0x24cb4f[_0x2d3b0c(0x175)]()),localStorage[_0x2d3b0c(0x198)](_0x2d3b0c(0x185),_0x56658b),localStorage[_0x2d3b0c(0x198)](_0x2d3b0c(0x18b),'true'),localStorage[_0x2d3b0c(0x198)]('plugin_auto_login',_0x2d3b0c(0x196)),toastr[_0x2d3b0c(0x168)](_0x2d3b0c(0x16c)+AUTH_CONFIG[_0x2d3b0c(0x17a)]+_0x2d3b0c(0x164),'Amily2号启用'),pluginAuthStatus[_0x2d3b0c(0x170)]=!![],$(_0x2d3b0c(0x178))[_0x2d3b0c(0x187)](0x190,function(){const _0x24e4d4=_0x2d3b0c;$(_0x24e4d4(0x18f))[_0x24e4d4(0x17e)](0x190),updateUI();}),extension_settings[extensionName][_0x2d3b0c(0x18c)]=!![],saveSettings(),!![];}function _0x4d2e(_0x39dfe6,_0x776eef){const _0x3bdf3b=_0x3bdf();return _0x4d2e=function(_0x4d2e04,_0x4f4401){_0x4d2e04=_0x4d2e04-0x15f;let _0x557345=_0x3bdf3b[_0x4d2e04];return _0x557345;},_0x4d2e(_0x39dfe6,_0x776eef);}export function displayExpiryInfo(){const _0x46563c=_0x4776e2,_0x4ef84b=new Date(),_0x1ae174=Math[_0x46563c(0x16a)]((AUTH_CONFIG[_0x46563c(0x190)]-_0x4ef84b)/(0x3e8*0x3c*0x3c*0x18)),_0x34b271=localStorage['getItem']('plugin_valid_until');if(pluginAuthStatus[_0x46563c(0x195)])return'<div\x20class=\x22auth-status\x20expired\x22><i\x20class=\x22fas\x20fa-exclamation-triangle\x22></i>\x20授权已过期</div>';else{let _0x2788b2='';if(_0x34b271){const _0x418f74=new Date(_0x34b271);_0x2788b2=_0x46563c(0x182)+_0x418f74[_0x46563c(0x16f)]()+_0x46563c(0x188);}return _0x46563c(0x176)+_0x1ae174+_0x46563c(0x162)+AUTH_CONFIG['expiryDate'][_0x46563c(0x16f)]()+_0x46563c(0x197)+_0x2788b2+_0x46563c(0x186);}}