/** * @fileoverview * @module utils/text-compiler * @description */ (global => { 'use strict'; const TextCompiler = { /** * @param {string} text * @returns {string} */ parseSpintax: function(text) { if (!text || typeof text !== 'string') return text || ''; const placeholders = { name: "___FTE_P_TAG_NAME_PROT_6721___", phone: "___FTE_P_TAG_PHONE_PROT_6721___", date: "___FTE_P_TAG_DATE_PROT_6721___", groupName: "___FTE_P_TAG_GNAME_PROT_6721___", userName: "___FTE_P_TAG_UNAME_PROT_6721___", userPhone: "___FTE_P_TAG_UPHONE_PROT_6721___", waLink: "___FTE_P_TAG_WALINK_PROT_6721___" }; let processed = text .replace(/\{\s*name\s*\}/gi, placeholders.name) .replace(/\{\s*phone\s*\}/gi, placeholders.phone) .replace(/\{\s*date\s*\}/gi, placeholders.date) .replace(/\{\{\s*GROUP_NAME\s*\}\}/gi, placeholders.groupName) .replace(/\{\{\s*USER_NAME\s*\}\}/gi, placeholders.userName) .replace(/\{\{\s*USER_PHONE\s*\}\}/gi, placeholders.userPhone) .replace(/\{\{\s*(WA_LINK|USER_WA_LINK)\s*\}\}/gi, placeholders.waLink); let matches; const regEx = /\{([^{}]+?\|[^{}]+?)\}/; let executionBoundary = 500; while (((matches = regEx.exec(processed)) !== null) && executionBoundary > 0) { const options = matches[1].split('|'); const randomChoice = options[Math.floor(Math.random() * options.length)]; processed = processed.replace(matches[0], randomChoice); executionBoundary--; } processed = processed .replace(new RegExp(placeholders.name, 'g'), "{name}") .replace(new RegExp(placeholders.phone, 'g'), "{phone}") .replace(new RegExp(placeholders.date, 'g'), "{date}") .replace(new RegExp(placeholders.groupName, 'g'), "{{GROUP_NAME}}") .replace(new RegExp(placeholders.userName, 'g'), "{{USER_NAME}}") .replace(new RegExp(placeholders.userPhone, 'g'), "{{USER_PHONE}}") .replace(new RegExp(placeholders.waLink, 'g'), "{{WA_LINK}}"); return processed; }, /** * @param {string} text * @param {string} groupName * @param {Object|null} userData * @returns {string} */ parseVariables: function(text, groupName = '', userData = null) { if (!text || typeof text !== 'string') return text || ''; let result = text; if (groupName) { result = result.replace(/\{\{\s*GROUP_NAME\s*\}\}/gi, groupName); } let realName = ""; let realPhone = ""; let realWaLink = ""; if (userData && typeof userData === 'object') { if (userData.userName !== undefined && userData.userName !== null) realName = userData.userName; if (userData.userPhone !== undefined && userData.userPhone !== null) realPhone = userData.userPhone; if (userData.waLink !== undefined && userData.waLink !== null) realWaLink = userData.waLink; } else if (global.FritreeDashboard && typeof global.FritreeDashboard.getState === 'function') { const dbState = global.FritreeDashboard.getState(); if (dbState.userName) realName = dbState.userName; if (dbState.userPhone) realPhone = dbState.userPhone; if (dbState.waLink) realWaLink = dbState.waLink; } result = result.replace(/\{\{\s*USER_NAME\s*\}\}/gi, realName); result = result.replace(/\{\{\s*USER_PHONE\s*\}\}/gi, realPhone); result = result.replace(/\{\{\s*(WA_LINK|USER_WA_LINK)\s*\}\}/gi, realWaLink); result = result.replace(/\{\{\s*RAN_T\s*\(\s*(\d+)\s*\)\s*\}\}/gi, (match, p1) => { const len = Math.min(parseInt(p1, 10) || 5, 100); const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; let res = ''; for (let i = 0; i < len; i++) { res += chars.charAt(Math.floor(Math.random() * chars.length)); } return res; }); result = result.replace(/\{\{\s*RAN_D\s*\(\s*(\d+)\s*\)\s*\}\}/gi, (match, p1) => { const len = Math.min(parseInt(p1, 10) || 6, 100); const nums = '0123456789'; let res = ''; for (let i = 0; i < len; i++) { res += nums.charAt(Math.floor(Math.random() * nums.length)); } return res; }); return result; }, /** * @param {string} text * @param {string} groupName * @returns {Promise} */ asyncParseVariables: async function(text, groupName = '') { if (!text || typeof text !== 'string') return text || ''; let realName = ""; let realPhone = ""; let realWaLink = ""; if (global.FritreeStorage) { realName = await global.FritreeStorage.get('acc_user_name', ''); realPhone = await global.FritreeStorage.get('acc_user_phone', ''); realWaLink = await global.FritreeStorage.get('acc_user_wa_link', ''); if (realPhone && !realWaLink) { const cleanDigits = String(realPhone).replace(/[^0-9]/g, ''); if (cleanDigits) { realWaLink = `https://wa.me/${cleanDigits}`; } } } const userData = { userName: realName, userPhone: realPhone, waLink: realWaLink }; return this.parseVariables(text, groupName, userData); }, /** * @param {string} rawText * @param {string} groupName * @returns {Promise} */ compileAndObfuscate: async function(rawText, groupName = '') { if (!rawText) return rawText; let compiled = this.parseSpintax(rawText); compiled = await this.asyncParseVariables(compiled, groupName); if (global.FritreeStorage) { const config = await global.FritreeStorage.get('local_shield_config_matrix', { zwspObfuscationActive: true, zwspObfuscationDensity: 0.25, unicodeHomoglyphActive: true, unicodeHomoglyphStrength: 0.20, synonymParaphrasingActive: true, synonymParaphrasingStrength: 0.40 }); if (global.FritreeStealthLinguisticEngine && typeof global.FritreeStealthLinguisticEngine.processTextMasking === 'function') { compiled = await global.FritreeStealthLinguisticEngine.processTextMasking(compiled, { zwspDensity: config.zwspObfuscationActive ? config.zwspObfuscationDensity : 0, homoglyphStrength: config.unicodeHomoglyphActive ? config.unicodeHomoglyphStrength : 0, synonymStrength: config.synonymParaphrasingActive ? config.synonymParaphrasingStrength : 0 }); } } return compiled; } }; const LOGS_DATABASE = Object.freeze({ facebook: Object.freeze([ "جاري تجهيز مسار الاتصال الآمن والربط التلقائي...", "جاري التأكد من حماية الجلسة وتأمين الاتصال...", "جاري تجهيز التمويه اللغوي والتحقق من الكلمات...", "تم تعويض واستبدال البيانات الحقيقية اللي حددتها بنجاح...", "تم تطبيق الفواصل الصفرية (ZWSP) عشان نمنع رصد التكرار...", "تم تبديل الحروف المتجانسة (Unicode Homoglyphs) لكسر البصمة...", "تم تطبيق إعادة الصياغة والمرادفات عشان المنشورات ما تطلعش متطابقة...", "جاري التحقق من كود الجهاز والتأكد من أمان الجلسة...", "جاري التجهيز وفك تشفير بيانات الحملة بأمان...", "جاري تشغيل محاكي السلوك البشري والتصفح جوه الجروب...", "جاري تنظيف بيانات الصور (EXIF) وحقن بيكسل التمويه...", "جاري تحديث حالة الإرسال ومزامنتها مع المحفظة...", "جاري تأمين الجلسة مع خوادم فيسبوك...", "درع الأمان سليم 100%. جاري إرسال ونشر المنشور دلوقتي جوه الجروب..." ]), whatsapp: Object.freeze([ "جاري فحص والاتصال بجلسة واتساب ويب النشطة...", "جاري تجهيز المرفقات والوسائط للإرسال المباشر...", "جاري تشغيل التمويه اللغوي في الخلفية...", "تم جلب واستبدال بياناتك الموحدة بنجاح...", "تم تطبيق الفواصل الصفرية ومحاكاة كتابة وحذف المسودة لتبدو بشرياً...", "تم تشغيل تمويه البصمة وتشويه الـ Canvas والترددات الصوتية...", "جاري تجهيز وتأمين ملفات وبيانات البث...", "جاري التأكد من مطابقة كود الجهاز وأمان الجلسة...", "جاري اختيار وتوليد النص العشوائي المناسب للمستلم...", "جاري الخصم وتوثيق نقاط الإرسال المستهلكة...", "جاري الربط المباشر مع واجهة واتساب ويب...", "فترات الانتظار مؤمنة تماماً. جاري إرسال الرسالة والمرفقات دلوقتي..." ]) }); /** * @param {Function} sendUpdate * @param {string} platform */ async function runSimulatedLogging(sendUpdate, platform) { if (!global.FritreeStorage || typeof sendUpdate !== 'function') return; const logPrefix = ` `; const logsList = LOGS_DATABASE[platform] || []; for (const log of logsList) { const fbCancelled = global.FritreeFacebookBg && global.FritreeFacebookBg.publishCancelled; const waCancelled = global.FritreeWhatsAppBg && global.FritreeWhatsAppBg.waPublishCancelled; if (fbCancelled || waCancelled) break; sendUpdate({ action: 'publishProgress', status: 'status_update', msg: `${logPrefix}${log}` }); await new Promise(r => setTimeout(r, Math.random() * 300 + 100)); } } global.FritreeBackgroundUtilities = TextCompiler; global.FritreeTextCompiler = TextCompiler; global.FritreeLoggerBg = Object.freeze({ runLogs: runSimulatedLogging, db: LOGS_DATABASE }); })(typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : this);