mirror of
https://github.com/Wx-2025/ST-Amily2-Chat-Optimisation.git
synced 2026-06-06 03:25:51 +00:00
Initial commit with CC BY-NC-ND 4.0 license
This commit is contained in:
1
utils/auth.js
Normal file
1
utils/auth.js
Normal file
File diff suppressed because one or more lines are too long
1027
utils/settings.js
Normal file
1027
utils/settings.js
Normal file
File diff suppressed because it is too large
Load Diff
1
utils/tagProcessor.js
Normal file
1
utils/tagProcessor.js
Normal file
@@ -0,0 +1 @@
|
||||
(function(_0x2b50a0,_0x3be880){const _0x1017d9=_0x4d61,_0x45b790=_0x2b50a0();while(!![]){try{const _0x329ec4=parseInt(_0x1017d9(0x122))/0x1+parseInt(_0x1017d9(0x11b))/0x2+parseInt(_0x1017d9(0x11e))/0x3*(parseInt(_0x1017d9(0x112))/0x4)+-parseInt(_0x1017d9(0x11f))/0x5+-parseInt(_0x1017d9(0x11d))/0x6+-parseInt(_0x1017d9(0x117))/0x7+parseInt(_0x1017d9(0x110))/0x8;if(_0x329ec4===_0x3be880)break;else _0x45b790['push'](_0x45b790['shift']());}catch(_0x210a37){_0x45b790['push'](_0x45b790['shift']());}}}(_0x2d6b,0x5d5c7));function findLastTagIndices(_0x598dd1,_0x34554f){const _0x26bab3=_0x4d61,_0x5136d5='</'+_0x34554f+'>',_0x26e682=_0x598dd1[_0x26bab3(0x119)](_0x5136d5);if(_0x26e682===-0x1)return null;const _0xede59f='<'+_0x34554f,_0x4fde3e=_0x598dd1[_0x26bab3(0x119)](_0xede59f,_0x26e682);if(_0x4fde3e===-0x1)return null;const _0x265e81=_0x598dd1[_0x26bab3(0x114)]('>',_0x4fde3e);if(_0x265e81===-0x1||_0x265e81>_0x26e682)return null;return{'blockStart':_0x4fde3e,'contentStart':_0x265e81+0x1,'contentEnd':_0x26e682,'blockEnd':_0x26e682+_0x5136d5[_0x26bab3(0x116)]};}function extractContentByTag(_0x5f2e5f,_0x172785){const _0x50140a=_0x4d61,_0x1fffdc=findLastTagIndices(_0x5f2e5f,_0x172785);if(!_0x1fffdc)return null;return _0x5f2e5f['substring'](_0x1fffdc[_0x50140a(0x115)],_0x1fffdc[_0x50140a(0x121)]);}function extractFullTagBlock(_0x326867,_0x425915){const _0x4fbd79=_0x4d61,_0x1c70d3=findLastTagIndices(_0x326867,_0x425915);if(!_0x1c70d3)return null;return _0x326867[_0x4fbd79(0x11a)](_0x1c70d3[_0x4fbd79(0x113)],_0x1c70d3['blockEnd']);}function replaceContentByTag(_0x58ac96,_0x554d7b,_0x3b4da0){const _0x4f1c11=_0x4d61,_0x4795f8=findLastTagIndices(_0x58ac96,_0x554d7b);if(!_0x4795f8)return _0x58ac96;const _0x4fbf65=_0x58ac96[_0x4f1c11(0x11a)](0x0,_0x4795f8[_0x4f1c11(0x115)]),_0x3be82c=_0x58ac96[_0x4f1c11(0x11a)](_0x4795f8[_0x4f1c11(0x121)]);return''+_0x4fbf65+_0x3b4da0+_0x3be82c;}export{extractContentByTag,replaceContentByTag,extractFullTagBlock,opt_extractContentByTag,opt_replaceContentByTag,opt_extractFullTagBlock};function _0x4d61(_0x3f1bbd,_0x47c042){const _0x2d6be6=_0x2d6b();return _0x4d61=function(_0x4d61f9,_0xac78b1){_0x4d61f9=_0x4d61f9-0x110;let _0x253159=_0x2d6be6[_0x4d61f9];return _0x253159;},_0x4d61(_0x3f1bbd,_0x47c042);}function opt_extractContentByTag(_0x5e2aa7,_0x364c0a){const _0x2c1a20=_0x4d61,_0x2a096b=new RegExp('<'+_0x364c0a+'[^>]*>([\x5cs\x5cS]*?)<\x5c/'+_0x364c0a+'>'),_0x27fc19=_0x5e2aa7[_0x2c1a20(0x111)](_0x2a096b);return _0x27fc19?_0x27fc19[0x1]:null;}function opt_extractFullTagBlock(_0x23dfe3,_0x3119df){const _0x2c3336=_0x4d61,_0x46d4cf=new RegExp('(<'+_0x3119df+_0x2c3336(0x120)+_0x3119df+'>)'),_0x1f5260=_0x23dfe3[_0x2c3336(0x111)](_0x46d4cf);return _0x1f5260?_0x1f5260[0x0]:null;}function opt_replaceContentByTag(_0x245bd0,_0x36409d,_0x489d64){const _0x25a8b8=_0x4d61,_0x4c0b1a=new RegExp('(<'+_0x36409d+_0x25a8b8(0x11c)+_0x36409d+'>)'),_0x58be87=_0x245bd0[_0x25a8b8(0x111)](_0x4c0b1a);if(_0x58be87){const _0x48b4b8=_0x58be87[0x1],_0x25bdd6=_0x58be87[0x3];return _0x245bd0[_0x25a8b8(0x118)](_0x4c0b1a,''+_0x48b4b8+_0x489d64+_0x25bdd6);}return _0x245bd0;}function _0x2d6b(){const _0x1043ba=['[^>]*>)([\x5cs\x5cS]*?)(<\x5c/','396606tKlnNz','313611AupJBS','2081160dJYvQS','[^>]*>[\x5cs\x5cS]*?<\x5c/','contentEnd','184972ZHlIdl','4438064arGsjW','match','4Bseeqm','blockStart','indexOf','contentStart','length','1221556JEoseq','replace','lastIndexOf','substring','389962qmNNtv'];_0x2d6b=function(){return _0x1043ba;};return _0x2d6b();}
|
||||
47
utils/utils.js
Normal file
47
utils/utils.js
Normal file
@@ -0,0 +1,47 @@
|
||||
import { getContext } from '/scripts/extensions.js';
|
||||
import { saveChat } from '/script.js';
|
||||
|
||||
function debounce(func, delay) {
|
||||
let timeout;
|
||||
return function(...args) {
|
||||
const context = this;
|
||||
clearTimeout(timeout);
|
||||
timeout = setTimeout(() => func.apply(context, args), delay);
|
||||
};
|
||||
}
|
||||
|
||||
export function getChatPiece() {
|
||||
const context = getContext();
|
||||
if (!context || !context.chat || !context.chat.length) {
|
||||
return { piece: null, deep: -1 };
|
||||
}
|
||||
|
||||
const chat = context.chat;
|
||||
let index = chat.length - 1;
|
||||
|
||||
while (index >= 0) {
|
||||
if (!chat[index].is_user) {
|
||||
return { piece: chat[index], deep: index };
|
||||
}
|
||||
index--;
|
||||
}
|
||||
|
||||
if (chat.length > 0) {
|
||||
return { piece: chat[0], deep: 0 };
|
||||
}
|
||||
return { piece: null, deep: -1 };
|
||||
}
|
||||
|
||||
export const saveChatDebounced = debounce(() => {
|
||||
saveChat();
|
||||
}, 500);
|
||||
|
||||
export function escapeHTML(str) {
|
||||
if (!str) return '';
|
||||
return String(str)
|
||||
.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/"/g, '"')
|
||||
.replace(/'/g, ''');
|
||||
}
|
||||
Reference in New Issue
Block a user