|
|
|
|
|
|
|
|
| (global => {
|
| 'use strict';
|
|
|
|
|
| const SHIELD_INTEGRITY_SALT = "FritreeFacebookStealthShieldSymmetricSignatureSalt_SHA256_2026_EnterpriseSecureForce";
|
| const RULES_INTEGRITY_SALT = "FritreeStealthRulesSymmetricVerificationSignatureSalt_SHA256_2026_EnterpriseSecureForce";
|
|
|
|
|
| const DEFAULT_SHIELD_CONFIG = {
|
|
|
| sessionProfile: "casual",
|
| typingProfile: "average",
|
| typingSpeedMultiplier: 1.0,
|
|
|
| humanScrollActive: true,
|
| simulateMouseActive: true,
|
| antiHoneypotActive: true,
|
| humanTypingActive: true,
|
| randomMicroActive: true,
|
| autoPauseFailActive: true,
|
|
|
| scrollStepPixels: 250,
|
| scrollTotalCycles: 4,
|
| mouseMovementCycles: 5,
|
| mouseJitterSpeed: 8,
|
| coordinateJitterRadius: 8,
|
| showVirtualCursor: true,
|
|
|
| canvasNoiseActive: true,
|
| audioContextNoiseActive: true,
|
| webRtcLeakProtectionActive: true,
|
| hardwareConcurrencyMockActive: true,
|
| deviceMemoryMockActive: true,
|
| batteryApiMockActive: true,
|
| languagesSpoofActive: true,
|
| screenOrientationSpoofActive: true,
|
| pluginsMockActive: true,
|
| idleWanderActive: true,
|
|
|
| safeHoursSchedulerActive: true,
|
| dailyCapActive: false,
|
| dailyCapLimit: 100,
|
| typoRatio: 0.04,
|
| activeFreezeState: false,
|
|
|
| viewportJitterActive: true,
|
| idleCursorDriftActive: true,
|
| audioFingerprintNoiseActive: true,
|
|
|
|
|
| fbAntiHoneypotStrict: true,
|
| fbFocusShufflingActive: true,
|
| fbFocusShuffleMinSec: 15,
|
| fbFocusShuffleMaxSec: 45,
|
| fbHesitationBeforeType: true,
|
| fbHesitationMinMs: 800,
|
| fbHesitationMaxMs: 2500,
|
| fbSmoothScrollAcceleration: true,
|
| fbNetworkInfoSpoof: true,
|
|
|
|
|
| waScrollActive: true,
|
| waMouseEmulationActive: true,
|
| waAntiHoneypotActive: true,
|
| waHumanTypingActive: true,
|
| waCanvasNoiseActive: true,
|
| waRandomTabActive: true,
|
| waTypingSimulationActive: true,
|
| waViewportJitterActive: true,
|
| waDailyCapLimit: 150,
|
|
|
| waScrollStepPixels: 200,
|
| waScrollTotalCycles: 3,
|
| waCoordinateJitterRadius: 6,
|
| waTypingDeletions: 3,
|
|
|
|
|
| waAntiHoneypotStrict: true,
|
| waFocusShufflingActive: true,
|
| waFocusShuffleMinSec: 15,
|
| waFocusShuffleMaxSec: 45,
|
| waHesitationBeforeType: true,
|
| waHesitationMinMs: 600,
|
| waHesitationMaxMs: 2200,
|
| waSmoothScrollAcceleration: true,
|
| waNetworkInfoSpoof: true,
|
| waAudioFingerprintNoise: true
|
| };
|
|
|
|
|
| const UI_FIELD_MAPPING = {
|
|
|
| 'chk-human-scroll': 'humanScrollActive',
|
| 'chk-simulate-mouse': 'simulateMouseActive',
|
| 'chk-anti-honeypot': 'antiHoneypotActive',
|
| 'chk-human-typing': 'humanTypingActive',
|
| 'chk-random-micro': 'randomMicroActive',
|
| 'chk-auto-pause-fail': 'autoPauseFailActive',
|
| 'chk-canvas-noise': 'canvasNoiseActive',
|
| 'chk-safe-hours-scheduler': 'safeHoursSchedulerActive',
|
| 'chk-random-tab-switch': 'idleWanderActive',
|
| 'chk-viewport-jitter': 'activeFreezeState',
|
| 'chk-custom-user-agent': 'languagesSpoofActive',
|
| 'chk-text-typing-delays': 'audioContextNoiseActive',
|
| 'chk-post-layout-scramble': 'webRtcLeakProtectionActive',
|
| 'num-max-daily-posts': 'dailyCapLimit',
|
|
|
| 'chk-fb-audio-noise': 'audioFingerprintNoiseActive',
|
| 'chk-fb-viewport-jitter': 'viewportJitterActive',
|
| 'chk-fb-cursor-drift': 'idleCursorDriftActive',
|
| 'chk-fb-show-virtual-cursor': 'showVirtualCursor',
|
|
|
| 'chk-fb-honeypot-strict': 'fbAntiHoneypotStrict',
|
| 'chk-fb-focus-shuffle': 'fbFocusShufflingActive',
|
| 'chk-fb-hesitation': 'fbHesitationBeforeType',
|
| 'chk-fb-smooth-scroll': 'fbSmoothScrollAcceleration',
|
| 'chk-fb-network-info': 'fbNetworkInfoSpoof',
|
|
|
|
|
| 'chk-wa-scroll': 'waScrollActive',
|
| 'chk-wa-mouse-emulation': 'waMouseEmulationActive',
|
| 'chk-wa-anti-honeypot': 'waAntiHoneypotActive',
|
| 'chk-wa-human-typing': 'waHumanTypingActive',
|
| 'chk-wa-canvas': 'waCanvasNoiseActive',
|
| 'chk-wa-random-tab': 'waRandomTabActive',
|
| 'chk-wa-typing-simulation': 'waTypingSimulationActive',
|
| 'chk-wa-viewport-jitter': 'waViewportJitterActive',
|
| 'chk-wa-cursor-emulation': 'showVirtualCursor',
|
| 'num-wa-max-daily': 'waDailyCapLimit',
|
|
|
| 'chk-wa-honeypot-strict': 'waAntiHoneypotStrict',
|
| 'chk-wa-focus-shuffle': 'waFocusShufflingActive',
|
| 'chk-wa-hesitation': 'waHesitationBeforeType',
|
| 'chk-wa-smooth-scroll': 'waSmoothScrollAcceleration',
|
| 'chk-wa-network-info': 'waNetworkInfoSpoof',
|
| 'chk-wa-audio-noise': 'waAudioFingerprintNoise'
|
| };
|
|
|
|
|
| const DUAL_INPUT_MAPPING = [
|
|
|
| {
|
| numId: 'num-scroll-step',
|
| rangeId: 'range-scroll-step',
|
| lblId: 'modal-lbl-scroll-pixels-val',
|
| configKey: 'scrollStepPixels',
|
| suffix: ' px'
|
| },
|
| {
|
| numId: 'num-scroll-cycles',
|
| rangeId: 'range-scroll-cycles',
|
| lblId: 'modal-lbl-scroll-cycles-val',
|
| configKey: 'scrollTotalCycles',
|
| suffix: ' Cycles'
|
| },
|
| {
|
| numId: 'num-mouse-cycles',
|
| rangeId: 'range-mouse-cycles',
|
| lblId: 'modal-lbl-mouse-cycles-val',
|
| configKey: 'mouseMovementCycles',
|
| suffix: ' Path(s)'
|
| },
|
| {
|
| numId: 'num-mouse-speed',
|
| rangeId: 'range-mouse-speed',
|
| lblId: 'modal-lbl-mouse-speed-val',
|
| configKey: 'mouseJitterSpeed',
|
| suffix: ' ms'
|
| },
|
| {
|
| numId: 'num-click-jitter',
|
| rangeId: 'range-click-jitter',
|
| lblId: 'modal-lbl-click-jitter-val',
|
| configKey: 'coordinateJitterRadius',
|
| suffix: ' px'
|
| },
|
|
|
|
|
| {
|
| numId: 'num-wa-scroll-step',
|
| rangeId: 'range-wa-scroll-step',
|
| lblId: 'modal-lbl-wa-scroll-pixels',
|
| configKey: 'waScrollStepPixels',
|
| suffix: ' px'
|
| },
|
| {
|
| numId: 'num-wa-scroll-cycles',
|
| rangeId: 'range-wa-scroll-cycles',
|
| lblId: 'modal-lbl-wa-scroll-cycles',
|
| configKey: 'waScrollTotalCycles',
|
| suffix: ' Cycles'
|
| },
|
| {
|
| numId: 'num-wa-click-jitter',
|
| rangeId: 'range-wa-click-jitter',
|
| lblId: 'modal-lbl-wa-click-jitter',
|
| configKey: 'waCoordinateJitterRadius',
|
| suffix: ' px'
|
| },
|
| {
|
| numId: 'num-wa-typing-deletions',
|
| rangeId: 'range-wa-typing-deletions',
|
| lblId: 'modal-lbl-wa-typing-deletions',
|
| configKey: 'waTypingDeletions',
|
| suffix: ' Cycles'
|
| }
|
| ];
|
|
|
|
|
|
|
|
|
| function analyzeSpintaxStructure(text) {
|
| if (!text) return { valid: true, variations: 1, errors: null };
|
|
|
| let openCount = 0;
|
| let closeCount = 0;
|
| const stack = [];
|
|
|
| for (let i = 0; i < text.length; i++) {
|
| const char = text[i];
|
| if (char === '{') {
|
| openCount++;
|
| stack.push(i);
|
| } else if (char === '}') {
|
| closeCount++;
|
| if (stack.length === 0) {
|
| return {
|
| valid: false,
|
| variations: 0,
|
| errors: `Spintax error: Unmatched closing brace '}' found at position [${i}]`
|
| };
|
| }
|
| stack.pop();
|
| }
|
| }
|
|
|
| if (stack.length > 0) {
|
| return {
|
| valid: false,
|
| variations: 0,
|
| errors: `Spintax error: Unopened brace '{' left unclosed at position [${stack[0]}]`
|
| };
|
| }
|
|
|
| let variations = 1;
|
| const regEx = /\{([^{}]+?)\}/g;
|
| let match;
|
| let boundaryLimit = 1000;
|
| let textCopy = text;
|
|
|
| while (((match = regEx.exec(textCopy)) !== null) && boundaryLimit > 0) {
|
| const options = match[1].split('|');
|
| variations *= options.length;
|
| textCopy = textCopy.replace(match[0], "SPEC_VAL");
|
| regEx.lastIndex = 0;
|
| boundaryLimit--;
|
| }
|
|
|
| return {
|
| valid: true,
|
| variations: variations,
|
| errors: null
|
| };
|
| }
|
|
|
| function updateSpintaxStats() {
|
| const postTextarea = document.getElementById('post-text');
|
| const countLabel = document.getElementById('spintax-count-lbl');
|
| const uniqueLabel = document.getElementById('spintax-unique-lbl');
|
| const duplicateWarn = document.getElementById('spintax-duplicate-warn');
|
|
|
| if (!postTextarea) return;
|
|
|
| const text = postTextarea.value;
|
| const analysis = analyzeSpintaxStructure(text);
|
|
|
| if (countLabel) {
|
| if (!analysis.valid) {
|
| countLabel.innerHTML = `<i class="fa-solid fa-triangle-exclamation" style="color:var(--danger); margin-right:3px;"></i>Invalid Spintax syntax`;
|
| } else {
|
| countLabel.innerHTML = `<i class="fa-solid fa-calculator"></i>Unique variations: ${analysis.variations.toLocaleString('en-US')} distinct copy paths`;
|
| }
|
| }
|
|
|
| if (uniqueLabel) {
|
| if (!analysis.valid) {
|
| uniqueLabel.innerHTML = `<i class="fa-solid fa-fingerprint"></i>Expected content uniqueness: N/A`;
|
| } else {
|
| const pct = analysis.variations > 50 ? 100 : Math.round((analysis.variations / 50) * 100);
|
| uniqueLabel.innerHTML = `<i class="fa-solid fa-fingerprint"></i>Expected content uniqueness: ${pct.toLocaleString('en-US')}%`;
|
| }
|
| }
|
|
|
| if (duplicateWarn) {
|
| if (!analysis.valid && analysis.errors) {
|
| duplicateWarn.innerHTML = `<i class="fa-solid fa-circle-exclamation"></i>${analysis.errors}`;
|
| duplicateWarn.style.color = "var(--danger)";
|
| } else if (analysis.variations < 10 && text.length > 0) {
|
| duplicateWarn.innerHTML = `<i class="fa-solid fa-triangle-exclamation"></i>Security Warning: Variation probability is low. Add more Spintax structures to avoid automated spam pattern detection.`;
|
| duplicateWarn.style.color = "var(--warning)";
|
| } else {
|
| duplicateWarn.textContent = "";
|
| }
|
| }
|
| }
|
|
|
|
|
|
|
|
|
| async function evaluateAntibanRiskScore() {
|
| const config = await FritreeStorage.get('local_shield_config_matrix', DEFAULT_SHIELD_CONFIG);
|
| let riskPoints = 100;
|
|
|
|
|
| if (!config.humanScrollActive) riskPoints -= 8;
|
| if (!config.simulateMouseActive) riskPoints -= 10;
|
| if (!config.humanTypingActive) riskPoints -= 8;
|
| if (!config.antiHoneypotActive) riskPoints -= 8;
|
| if (!config.randomMicroActive) riskPoints -= 6;
|
| if (!config.autoPauseFailActive) riskPoints -= 6;
|
| if (!config.canvasNoiseActive) riskPoints -= 8;
|
| if (!config.webRtcLeakProtectionActive) riskPoints -= 8;
|
| if (!config.safeHoursSchedulerActive) riskPoints -= 5;
|
| if (!config.idleCursorDriftActive) riskPoints -= 4;
|
| if (!config.viewportJitterActive) riskPoints -= 4;
|
| if (!config.audioFingerprintNoiseActive) riskPoints -= 4;
|
|
|
| if (!config.fbAntiHoneypotStrict) riskPoints -= 4;
|
| if (!config.fbFocusShufflingActive) riskPoints -= 4;
|
| if (!config.fbHesitationBeforeType) riskPoints -= 4;
|
| if (!config.fbSmoothScrollAcceleration) riskPoints -= 4;
|
| if (!config.fbNetworkInfoSpoof) riskPoints -= 4;
|
|
|
|
|
| if (!config.waScrollActive) riskPoints -= 8;
|
| if (!config.waMouseEmulationActive) riskPoints -= 10;
|
| if (!config.waAntiHoneypotActive) riskPoints -= 8;
|
| if (!config.waHumanTypingActive) riskPoints -= 8;
|
| if (!config.waCanvasNoiseActive) riskPoints -= 8;
|
| if (!config.waRandomTabActive) riskPoints -= 6;
|
| if (!config.waTypingSimulationActive) riskPoints -= 10;
|
| if (!config.waViewportJitterActive) riskPoints -= 4;
|
|
|
| if (!config.waAntiHoneypotStrict) riskPoints -= 4;
|
| if (!config.waFocusShufflingActive) riskPoints -= 4;
|
| if (!config.waHesitationBeforeType) riskPoints -= 4;
|
| if (!config.waSmoothScrollAcceleration) riskPoints -= 4;
|
| if (!config.waNetworkInfoSpoof) riskPoints -= 4;
|
| if (!config.waAudioFingerprintNoise) riskPoints -= 4;
|
|
|
|
|
| if ((config.scrollStepPixels || 250) > 600) riskPoints -= 3;
|
| if ((config.scrollTotalCycles || 4) < 2) riskPoints -= 3;
|
| if ((config.mouseMovementCycles || 5) < 3) riskPoints -= 3;
|
| if ((config.mouseJitterSpeed || 8) < 5) riskPoints -= 3;
|
| if ((config.coordinateJitterRadius || 8) < 4) riskPoints -= 3;
|
|
|
|
|
| if ((config.waScrollStepPixels || 200) > 500) riskPoints -= 3;
|
| if ((config.waScrollTotalCycles || 3) < 2) riskPoints -= 3;
|
| if ((config.waCoordinateJitterRadius || 6) < 3) riskPoints -= 3;
|
| if ((config.waTypingDeletions || 3) < 1) riskPoints -= 5;
|
|
|
|
|
| const scorePct = Math.min(Math.max(riskPoints, 0), 100);
|
| const progressFill = document.getElementById('risk-progress-bar');
|
| const riskBadge = document.getElementById('risk-score-badge');
|
|
|
| if (progressFill) {
|
| progressFill.style.width = `${scorePct}%`;
|
| if (scorePct <= 40) {
|
| progressFill.style.background = "linear-gradient(90deg, #ef4444, #f87171)";
|
| } else if (scorePct <= 75) {
|
| progressFill.style.background = "linear-gradient(90deg, #f59e0b, #fbbf24)";
|
| } else {
|
| progressFill.style.background = "linear-gradient(90deg, #10b981, #34d399)";
|
| }
|
| }
|
|
|
| if (riskBadge) {
|
| if (scorePct <= 40) {
|
| riskBadge.className = "badge red";
|
| riskBadge.innerHTML = `<i class="fa-solid fa-circle-xmark"></i>Critical Shield Degradation (Low Protection)`;
|
| } else if (scorePct <= 75) {
|
| riskBadge.className = "badge yellow";
|
| riskBadge.innerHTML = `<i class="fa-solid fa-circle-exclamation"></i>Moderate Antiban Index`;
|
| } else {
|
| riskBadge.className = "badge green";
|
| riskBadge.innerHTML = `<i class="fa-solid fa-shield-halved"></i>Stealth Shield Confirmed (Maximum Protection)`;
|
| }
|
| }
|
| }
|
|
|
|
|
|
|
|
|
| async function calculateShieldSignature(config) {
|
| const serialized = JSON.stringify(config);
|
| const concatString = `${serialized}:${SHIELD_INTEGRITY_SALT}`;
|
|
|
| if (typeof FritreeCrypto !== 'undefined' && typeof FritreeCrypto.signReceipt === 'function') {
|
| return await FritreeCrypto.signReceipt(
|
| "FB_STEALTH_SHIELD_V3",
|
| concatString.length,
|
| "config_signature_256",
|
| concatString,
|
| SHIELD_INTEGRITY_SALT
|
| );
|
| }
|
| return "fallback_shield_sig_256_" + concatString.length;
|
| }
|
|
|
| async function saveProtectionSettings() {
|
| const currentMatrix = await FritreeStorage.get('local_shield_config_matrix', DEFAULT_SHIELD_CONFIG);
|
|
|
|
|
| Object.keys(UI_FIELD_MAPPING).forEach(uiId => {
|
| const element = document.getElementById(uiId);
|
| if (element) {
|
| const configKey = UI_FIELD_MAPPING[uiId];
|
| if (element.type === 'checkbox') {
|
| currentMatrix[configKey] = element.checked;
|
| } else if (element.type === 'number') {
|
| currentMatrix[configKey] = parseInt(element.value) || 0;
|
| }
|
| }
|
| });
|
|
|
|
|
| DUAL_INPUT_MAPPING.forEach(pair => {
|
| const numEl = document.getElementById(pair.numId);
|
| if (numEl) {
|
| currentMatrix[pair.configKey] = parseInt(numEl.value) || DEFAULT_SHIELD_CONFIG[pair.configKey];
|
| }
|
| });
|
|
|
| const signature256 = await calculateShieldSignature(currentMatrix);
|
|
|
|
|
| const concatString = `${JSON.stringify(currentMatrix)}:${SHIELD_INTEGRITY_SALT}`;
|
| let signature512 = "fallback_shield_sig_512_" + concatString.length;
|
| if (typeof FritreeCrypto !== 'undefined' && typeof FritreeCrypto.signReceipt === 'function') {
|
| signature512 = await FritreeCrypto.signReceipt(
|
| "FB_STEALTH_SHIELD_V3",
|
| concatString.length,
|
| "config_signature_512",
|
| concatString,
|
| SHIELD_INTEGRITY_SALT
|
| );
|
| }
|
|
|
| await FritreeStorage.set('local_shield_config_matrix', currentMatrix);
|
| await FritreeStorage.set('local_shield_config_matrix_sig_256', signature256);
|
| await FritreeStorage.set('local_shield_config_matrix_sig_512', signature512);
|
|
|
| await evaluateAntibanRiskScore();
|
| }
|
|
|
| async function loadProtectionSettings() {
|
| const matrix = await FritreeStorage.get('local_shield_config_matrix', DEFAULT_SHIELD_CONFIG);
|
| const savedSig = await FritreeStorage.get('local_shield_config_matrix_sig_256', '');
|
|
|
| if (savedSig) {
|
| const computedSig = await calculateShieldSignature(matrix);
|
| if (savedSig !== computedSig) {
|
| console.log("[Fritree Crypto] Unified protection matrix signature aligned.");
|
| await FritreeStorage.set('local_shield_config_matrix_sig_256', computedSig);
|
| }
|
| }
|
|
|
| syncMatrixToUIForm(matrix);
|
| await evaluateAntibanRiskScore();
|
| }
|
|
|
| function syncMatrixToUIForm(matrix) {
|
|
|
| Object.keys(UI_FIELD_MAPPING).forEach(uiId => {
|
| const element = document.getElementById(uiId);
|
| if (element) {
|
| const configKey = UI_FIELD_MAPPING[uiId];
|
| if (element.type === 'checkbox') {
|
| element.checked = !!matrix[configKey];
|
| } else {
|
| element.value = matrix[configKey] !== undefined ? matrix[configKey] : '';
|
| }
|
| }
|
| });
|
|
|
|
|
| DUAL_INPUT_MAPPING.forEach(pair => {
|
| const numEl = document.getElementById(pair.numId);
|
| const rangeEl = document.getElementById(pair.rangeId);
|
| const lblEl = document.getElementById(pair.lblId);
|
|
|
| const value = matrix[pair.configKey] !== undefined ? matrix[pair.configKey] : DEFAULT_SHIELD_CONFIG[pair.configKey];
|
|
|
| if (numEl) numEl.value = value;
|
| if (rangeEl) rangeEl.value = value;
|
| if (lblEl) lblEl.textContent = `${value.toLocaleString('en-US')}${pair.suffix}`;
|
| });
|
| }
|
|
|
|
|
|
|
|
|
| function initDynamicSyncOrchestrator() {
|
| if (typeof chrome !== 'undefined' && chrome.storage && chrome.storage.onChanged) {
|
| chrome.storage.onChanged.addListener(async (changes, namespace) => {
|
| if (namespace === 'local' && changes.local_shield_config_matrix) {
|
| const newValue = changes.local_shield_config_matrix.newValue;
|
| if (newValue) {
|
| syncMatrixToUIForm(newValue);
|
| await evaluateAntibanRiskScore();
|
|
|
| if (typeof window.addLog === 'function') {
|
| window.addLog("Shield Sync: Active settings matrix synchronized across processes.", "success");
|
| }
|
| }
|
| }
|
| });
|
| }
|
|
|
|
|
| Object.keys(UI_FIELD_MAPPING).forEach(uiId => {
|
| const element = document.getElementById(uiId);
|
| if (element) {
|
| const eventType = element.type === 'checkbox' ? 'change' : 'input';
|
| element.addEventListener(eventType, async () => {
|
| await saveProtectionSettings();
|
| });
|
| }
|
| });
|
|
|
|
|
| DUAL_INPUT_MAPPING.forEach(pair => {
|
| const numEl = document.getElementById(pair.numId);
|
| const rangeEl = document.getElementById(pair.rangeId);
|
| const lblEl = document.getElementById(pair.lblId);
|
|
|
| if (numEl && rangeEl) {
|
| numEl.addEventListener('input', async (e) => {
|
| let val = parseInt(e.target.value) || 0;
|
| const min = parseInt(rangeEl.min);
|
| const max = parseInt(rangeEl.max);
|
|
|
| if (val < min) val = min;
|
| if (val > max) val = max;
|
|
|
| rangeEl.value = val;
|
| if (lblEl) lblEl.textContent = `${val.toLocaleString('en-US')}${pair.suffix}`;
|
| await saveProtectionSettings();
|
| });
|
|
|
| rangeEl.addEventListener('input', async (e) => {
|
| const val = parseInt(e.target.value);
|
| numEl.value = val;
|
| if (lblEl) lblEl.textContent = `${val.toLocaleString('en-US')}${pair.suffix}`;
|
| await saveProtectionSettings();
|
| });
|
| }
|
| });
|
| }
|
|
|
|
|
|
|
|
|
| async function saveDelayIntervalSettings() {
|
| const intervals = {
|
| mode: document.getElementById('delay-mode')?.value || 'continuous',
|
| min: parseInt(document.getElementById('delay-min')?.value) || 60,
|
| max: parseInt(document.getElementById('delay-max')?.value) || 120,
|
| fixed: parseInt(document.getElementById('delay-fixed')?.value) || 60,
|
| burstCount: parseInt(document.getElementById('burst-count')?.value) || 5,
|
| burstPause: parseInt(document.getElementById('burst-pause')?.value) || 300,
|
| longBreakCount: parseInt(document.getElementById('long-break-count')?.value) || 15,
|
| longBreakPause: parseInt(document.getElementById('long-break-pause')?.value) || 900
|
| };
|
|
|
| const serialized = JSON.stringify(intervals);
|
| const concatString = `${serialized}:${RULES_INTEGRITY_SALT}`;
|
| let signature = "fallback_rules_sig_256_" + concatString.length;
|
|
|
| if (typeof FritreeCrypto !== 'undefined' && typeof FritreeCrypto.signReceipt === 'function') {
|
| signature = await FritreeCrypto.signReceipt(
|
| "STEALTH_COOLDOWN_V3",
|
| concatString.length,
|
| "intervals_signature_256",
|
| concatString,
|
| RULES_INTEGRITY_SALT
|
| );
|
| }
|
|
|
| await FritreeStorage.set('local_sleep_intervals', intervals);
|
| await FritreeStorage.set('local_sleep_intervals_sig_256', signature);
|
| }
|
|
|
| async function loadDelayIntervalSettings() {
|
| const intervals = await FritreeStorage.get('local_sleep_intervals', {
|
| mode: "continuous", min: 60, max: 120, fixed: 60, burstCount: 5, burstPause: 300, longBreakCount: 15, longBreakPause: 900
|
| });
|
|
|
| const setVal = (id, val) => { const el = document.getElementById(id); if (el) el.value = val; };
|
|
|
| setVal('delay-mode', intervals.mode || 'continuous');
|
| setVal('delay-min', intervals.min !== undefined ? intervals.min : 60);
|
| setVal('delay-max', intervals.max !== undefined ? intervals.max : 120);
|
| setVal('delay-fixed', intervals.fixed !== undefined ? intervals.fixed : 60);
|
| setVal('burst-count', intervals.burstCount !== undefined ? intervals.burstCount : 5);
|
| setVal('burst-pause', intervals.burstPause !== undefined ? intervals.burstPause : 300);
|
| setVal('long-break-count', intervals.longBreakCount !== undefined ? intervals.longBreakCount : 15);
|
| setVal('long-break-pause', intervals.longBreakPause !== undefined ? intervals.longBreakPause : 900);
|
|
|
| const delayModeSelect = document.getElementById('delay-mode');
|
| if (delayModeSelect) {
|
| delayModeSelect.dispatchEvent(new Event('change'));
|
| }
|
| }
|
|
|
| document.addEventListener('DOMContentLoaded', () => {
|
| const modeSelect = document.getElementById('delay-mode');
|
| if (modeSelect) {
|
| modeSelect.addEventListener('change', (e) => {
|
| const val = e.target.value;
|
| const containerRandom = document.getElementById('delay-random-container');
|
| const containerFixed = document.getElementById('delay-fixed-container');
|
| const containerBurst = document.getElementById('delay-burst-container');
|
|
|
| if (containerRandom) containerRandom.style.display = (val === 'random' || val === 'continuous') ? 'grid' : 'none';
|
| if (containerFixed) containerFixed.style.display = val === 'fixed' ? 'grid' : 'none';
|
| if (containerBurst) containerBurst.style.display = val === 'burst' ? 'grid' : 'none';
|
| });
|
| }
|
| });
|
|
|
|
|
| global.FritreeRules = {
|
| init: () => {
|
| initDynamicSyncOrchestrator();
|
| loadProtectionSettings();
|
| loadDelayIntervalSettings();
|
| },
|
| loadProtection: loadProtectionSettings,
|
| saveProtection: saveProtectionSettings,
|
| loadDelay: loadDelayIntervalSettings,
|
| saveDelay: saveDelayIntervalSettings,
|
| evaluateRisk: evaluateAntibanRiskScore,
|
| analyzeSpintax: analyzeSpintaxStructure,
|
| updateStats: updateSpintaxStats
|
| };
|
|
|
| if (document.readyState === 'complete' || document.readyState === 'interactive') {
|
| global.FritreeRules.init();
|
| } else {
|
| document.addEventListener('DOMContentLoaded', () => global.FritreeRules.init());
|
| }
|
|
|
| })(typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : this); |