Spaces:
Paused
Paused
Update server.js
Browse files
server.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
/**
|
| 2 |
* ============================================================================
|
| 3 |
-
* ULTIMATE AI BROWSER ENGINE (GOD-MODE) -
|
| 4 |
-
* Architecture: Puppeteer Stealth + WebSocket +
|
| 5 |
* Repository: Senku21230/Browser-Extensions
|
| 6 |
* ============================================================================
|
| 7 |
*/
|
|
@@ -15,7 +15,7 @@ const fs = require('fs');
|
|
| 15 |
const path = require('path');
|
| 16 |
const { execSync } = require('child_process');
|
| 17 |
|
| 18 |
-
// Apply Ultimate Stealth Plugin
|
| 19 |
puppeteer.use(StealthPlugin());
|
| 20 |
|
| 21 |
const app = express();
|
|
@@ -26,560 +26,529 @@ const PORT = process.env.PORT || 3000;
|
|
| 26 |
const DATASET_REPO = "Senku21230/Browser-Extensions";
|
| 27 |
const EXTENSION_PATH = '/tmp/extensions';
|
| 28 |
|
|
|
|
| 29 |
let browser = null;
|
| 30 |
let pages = [];
|
| 31 |
let activePageIndex = 0;
|
| 32 |
let cdpSession = null;
|
| 33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
function syncExtensionsFromDataset() {
|
| 35 |
console.log("[SYSTEM] Initializing Persistent Extension Storage...");
|
| 36 |
const hfToken = process.env.HF_TOKEN;
|
|
|
|
| 37 |
if (!hfToken) {
|
| 38 |
-
console.error("[CRITICAL] HF_TOKEN missing! Cannot pull dataset.");
|
| 39 |
if (!fs.existsSync(EXTENSION_PATH)) fs.mkdirSync(EXTENSION_PATH, { recursive: true });
|
| 40 |
return;
|
| 41 |
}
|
|
|
|
| 42 |
try {
|
| 43 |
-
if (fs.existsSync(EXTENSION_PATH))
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
const cloneCmd = `git clone https://oauth2:${hfToken}@huggingface.co/datasets/${DATASET_REPO} ${EXTENSION_PATH}`;
|
| 45 |
execSync(cloneCmd, { stdio: 'ignore' });
|
| 46 |
-
console.log("[STORAGE] Extensions synced!");
|
| 47 |
} catch (error) {
|
| 48 |
-
console.error("[ERROR] Failed to sync dataset.");
|
| 49 |
if (!fs.existsSync(EXTENSION_PATH)) fs.mkdirSync(EXTENSION_PATH, { recursive: true });
|
| 50 |
}
|
| 51 |
}
|
| 52 |
|
| 53 |
/**
|
| 54 |
* ============================================================================
|
| 55 |
-
* AI TOOL REGISTRY
|
| 56 |
* ============================================================================
|
| 57 |
*/
|
| 58 |
const ai_tools = [
|
| 59 |
-
// --- 1.
|
| 60 |
{
|
| 61 |
name: "basic_navigation_controller",
|
| 62 |
-
description: "CORE INTERACTION MASTER:
|
| 63 |
},
|
| 64 |
-
|
| 65 |
-
// --- 2. THE GOD-TIER CYBER TOOLS (DETAILED) ---
|
| 66 |
{
|
| 67 |
name: "deep_network_v8_interceptor",
|
| 68 |
-
description: "CRITICAL NETWORK HACK:
|
| 69 |
},
|
| 70 |
{
|
| 71 |
name: "visual_ocr_canvas_piercer",
|
| 72 |
-
description: "ADVANCED VISION ENGINE:
|
| 73 |
},
|
| 74 |
{
|
| 75 |
name: "deep_shadow_dom_piercer",
|
| 76 |
-
description: "DOM PENETRATION PROTOCOL:
|
| 77 |
},
|
| 78 |
{
|
| 79 |
name: "auto_api_reverse_engineering",
|
| 80 |
-
description: "BACKGROUND API SCANNER:
|
| 81 |
},
|
| 82 |
{
|
| 83 |
name: "network_payload_modifier",
|
| 84 |
-
description: "REAL-TIME TRAFFIC MUTATION:
|
| 85 |
},
|
| 86 |
{
|
| 87 |
name: "custom_extension_loader",
|
| 88 |
-
description: "PERSISTENT STORAGE INJECTOR:
|
| 89 |
},
|
| 90 |
{
|
| 91 |
name: "start_recording",
|
| 92 |
-
description: "MEDIA ENGINE (START): Initializes
|
| 93 |
},
|
| 94 |
{
|
| 95 |
name: "stop_recording",
|
| 96 |
-
description: "MEDIA ENGINE (STOP): Safely terminates the
|
| 97 |
-
}
|
| 98 |
-
];
|
| 99 |
-
|
| 100 |
-
// Part 1B will continue with the remaining God-Tier tools and the next batch of explicitly separated core tools...
|
| 101 |
-
// --- 3. THE REMAINING GOD-TIER CYBER TOOLS (CONTINUED) ---
|
| 102 |
{
|
| 103 |
name: "auto_captcha_solver",
|
| 104 |
-
description: "SECURITY BYPASS:
|
| 105 |
},
|
| 106 |
{
|
| 107 |
name: "file_manager_io",
|
| 108 |
-
description: "STORAGE I/O
|
| 109 |
},
|
| 110 |
{
|
| 111 |
name: "media_inventory",
|
| 112 |
-
description: "SYSTEM MANAGEMENT
|
| 113 |
},
|
| 114 |
{
|
| 115 |
name: "smart_cleanup",
|
| 116 |
-
description: "SYSTEM MANAGEMENT
|
| 117 |
},
|
| 118 |
-
|
| 119 |
-
// --- 4. EXPLICITLY SEPARATED CORE TOOLS (BATCH 1) ---
|
| 120 |
{
|
| 121 |
name: "evaluate_javascript",
|
| 122 |
-
description: "BROWSER CONSOLE: Injects and executes raw JavaScript code
|
| 123 |
},
|
| 124 |
{
|
| 125 |
name: "inject_custom_cookies",
|
| 126 |
-
description: "SESSION HIJACKING
|
| 127 |
},
|
| 128 |
{
|
| 129 |
name: "take_screenshot",
|
| 130 |
-
description: "VISUAL CAPTURE: Captures a high-resolution
|
| 131 |
},
|
| 132 |
{
|
| 133 |
name: "hover_element",
|
| 134 |
-
description: "UI INTERACTION: Simulates
|
| 135 |
},
|
| 136 |
{
|
| 137 |
name: "wait_for_selector",
|
| 138 |
-
description: "EXECUTION DELAY: Pauses AI execution
|
| 139 |
},
|
| 140 |
{
|
| 141 |
name: "get_element_attributes",
|
| 142 |
-
description: "DATA EXTRACTION: Retrieves all HTML attributes (href, src, class, id
|
| 143 |
},
|
| 144 |
{
|
| 145 |
name: "switch_to_iframe",
|
| 146 |
-
description: "CONTEXT SWITCHING: Shifts
|
|
|
|
|
|
|
|
|
|
|
|
|
| 147 |
},
|
| 148 |
{
|
| 149 |
name: "emulate_device_viewport",
|
| 150 |
-
description: "DEVICE SPOOFING: Alters
|
| 151 |
},
|
| 152 |
{
|
| 153 |
name: "set_geolocation",
|
| 154 |
-
description: "HARDWARE SPOOFING: Overrides
|
| 155 |
-
}
|
| 156 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 157 |
{
|
| 158 |
name: "open_new_tab",
|
| 159 |
-
description: "TAB MANAGEMENT: Opens a completely new, blank browser tab and
|
| 160 |
},
|
| 161 |
{
|
| 162 |
name: "close_current_tab",
|
| 163 |
-
description: "TAB MANAGEMENT: Safely closes the currently active browser tab
|
| 164 |
},
|
| 165 |
{
|
| 166 |
name: "get_all_tabs",
|
| 167 |
-
description: "TAB MANAGEMENT: Retrieves a JSON array of all currently open tabs
|
|
|
|
|
|
|
|
|
|
|
|
|
| 168 |
},
|
| 169 |
-
|
| 170 |
-
|
|
|
|
|
|
|
|
|
|
| 171 |
{
|
| 172 |
name: "press_key",
|
| 173 |
-
description: "HARDWARE INPUT: Simulates the physical pressing of a single
|
| 174 |
},
|
| 175 |
{
|
| 176 |
name: "hold_key",
|
| 177 |
-
description: "HARDWARE INPUT: Simulates holding down a modifier key
|
| 178 |
},
|
| 179 |
{
|
| 180 |
name: "mouse_drag_and_drop",
|
| 181 |
-
description: "HARDWARE INPUT:
|
| 182 |
},
|
| 183 |
{
|
| 184 |
name: "right_click",
|
| 185 |
-
description: "HARDWARE INPUT: Simulates a physical right-click on a specific DOM element. Parameter
|
| 186 |
},
|
| 187 |
{
|
| 188 |
name: "double_click",
|
| 189 |
-
description: "HARDWARE INPUT: Simulates a rapid double left-click on an element. Parameter
|
| 190 |
-
},
|
| 191 |
-
|
| 192 |
-
// --- 7. EXPLICITLY SEPARATED CORE TOOLS (BATCH 4: FORM & INPUT HANDLING) ---
|
| 193 |
-
{
|
| 194 |
-
name: "select_dropdown_option",
|
| 195 |
-
description: "FORM CONTROL: Selects a specific <option> inside a native <select> dropdown element. Parameters required: 'selector' (for the select tag) and 'value_or_text' (the item to choose). Bypasses the need to click the dropdown open first."
|
| 196 |
},
|
| 197 |
{
|
| 198 |
-
name: "
|
| 199 |
-
description: "
|
| 200 |
-
},
|
| 201 |
-
{
|
| 202 |
-
name: "uncheck_checkbox",
|
| 203 |
-
description: "FORM CONTROL: Forces a checkbox or radio button into an 'unchecked' state. Parameter required: 'selector'."
|
| 204 |
},
|
| 205 |
-
|
| 206 |
-
// --- 8. EXPLICITLY SEPARATED CORE TOOLS (BATCH 5: WAIT & SYNC EVENTS) ---
|
| 207 |
{
|
| 208 |
-
name: "
|
| 209 |
-
description: "
|
| 210 |
},
|
| 211 |
{
|
| 212 |
-
name: "
|
| 213 |
-
description: "
|
| 214 |
},
|
| 215 |
{
|
| 216 |
-
name: "
|
| 217 |
-
description: "
|
| 218 |
},
|
| 219 |
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
},
|
| 225 |
-
{
|
| 226 |
-
name: "clear_cache_and_cookies",
|
| 227 |
-
description: "BROWSER STATE: Completely wipes all active cookies, LocalStorage, and SessionStorage for the current domain. Essential for testing incognito-like states or logging out of accounts forcefully without finding the logout button."
|
| 228 |
-
}
|
| 229 |
-
// --- 10. EXPLICITLY SEPARATED CORE TOOLS (BATCH 7: ADVANCED EXTRACTION) ---
|
| 230 |
{
|
| 231 |
-
name: "
|
| 232 |
-
description: "
|
| 233 |
},
|
| 234 |
{
|
| 235 |
-
name: "
|
| 236 |
-
description: "
|
| 237 |
},
|
| 238 |
{
|
| 239 |
-
name: "
|
| 240 |
-
description: "
|
| 241 |
},
|
| 242 |
{
|
| 243 |
-
name: "
|
| 244 |
-
description: "
|
| 245 |
},
|
| 246 |
{
|
| 247 |
-
name: "
|
| 248 |
-
description: "
|
| 249 |
},
|
| 250 |
-
|
| 251 |
-
// --- 11. EXPLICITLY SEPARATED CORE TOOLS (BATCH 8: VIEWPORT & FOCUS CONTROL) ---
|
| 252 |
{
|
| 253 |
-
name: "
|
| 254 |
-
description: "
|
| 255 |
},
|
| 256 |
{
|
| 257 |
-
name: "
|
| 258 |
-
description: "DOM
|
| 259 |
},
|
| 260 |
{
|
| 261 |
-
name: "
|
| 262 |
-
description: "
|
| 263 |
},
|
| 264 |
{
|
| 265 |
-
name: "
|
| 266 |
-
description: "
|
| 267 |
},
|
| 268 |
{
|
| 269 |
-
name: "
|
| 270 |
-
description: "
|
| 271 |
},
|
| 272 |
-
|
| 273 |
-
// --- 12. EXPLICITLY SEPARATED CORE TOOLS (BATCH 9: NETWORK & AUTH OVERRIDES) ---
|
| 274 |
{
|
| 275 |
-
name: "
|
| 276 |
-
description: "
|
| 277 |
},
|
| 278 |
{
|
| 279 |
-
name: "
|
| 280 |
-
description: "
|
| 281 |
},
|
| 282 |
{
|
| 283 |
-
name: "
|
| 284 |
-
description: "
|
| 285 |
},
|
| 286 |
{
|
| 287 |
-
name: "
|
| 288 |
-
description: "
|
| 289 |
},
|
| 290 |
-
|
| 291 |
-
// --- 13. EXPLICITLY SEPARATED CORE TOOLS (BATCH 10: STORAGE & CACHE HACKING) ---
|
| 292 |
{
|
| 293 |
name: "get_cookies",
|
| 294 |
-
description: "SESSION THEFT: Retrieves all active cookies currently accessible by the browser for the current domain.
|
| 295 |
},
|
| 296 |
{
|
| 297 |
name: "delete_cookie",
|
| 298 |
-
description: "STATE MANIPULATION: Forcefully deletes a specific cookie by its name. Parameter
|
| 299 |
},
|
| 300 |
{
|
| 301 |
name: "clear_local_storage",
|
| 302 |
-
description: "STATE MANIPULATION: Executes 'localStorage.clear()' to wipe all persistent frontend data
|
| 303 |
},
|
| 304 |
{
|
| 305 |
name: "clear_session_storage",
|
| 306 |
-
description: "STATE MANIPULATION: Executes 'sessionStorage.clear()' to wipe temporary frontend data.
|
| 307 |
},
|
| 308 |
{
|
| 309 |
name: "set_local_storage_item",
|
| 310 |
-
description: "STATE INJECTION: Forcefully injects a key-value pair directly into the browser's LocalStorage. Parameters
|
| 311 |
},
|
| 312 |
{
|
| 313 |
name: "set_session_storage_item",
|
| 314 |
-
description: "STATE INJECTION: Forcefully injects a key-value pair directly into the browser's SessionStorage. Parameters
|
| 315 |
},
|
| 316 |
{
|
| 317 |
name: "get_local_storage_item",
|
| 318 |
-
description: "STATE THEFT: Reads and returns the value of a specific key from the browser's LocalStorage. Parameter
|
| 319 |
-
}
|
| 320 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 321 |
{
|
| 322 |
name: "extract_audio_video_sources",
|
| 323 |
-
description: "DATA EXTRACTION: Scans the live DOM specifically for <audio> and <video> tags
|
| 324 |
},
|
| 325 |
{
|
| 326 |
name: "play_media",
|
| 327 |
-
description: "MEDIA CONTROL: Forces a specific HTML5 media element
|
| 328 |
},
|
| 329 |
{
|
| 330 |
name: "pause_media",
|
| 331 |
-
description: "MEDIA CONTROL: Forces a specific media element to pause
|
| 332 |
},
|
| 333 |
{
|
| 334 |
name: "mute_media",
|
| 335 |
-
description: "MEDIA CONTROL: Sets the 'muted' property of a media element to true. Parameter
|
| 336 |
},
|
| 337 |
{
|
| 338 |
name: "set_media_playback_rate",
|
| 339 |
-
description: "MEDIA CONTROL: Modifies the playback speed of a media element. Parameters
|
| 340 |
},
|
| 341 |
-
|
| 342 |
-
// --- 15. EXPLICITLY SEPARATED CORE TOOLS (BATCH 12: LIVE DOM MUTATION & INJECTION) ---
|
| 343 |
{
|
| 344 |
name: "remove_element",
|
| 345 |
-
description: "DOM MUTATION: Completely rips a specific HTML element out of the live DOM using '.remove()'. Parameter
|
| 346 |
},
|
| 347 |
{
|
| 348 |
name: "inject_custom_css",
|
| 349 |
-
description: "DOM MUTATION: Injects a raw block of CSS rules directly into the page's <head>. Parameter
|
| 350 |
},
|
| 351 |
{
|
| 352 |
name: "change_element_text",
|
| 353 |
-
description: "DOM MUTATION: Overwrites the innerText of a specific element dynamically. Parameters
|
| 354 |
},
|
| 355 |
{
|
| 356 |
name: "set_element_attribute",
|
| 357 |
-
description: "DOM MUTATION: Forces a new value into a specific HTML attribute. Parameters
|
| 358 |
},
|
| 359 |
{
|
| 360 |
name: "remove_element_attribute",
|
| 361 |
-
description: "DOM MUTATION: Strips an attribute entirely from an element. Parameters
|
| 362 |
},
|
| 363 |
-
|
| 364 |
-
// --- 16. EXPLICITLY SEPARATED CORE TOOLS (BATCH 13: ADVANCED ENVIRONMENT SPOOFING) ---
|
| 365 |
{
|
| 366 |
name: "spoof_timezone",
|
| 367 |
-
description: "ENVIRONMENT SPOOFING: Overrides the browser's native timezone ID. Parameter
|
| 368 |
},
|
| 369 |
{
|
| 370 |
name: "spoof_language",
|
| 371 |
-
description: "ENVIRONMENT SPOOFING: Modifies the navigator.language and Accept-Language headers. Parameter
|
| 372 |
},
|
| 373 |
{
|
| 374 |
name: "override_permissions",
|
| 375 |
-
description: "ENVIRONMENT SPOOFING: Automatically
|
| 376 |
-
},
|
| 377 |
-
|
| 378 |
-
// --- 17. EXPLICITLY SEPARATED CORE TOOLS (BATCH 14: POPUP & DIALOG CONTROL) ---
|
| 379 |
-
{
|
| 380 |
-
name: "accept_browser_alert",
|
| 381 |
-
description: "DIALOG CONTROL: Pre-configures the browser to automatically click 'OK' or 'Accept' the next time a native JavaScript alert() or confirm() dialog appears. Prevents the AI engine from hanging infinitely when a website throws an unexpected alert."
|
| 382 |
-
},
|
| 383 |
-
{
|
| 384 |
-
name: "dismiss_browser_alert",
|
| 385 |
-
description: "DIALOG CONTROL: Pre-configures the browser to automatically click 'Cancel' or dismiss native JavaScript dialogs. Useful for rejecting 'Are you sure you want to leave this page?' prompts."
|
| 386 |
-
},
|
| 387 |
-
{
|
| 388 |
-
name: "answer_browser_prompt",
|
| 389 |
-
description: "DIALOG CONTROL: Pre-configures the browser to type a specific string into a native JavaScript prompt() dialog and hit accept. Parameter required: 'prompt_text'."
|
| 390 |
-
},
|
| 391 |
-
{
|
| 392 |
-
name: "get_dialog_message",
|
| 393 |
-
description: "DIALOG CONTROL: Extracts and returns the text message displayed inside the currently active JavaScript popup dialog before it is accepted or dismissed. Essential for reading error codes sent via alerts."
|
| 394 |
-
}
|
| 395 |
-
// --- 18. EXPLICITLY SEPARATED CORE TOOLS (BATCH 15: ADVANCED IFRAME & CONTEXT) ---
|
| 396 |
-
{
|
| 397 |
-
name: "exit_iframe",
|
| 398 |
-
description: "CONTEXT SWITCHING: Returns the Puppeteer execution context from a nested iframe back to the main document (top-level frame). Essential after finishing tasks inside a payment widget or captcha box so the AI can resume interacting with the main website."
|
| 399 |
-
},
|
| 400 |
-
{
|
| 401 |
-
name: "wait_for_iframe",
|
| 402 |
-
description: "EXECUTION SYNC: Pauses AI execution until a specific iframe dynamically loads and becomes fully available in the DOM. Parameter required: 'iframe_selector' or 'iframe_name'. Crucial for third-party embeds that load asynchronously."
|
| 403 |
-
},
|
| 404 |
-
|
| 405 |
-
// --- 19. EXPLICITLY SEPARATED CORE TOOLS (BATCH 16: ADVANCED HUMAN MIMICRY) ---
|
| 406 |
-
{
|
| 407 |
-
name: "mouse_move_human_path",
|
| 408 |
-
description: "ANTI-BOT BYPASS: Moves the mouse cursor to a specific X/Y coordinate using mathematically generated Bezier curves, variable speeds, and slight overshoots instead of a straight linear line. Parameters required: 'target_x' and 'target_y'. Highly effective at bypassing behavioral bot-detection systems like reCAPTCHA v3 or Datadome."
|
| 409 |
-
},
|
| 410 |
-
{
|
| 411 |
-
name: "mouse_scroll_hardware",
|
| 412 |
-
description: "ANTI-BOT BYPASS: Simulates the physical hardware ticks of a mouse scroll wheel rather than using JavaScript window.scrollBy(). Parameters required: 'delta_x' and 'delta_y'. Bypasses listeners that specifically check for synthetic scroll events."
|
| 413 |
-
},
|
| 414 |
-
{
|
| 415 |
-
name: "type_text_human_like",
|
| 416 |
-
description: "ANTI-BOT BYPASS: Types a given string into an active input field but introduces randomized delays (e.g., 50ms to 150ms) between each keystroke to flawlessly mimic human typing rhythms. Parameters required: 'selector' and 'text_to_type'."
|
| 417 |
-
},
|
| 418 |
-
{
|
| 419 |
-
name: "press_keyboard_shortcut",
|
| 420 |
-
description: "HARDWARE INPUT: Executes multi-key combination shortcuts simultaneously. Parameter required: 'keys_array' (e.g., ['Control', 'Shift', 'I'] or ['Control', 'C']). Perfect for triggering hidden developer menus or executing native OS copy-paste commands within web editors."
|
| 421 |
},
|
| 422 |
-
|
| 423 |
-
// --- 20. EXPLICITLY SEPARATED CORE TOOLS (BATCH 17: ENVIRONMENT & THROTTLING) ---
|
| 424 |
{
|
| 425 |
name: "emulate_network_conditions",
|
| 426 |
-
description: "ENVIRONMENT SPOOFING: Forces the browser to simulate specific network speeds
|
| 427 |
},
|
| 428 |
{
|
| 429 |
name: "set_cpu_throttling",
|
| 430 |
-
description: "ENVIRONMENT SPOOFING: Artificially slows down the V8 JavaScript engine execution speed. Parameter
|
| 431 |
},
|
| 432 |
{
|
| 433 |
name: "emulate_color_scheme",
|
| 434 |
-
description: "ENVIRONMENT SPOOFING: Forces the browser to request
|
| 435 |
},
|
| 436 |
{
|
| 437 |
name: "emulate_media_type",
|
| 438 |
-
description: "ENVIRONMENT SPOOFING: Changes the CSS media type of the page
|
| 439 |
},
|
| 440 |
-
|
| 441 |
-
// --- 21. EXPLICITLY SEPARATED CORE TOOLS (BATCH 18: SECURITY & EVENT OVERRIDES) ---
|
| 442 |
{
|
| 443 |
-
name: "
|
| 444 |
-
description: "
|
| 445 |
-
},
|
| 446 |
-
{
|
| 447 |
-
name: "ignore_https_errors",
|
| 448 |
-
description: "SECURITY OVERRIDE: Instructs the browser session to completely bypass 'NET::ERR_CERT_AUTHORITY_INVALID' or expired SSL certificate warnings, allowing the AI to forcefully navigate into insecure or local development environments."
|
| 449 |
-
},
|
| 450 |
-
|
| 451 |
-
// --- 22. EXPLICITLY SEPARATED CORE TOOLS (BATCH 19: DEEP DATA EXTRACTION) ---
|
| 452 |
-
{
|
| 453 |
-
name: "extract_json_ld",
|
| 454 |
-
description: "DATA EXTRACTION: Scans the document for <script type='application/ld+json'> tags and parses them into a structured JSON array. Instantly extracts high-value SEO microdata like product prices, ratings, article authors, and business addresses without needing to parse the visible DOM."
|
| 455 |
},
|
|
|
|
| 456 |
{
|
| 457 |
-
name: "
|
| 458 |
-
description: "
|
| 459 |
},
|
| 460 |
{
|
| 461 |
-
name: "
|
| 462 |
-
description: "
|
| 463 |
},
|
| 464 |
-
|
| 465 |
-
// --- 23. EXPLICITLY SEPARATED CORE TOOLS (BATCH 20: RESOURCE ABORTING & DEBUGGING) ---
|
| 466 |
{
|
| 467 |
-
name: "
|
| 468 |
-
description: "
|
| 469 |
},
|
| 470 |
{
|
| 471 |
-
name: "
|
| 472 |
-
description: "
|
| 473 |
},
|
| 474 |
{
|
| 475 |
-
name: "
|
| 476 |
-
description: "
|
| 477 |
},
|
| 478 |
{
|
| 479 |
-
name: "
|
| 480 |
-
description: "
|
| 481 |
},
|
| 482 |
-
|
| 483 |
-
name: "highlight_element",
|
| 484 |
-
description: "VISUAL DEBUGGING: Injects inline CSS to draw a thick, glowing red border around a specific element. Parameter required: 'selector'. Extremely useful when paired with 'take_screenshot' so the user can visually verify exactly which element the AI is targeting."
|
| 485 |
-
}
|
| 486 |
-
// --- 24. EXPLICITLY SEPARATED CORE TOOLS (BATCH 21: BASIC STATE & NAVIGATION) ---
|
| 487 |
{
|
| 488 |
name: "get_current_url",
|
| 489 |
-
description: "NAVIGATION STATE: Instantly retrieves and returns the absolute URL currently loaded in the active tab.
|
| 490 |
},
|
| 491 |
{
|
| 492 |
name: "reload_page",
|
| 493 |
-
description: "NAVIGATION STATE: Triggers a reload of the active document. Parameter optional: 'ignore_cache'
|
| 494 |
},
|
| 495 |
{
|
| 496 |
name: "navigate_back",
|
| 497 |
-
description: "NAVIGATION STATE: Simulates clicking the browser's native 'Back' button
|
| 498 |
},
|
| 499 |
{
|
| 500 |
name: "navigate_forward",
|
| 501 |
description: "NAVIGATION STATE: Simulates clicking the browser's native 'Forward' button."
|
| 502 |
},
|
| 503 |
-
|
| 504 |
-
// --- 25. EXPLICITLY SEPARATED CORE TOOLS (BATCH 22: VALIDATION & TEXT) ---
|
| 505 |
-
{
|
| 506 |
-
name: "check_element_exists",
|
| 507 |
-
description: "DOM VALIDATION: Silently verifies if a specific CSS/XPath selector exists in the DOM structure. Parameter required: 'selector'. Returns a boolean (true/false) without throwing execution errors if the element is absent. Perfect for conditional AI logic."
|
| 508 |
-
},
|
| 509 |
{
|
| 510 |
-
name: "
|
| 511 |
-
description: "
|
| 512 |
-
},
|
| 513 |
-
{
|
| 514 |
-
name: "get_element_text",
|
| 515 |
-
description: "DATA EXTRACTION: Extracts and returns the clean, trimmed 'innerText' or 'textContent' of a specific HTML element. Parameter required: 'selector'. Used for reading specific numbers, titles, or status messages without extracting the whole page."
|
| 516 |
-
},
|
| 517 |
-
{
|
| 518 |
-
name: "get_element_html",
|
| 519 |
-
description: "DATA EXTRACTION: Extracts and returns the raw 'outerHTML' string of a specific HTML element. Parameter required: 'selector'. Useful for parsing a localized block of complex nested tags."
|
| 520 |
},
|
| 521 |
-
|
| 522 |
-
// --- 26. EXPLICITLY SEPARATED CORE TOOLS (BATCH 23: NATIVE FORM & FILE HANDLING) ---
|
| 523 |
{
|
| 524 |
-
name: "
|
| 525 |
-
description: "
|
| 526 |
},
|
| 527 |
{
|
| 528 |
-
name: "
|
| 529 |
-
description: "
|
| 530 |
},
|
| 531 |
{
|
| 532 |
-
name: "
|
| 533 |
-
description: "
|
| 534 |
},
|
| 535 |
-
|
| 536 |
-
// --- 27. EXPLICITLY SEPARATED CORE TOOLS (BATCH 24: METRICS & QUERYING) ---
|
| 537 |
{
|
| 538 |
-
name: "
|
| 539 |
-
description: "VIEWPORT
|
| 540 |
},
|
| 541 |
{
|
| 542 |
-
name: "
|
| 543 |
-
description: "
|
| 544 |
},
|
| 545 |
{
|
| 546 |
name: "evaluate_xpath_expression",
|
| 547 |
-
description: "ADVANCED QUERYING: Executes
|
| 548 |
},
|
| 549 |
-
|
| 550 |
-
// --- 28. EXPLICITLY SEPARATED CORE TOOLS (BATCH 25: DEEP DEBUGGING & MOBILE) ---
|
| 551 |
{
|
| 552 |
name: "listen_for_console_logs",
|
| 553 |
-
description: "DEBUGGING: Attaches a persistent event listener to capture all 'console.log'
|
| 554 |
},
|
| 555 |
{
|
| 556 |
name: "intercept_websocket_frames",
|
| 557 |
-
description: "NETWORK HACKING: Monitors and captures raw WebSocket message frames
|
| 558 |
},
|
| 559 |
{
|
| 560 |
-
name: "
|
| 561 |
-
description: "
|
| 562 |
}
|
| 563 |
-
];
|
| 564 |
|
| 565 |
-
// END OF TOOL REGISTRY (Total Tools: 113)
|
| 566 |
-
// ============================================================================
|
| 567 |
/**
|
| 568 |
* ============================================================================
|
| 569 |
-
*
|
| 570 |
-
* Core Browser Launch, CDP Streaming, and Tool Execution Dispatcher
|
| 571 |
-
* ============================================================================
|
| 572 |
-
*/
|
| 573 |
-
|
| 574 |
-
/**
|
| 575 |
-
* ============================================================================
|
| 576 |
-
* 1. BROWSER INITIALIZATION & CONTEXT MANAGEMENT
|
| 577 |
* ============================================================================
|
| 578 |
*/
|
| 579 |
async function initBrowser() {
|
| 580 |
console.log("[SYSTEM] Booting God-Mode Stealth Engine...");
|
| 581 |
|
| 582 |
-
// Sync extensions
|
| 583 |
syncExtensionsFromDataset();
|
| 584 |
|
| 585 |
const launchArgs = [
|
|
@@ -588,11 +557,10 @@ async function initBrowser() {
|
|
| 588 |
'--disable-dev-shm-usage',
|
| 589 |
'--disable-blink-features=AutomationControlled',
|
| 590 |
'--window-size=1280,800',
|
| 591 |
-
'--disable-web-security',
|
| 592 |
-
'--disable-features=IsolateOrigins,site-per-process'
|
| 593 |
];
|
| 594 |
|
| 595 |
-
// Conditionally load extensions if the directory has contents
|
| 596 |
if (fs.existsSync(EXTENSION_PATH) && fs.readdirSync(EXTENSION_PATH).length > 0) {
|
| 597 |
launchArgs.push(`--disable-extensions-except=${EXTENSION_PATH}`);
|
| 598 |
launchArgs.push(`--load-extension=${EXTENSION_PATH}`);
|
|
@@ -601,7 +569,7 @@ async function initBrowser() {
|
|
| 601 |
|
| 602 |
try {
|
| 603 |
browser = await puppeteer.launch({
|
| 604 |
-
headless: 'new',
|
| 605 |
args: launchArgs,
|
| 606 |
ignoreDefaultArgs: ["--enable-automation"]
|
| 607 |
});
|
|
@@ -609,7 +577,6 @@ async function initBrowser() {
|
|
| 609 |
const defaultPage = await browser.newPage();
|
| 610 |
await defaultPage.setViewport({ width: 1280, height: 800 });
|
| 611 |
|
| 612 |
-
// Stealth Overrides for standard navigator properties
|
| 613 |
await defaultPage.evaluateOnNewDocument(() => {
|
| 614 |
Object.defineProperty(navigator, 'webdriver', { get: () => undefined });
|
| 615 |
});
|
|
@@ -619,13 +586,12 @@ async function initBrowser() {
|
|
| 619 |
|
| 620 |
} catch (error) {
|
| 621 |
console.error("[CRITICAL] Failed to launch browser engine:", error);
|
| 622 |
-
process.exit(1);
|
| 623 |
}
|
| 624 |
}
|
| 625 |
|
| 626 |
/**
|
| 627 |
* ============================================================================
|
| 628 |
-
*
|
| 629 |
* ============================================================================
|
| 630 |
*/
|
| 631 |
async function startRealTimeStream(page, ws) {
|
|
@@ -634,28 +600,23 @@ async function startRealTimeStream(page, ws) {
|
|
| 634 |
await cdpSession.detach();
|
| 635 |
}
|
| 636 |
|
| 637 |
-
// Attach directly to the Chrome DevTools Protocol
|
| 638 |
cdpSession = await page.target().createCDPSession();
|
| 639 |
-
|
| 640 |
console.log("[STREAM] CDP Session attached. Initiating Screencast...");
|
| 641 |
|
| 642 |
-
// Start ultra-fast binary streaming optimized for latency
|
| 643 |
await cdpSession.send('Page.startScreencast', {
|
| 644 |
format: 'jpeg',
|
| 645 |
-
quality: 65,
|
| 646 |
everyNthFrame: 1
|
| 647 |
});
|
| 648 |
|
| 649 |
cdpSession.on('Page.screencastFrame', async (frameObject) => {
|
| 650 |
if (ws.readyState === WebSocket.OPEN) {
|
| 651 |
-
// Push raw base64 frame directly to client UI
|
| 652 |
ws.send(JSON.stringify({
|
| 653 |
type: 'stream_frame',
|
| 654 |
data: frameObject.data,
|
| 655 |
sessionId: frameObject.sessionId
|
| 656 |
}));
|
| 657 |
|
| 658 |
-
// Acknowledge frame to keep the buffer flowing
|
| 659 |
await cdpSession.send('Page.screencastFrameAck', {
|
| 660 |
sessionId: frameObject.sessionId
|
| 661 |
}).catch(() => {});
|
|
@@ -668,21 +629,20 @@ async function startRealTimeStream(page, ws) {
|
|
| 668 |
|
| 669 |
/**
|
| 670 |
* ============================================================================
|
| 671 |
-
*
|
| 672 |
* ============================================================================
|
| 673 |
*/
|
| 674 |
async function executeAITool(toolName, parameters) {
|
| 675 |
if (!browser || pages.length === 0) {
|
| 676 |
-
return { status: "error", message: "
|
| 677 |
}
|
| 678 |
|
| 679 |
const activePage = pages[activePageIndex].page;
|
| 680 |
-
console.log(`[EXECUTE]
|
| 681 |
|
| 682 |
try {
|
| 683 |
switch (toolName) {
|
| 684 |
|
| 685 |
-
// --- CORE MASTER TOOL ---
|
| 686 |
case "basic_navigation_controller":
|
| 687 |
const { action_type, url, selector, text_to_type } = parameters;
|
| 688 |
if (action_type === "navigate") {
|
|
@@ -694,7 +654,7 @@ async function executeAITool(toolName, parameters) {
|
|
| 694 |
return { status: "success", action: "clicked" };
|
| 695 |
} else if (action_type === "type") {
|
| 696 |
await activePage.waitForSelector(selector, { visible: true });
|
| 697 |
-
await activePage.type(selector, text_to_type, { delay: 50 });
|
| 698 |
return { status: "success", action: "typed" };
|
| 699 |
} else if (action_type === "extract") {
|
| 700 |
const html = await activePage.content();
|
|
@@ -702,41 +662,19 @@ async function executeAITool(toolName, parameters) {
|
|
| 702 |
}
|
| 703 |
break;
|
| 704 |
|
| 705 |
-
// --- GOD-TIER: NETWORK REVERSE ENGINEERING ---
|
| 706 |
-
case "auto_api_reverse_engineering":
|
| 707 |
-
console.log("[HACK] Attaching deep network listener...");
|
| 708 |
-
const endpoints = [];
|
| 709 |
-
activePage.on('request', request => {
|
| 710 |
-
if (['xhr', 'fetch'].includes(request.resourceType())) {
|
| 711 |
-
endpoints.push({
|
| 712 |
-
url: request.url(),
|
| 713 |
-
method: request.method(),
|
| 714 |
-
headers: request.headers()
|
| 715 |
-
});
|
| 716 |
-
}
|
| 717 |
-
});
|
| 718 |
-
return { status: "success", message: "Network listeners attached in background. Gathering data..." };
|
| 719 |
-
|
| 720 |
-
// --- GOD-TIER: SHADOW DOM PIERCER ---
|
| 721 |
case "deep_shadow_dom_piercer":
|
| 722 |
console.log("[HACK] Injecting Shadow DOM override script...");
|
| 723 |
const shadowData = await activePage.evaluate(() => {
|
| 724 |
-
// Deep recursive extraction logic
|
| 725 |
function traverseShadows(node) {
|
| 726 |
let content = node.outerHTML || '';
|
| 727 |
-
if (node.shadowRoot)
|
| 728 |
-
|
| 729 |
-
}
|
| 730 |
-
node.childNodes.forEach(child => {
|
| 731 |
-
content += traverseShadows(child);
|
| 732 |
-
});
|
| 733 |
return content;
|
| 734 |
}
|
| 735 |
return traverseShadows(document.body);
|
| 736 |
});
|
| 737 |
return { status: "success", data: shadowData.substring(0, 5000) };
|
| 738 |
|
| 739 |
-
// --- GOD-TIER: V8 NETWORK INTERCEPTOR ---
|
| 740 |
case "deep_network_v8_interceptor":
|
| 741 |
console.log("[HACK] Hooking into CDP Network domain...");
|
| 742 |
const session = await activePage.target().createCDPSession();
|
|
@@ -747,63 +685,53 @@ async function executeAITool(toolName, parameters) {
|
|
| 747 |
if (params.request.headers['Authorization'] || params.request.headers['authorization']) {
|
| 748 |
resolve({
|
| 749 |
status: "success",
|
| 750 |
-
message: "Authorization Bearer Token Intercepted!",
|
| 751 |
url: params.request.url,
|
| 752 |
-
headers: params.request.headers,
|
| 753 |
raw_curl: `curl -X ${params.request.method} '${params.request.url}' -H 'Authorization: ${params.request.headers['Authorization'] || params.request.headers['authorization']}'`
|
| 754 |
});
|
| 755 |
}
|
| 756 |
});
|
| 757 |
-
|
| 758 |
-
setTimeout(() => resolve({ status: "timeout", message: "No secure tokens found in the last 10 seconds." }), 10000);
|
| 759 |
});
|
| 760 |
|
| 761 |
-
// --- CORE: JAVASCRIPT EVALUATION ---
|
| 762 |
-
case "evaluate_javascript":
|
| 763 |
-
const jsResult = await activePage.evaluate(parameters.js_code_string);
|
| 764 |
-
return { status: "success", data: jsResult };
|
| 765 |
-
|
| 766 |
-
// --- CORE: VISUAL CAPTURE ---
|
| 767 |
case "take_screenshot":
|
| 768 |
const screenshotPath = path.join(__dirname, 'public', `screenshot_${Date.now()}.png`);
|
| 769 |
await activePage.screenshot({ path: screenshotPath, fullPage: parameters.full_page || false });
|
| 770 |
return { status: "success", url: `/public/${path.basename(screenshotPath)}` };
|
| 771 |
|
| 772 |
-
// --- TAB MANAGEMENT ---
|
| 773 |
case "open_new_tab":
|
| 774 |
const newPage = await browser.newPage();
|
| 775 |
await newPage.setViewport({ width: 1280, height: 800 });
|
| 776 |
const tabId = Date.now();
|
| 777 |
pages.push({ id: tabId, page: newPage, title: "New Tab" });
|
| 778 |
-
activePageIndex = pages.length - 1;
|
| 779 |
return { status: "success", tab_id: tabId };
|
| 780 |
|
| 781 |
-
//
|
| 782 |
default:
|
| 783 |
-
console.warn(`[WARNING] Tool '${toolName}'
|
| 784 |
-
return { status: "pending", message: `Tool ${toolName} registered
|
| 785 |
}
|
| 786 |
} catch (error) {
|
| 787 |
-
console.error(`[TOOL ERROR]
|
| 788 |
return { status: "error", message: error.message };
|
| 789 |
}
|
| 790 |
}
|
| 791 |
/**
|
| 792 |
* ============================================================================
|
| 793 |
* ULTIMATE AI BROWSER ENGINE (GOD-MODE) - PART 3
|
| 794 |
-
*
|
| 795 |
* ============================================================================
|
| 796 |
*/
|
| 797 |
|
| 798 |
/**
|
| 799 |
* ============================================================================
|
| 800 |
-
*
|
| 801 |
* ============================================================================
|
| 802 |
*/
|
| 803 |
wss.on('connection', async (ws) => {
|
| 804 |
-
console.log("[WS] Secure
|
| 805 |
|
| 806 |
-
//
|
| 807 |
if (pages.length > 0 && pages[activePageIndex]) {
|
| 808 |
await startRealTimeStream(pages[activePageIndex].page, ws);
|
| 809 |
}
|
|
@@ -812,98 +740,108 @@ wss.on('connection', async (ws) => {
|
|
| 812 |
try {
|
| 813 |
const payload = JSON.parse(message);
|
| 814 |
|
| 815 |
-
//
|
| 816 |
if (payload.type === 'switch_tab') {
|
| 817 |
const targetIndex = pages.findIndex(p => p.id === payload.tabId);
|
| 818 |
if (targetIndex !== -1) {
|
| 819 |
activePageIndex = targetIndex;
|
| 820 |
await pages[activePageIndex].page.bringToFront();
|
| 821 |
await startRealTimeStream(pages[activePageIndex].page, ws);
|
| 822 |
-
console.log(`[WS]
|
| 823 |
}
|
| 824 |
}
|
| 825 |
|
| 826 |
-
//
|
| 827 |
if (payload.type === 'new_tab') {
|
| 828 |
const newPage = await browser.newPage();
|
| 829 |
await newPage.setViewport({ width: 1280, height: 800 });
|
| 830 |
-
|
|
|
|
|
|
|
| 831 |
activePageIndex = pages.length - 1;
|
|
|
|
| 832 |
await newPage.goto('https://www.google.com', { waitUntil: 'domcontentloaded' });
|
| 833 |
await startRealTimeStream(newPage, ws);
|
| 834 |
-
console.log(`[WS] New tab initialized. ID: ${
|
| 835 |
-
}
|
| 836 |
-
|
| 837 |
-
// Handle raw mouse/keyboard events from UI overlay (if implemented)
|
| 838 |
-
if (payload.type === 'input_action') {
|
| 839 |
-
// Future expansion: Route UI clicks directly to puppeteer
|
| 840 |
}
|
| 841 |
|
| 842 |
} catch (error) {
|
| 843 |
-
console.error("[WS ERROR]
|
| 844 |
}
|
| 845 |
});
|
| 846 |
|
| 847 |
ws.on('close', () => {
|
| 848 |
-
console.log("[WS]
|
| 849 |
-
if (cdpSession) {
|
| 850 |
-
cdpSession.detach().catch(() => {});
|
| 851 |
-
}
|
| 852 |
});
|
| 853 |
});
|
| 854 |
|
| 855 |
/**
|
| 856 |
* ============================================================================
|
| 857 |
-
*
|
| 858 |
* ============================================================================
|
| 859 |
*/
|
| 860 |
|
| 861 |
-
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 862 |
app.get('/live', (req, res) => {
|
| 863 |
-
const
|
| 864 |
-
if (fs.existsSync(
|
| 865 |
-
res.sendFile(
|
| 866 |
} else {
|
| 867 |
-
res.status(404).send("UI Dashboard
|
| 868 |
}
|
| 869 |
});
|
| 870 |
|
| 871 |
-
/
|
| 872 |
-
|
|
|
|
|
|
|
| 873 |
app.post('/api/execute', async (req, res) => {
|
| 874 |
const { tool_name, parameters } = req.body;
|
| 875 |
|
| 876 |
if (!tool_name) {
|
| 877 |
-
return res.status(400).json({ error: "
|
| 878 |
}
|
| 879 |
|
| 880 |
-
|
| 881 |
-
|
| 882 |
-
res.json(result);
|
| 883 |
});
|
| 884 |
|
| 885 |
-
/
|
|
|
|
|
|
|
|
|
|
| 886 |
app.get('/status', (req, res) => {
|
| 887 |
res.json({
|
| 888 |
-
|
| 889 |
-
|
| 890 |
active_tabs: pages.length,
|
| 891 |
-
|
| 892 |
-
|
| 893 |
});
|
| 894 |
});
|
| 895 |
|
| 896 |
/**
|
| 897 |
* ============================================================================
|
| 898 |
-
*
|
| 899 |
* ============================================================================
|
| 900 |
*/
|
| 901 |
server.listen(PORT, async () => {
|
| 902 |
-
console.log(`\n
|
| 903 |
-
console.log(`[
|
| 904 |
-
console.log(`[
|
| 905 |
-
console.log(`
|
|
|
|
| 906 |
|
| 907 |
-
// Boot the browser engine immediately
|
| 908 |
await initBrowser();
|
| 909 |
});
|
|
|
|
| 1 |
/**
|
| 2 |
* ============================================================================
|
| 3 |
+
* ULTIMATE AI BROWSER ENGINE (GOD-MODE) - COMPLETE SERVER.JS
|
| 4 |
+
* Architecture: Puppeteer Stealth + WebSocket + Advanced API Reversing
|
| 5 |
* Repository: Senku21230/Browser-Extensions
|
| 6 |
* ============================================================================
|
| 7 |
*/
|
|
|
|
| 15 |
const path = require('path');
|
| 16 |
const { execSync } = require('child_process');
|
| 17 |
|
| 18 |
+
// Apply Ultimate Stealth Plugin to bypass Cloudflare/Datadome
|
| 19 |
puppeteer.use(StealthPlugin());
|
| 20 |
|
| 21 |
const app = express();
|
|
|
|
| 26 |
const DATASET_REPO = "Senku21230/Browser-Extensions";
|
| 27 |
const EXTENSION_PATH = '/tmp/extensions';
|
| 28 |
|
| 29 |
+
// Global State Management
|
| 30 |
let browser = null;
|
| 31 |
let pages = [];
|
| 32 |
let activePageIndex = 0;
|
| 33 |
let cdpSession = null;
|
| 34 |
|
| 35 |
+
/**
|
| 36 |
+
* ============================================================================
|
| 37 |
+
* 1. MAGIC DATASET SYNC MECHANISM
|
| 38 |
+
* ============================================================================
|
| 39 |
+
*/
|
| 40 |
function syncExtensionsFromDataset() {
|
| 41 |
console.log("[SYSTEM] Initializing Persistent Extension Storage...");
|
| 42 |
const hfToken = process.env.HF_TOKEN;
|
| 43 |
+
|
| 44 |
if (!hfToken) {
|
| 45 |
+
console.error("[CRITICAL WARNING] HF_TOKEN missing! Cannot pull private dataset.");
|
| 46 |
if (!fs.existsSync(EXTENSION_PATH)) fs.mkdirSync(EXTENSION_PATH, { recursive: true });
|
| 47 |
return;
|
| 48 |
}
|
| 49 |
+
|
| 50 |
try {
|
| 51 |
+
if (fs.existsSync(EXTENSION_PATH)) {
|
| 52 |
+
fs.rmSync(EXTENSION_PATH, { recursive: true, force: true });
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
console.log(`[STORAGE] Connecting to private dataset: ${DATASET_REPO}...`);
|
| 56 |
const cloneCmd = `git clone https://oauth2:${hfToken}@huggingface.co/datasets/${DATASET_REPO} ${EXTENSION_PATH}`;
|
| 57 |
execSync(cloneCmd, { stdio: 'ignore' });
|
| 58 |
+
console.log("[STORAGE] Extensions successfully synced to working directory!");
|
| 59 |
} catch (error) {
|
| 60 |
+
console.error("[ERROR] Failed to sync dataset. Proceeding with empty folder.");
|
| 61 |
if (!fs.existsSync(EXTENSION_PATH)) fs.mkdirSync(EXTENSION_PATH, { recursive: true });
|
| 62 |
}
|
| 63 |
}
|
| 64 |
|
| 65 |
/**
|
| 66 |
* ============================================================================
|
| 67 |
+
* 2. AI TOOL REGISTRY (THE MASTER BRAIN - PART A)
|
| 68 |
* ============================================================================
|
| 69 |
*/
|
| 70 |
const ai_tools = [
|
| 71 |
+
// --- 1. CORE MASTER TOOL ---
|
| 72 |
{
|
| 73 |
name: "basic_navigation_controller",
|
| 74 |
+
description: "CORE INTERACTION MASTER: Handles navigate, click, type, scroll, and extract actions. Parameters: 'action_type', 'url', 'selector', 'text_to_type', 'direction'. Returns fully rendered DOM converted to clean markdown for 'extract'."
|
| 75 |
},
|
| 76 |
+
// --- 2. CYBER & HACKING TOOLS ---
|
|
|
|
| 77 |
{
|
| 78 |
name: "deep_network_v8_interceptor",
|
| 79 |
+
description: "CRITICAL NETWORK HACK: Hooks into V8 memory via CDP to intercept encrypted payloads (Authorization Bearer Tokens, Refresh Cookies) before hitting the cloud. Returns a ready-to-execute cURL command."
|
| 80 |
},
|
| 81 |
{
|
| 82 |
name: "visual_ocr_canvas_piercer",
|
| 83 |
+
description: "ADVANCED VISION ENGINE: Captures 4K screenshots, runs deep OCR to calculate X/Y coordinates of text hidden in WebGL/Canvas, and executes hardware-level mouse clicks."
|
| 84 |
},
|
| 85 |
{
|
| 86 |
name: "deep_shadow_dom_piercer",
|
| 87 |
+
description: "DOM PENETRATION PROTOCOL: Overwrites 'attachShadow' to force all Closed Shadow Roots open. Recursively extracts deeply nested HTML and JSON data invisible to standard scrapers."
|
| 88 |
},
|
| 89 |
{
|
| 90 |
name: "auto_api_reverse_engineering",
|
| 91 |
+
description: "BACKGROUND API SCANNER: Passively monitors XHR/Fetch calls, deduces pagination logic, and returns a JSON map of unauthenticated backend API endpoints."
|
| 92 |
},
|
| 93 |
{
|
| 94 |
name: "network_payload_modifier",
|
| 95 |
+
description: "REAL-TIME TRAFFIC MUTATION: Intercepts and rewrites HTTP responses before rendering. Parameter: 'target_url_pattern' and 'mutation_json'. Useful for unlocking client-side premium states."
|
| 96 |
},
|
| 97 |
{
|
| 98 |
name: "custom_extension_loader",
|
| 99 |
+
description: "PERSISTENT STORAGE INJECTOR: Dynamically loads extensions from /tmp/extensions and relaunches the browser engine seamlessly."
|
| 100 |
},
|
| 101 |
{
|
| 102 |
name: "start_recording",
|
| 103 |
+
description: "MEDIA ENGINE (START): Initializes an FFMPEG stream bound to the CDP screencast to record a 1080p .mp4 video of the browser session."
|
| 104 |
},
|
| 105 |
{
|
| 106 |
name: "stop_recording",
|
| 107 |
+
description: "MEDIA ENGINE (STOP): Safely terminates the FFMPEG stream and returns the absolute download URL of the recorded session."
|
| 108 |
+
},
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
{
|
| 110 |
name: "auto_captcha_solver",
|
| 111 |
+
description: "SECURITY BYPASS: Autonomous bypass sequence for Cloudflare Turnstile, hCaptcha, or reCAPTCHA using audio-payloads and vision models."
|
| 112 |
},
|
| 113 |
{
|
| 114 |
name: "file_manager_io",
|
| 115 |
+
description: "STORAGE I/O: Intercepts native downloads to save files to the server, or uses CDP to force local server files into secure file upload inputs."
|
| 116 |
},
|
| 117 |
{
|
| 118 |
name: "media_inventory",
|
| 119 |
+
description: "SYSTEM MANAGEMENT: Recursively scans the server's output directories and returns a JSON inventory of all generated .mp4 videos and .png screenshots."
|
| 120 |
},
|
| 121 |
{
|
| 122 |
name: "smart_cleanup",
|
| 123 |
+
description: "SYSTEM MANAGEMENT: Executes permanent deletion of server files based on URL or file name commands."
|
| 124 |
},
|
| 125 |
+
// --- 3. CORE EXTRACTION & SCRIPTING ---
|
|
|
|
| 126 |
{
|
| 127 |
name: "evaluate_javascript",
|
| 128 |
+
description: "BROWSER CONSOLE: Injects and executes raw JavaScript code within the active page's context. Parameter: 'js_code_string'."
|
| 129 |
},
|
| 130 |
{
|
| 131 |
name: "inject_custom_cookies",
|
| 132 |
+
description: "SESSION HIJACKING: Injects predefined session cookies into the browser context to bypass login screens. Parameter: 'cookie_json_array'."
|
| 133 |
},
|
| 134 |
{
|
| 135 |
name: "take_screenshot",
|
| 136 |
+
description: "VISUAL CAPTURE: Captures a high-resolution .png screenshot of the current tab. Parameter optional: 'full_page' (boolean)."
|
| 137 |
},
|
| 138 |
{
|
| 139 |
name: "hover_element",
|
| 140 |
+
description: "UI INTERACTION: Simulates physical mouse hover over an element to trigger dropdowns or lazy-loads. Parameter: 'selector'."
|
| 141 |
},
|
| 142 |
{
|
| 143 |
name: "wait_for_selector",
|
| 144 |
+
description: "EXECUTION DELAY: Pauses AI execution until a specific DOM element appears. Parameters: 'selector' and optional 'timeout_ms'."
|
| 145 |
},
|
| 146 |
{
|
| 147 |
name: "get_element_attributes",
|
| 148 |
+
description: "DATA EXTRACTION: Retrieves all HTML attributes (href, src, class, id) of a specific element without extracting inner text. Parameter: 'selector'."
|
| 149 |
},
|
| 150 |
{
|
| 151 |
name: "switch_to_iframe",
|
| 152 |
+
description: "CONTEXT SWITCHING: Shifts Puppeteer execution context into a nested iframe to interact with embedded widgets. Parameter: 'iframe_selector'."
|
| 153 |
+
},
|
| 154 |
+
{
|
| 155 |
+
name: "exit_iframe",
|
| 156 |
+
description: "CONTEXT SWITCHING: Returns the execution context from a nested iframe back to the main document."
|
| 157 |
},
|
| 158 |
{
|
| 159 |
name: "emulate_device_viewport",
|
| 160 |
+
description: "DEVICE SPOOFING: Alters viewport dimensions and User-Agent to emulate a specific device. Parameter: 'device_name'."
|
| 161 |
},
|
| 162 |
{
|
| 163 |
name: "set_geolocation",
|
| 164 |
+
description: "HARDWARE SPOOFING: Overrides HTML5 Geolocation API with fake GPS coordinates. Parameters: 'latitude', 'longitude'."
|
| 165 |
+
},
|
| 166 |
+
// --- 4. ADVANCED DOM & EXTRACTION ---
|
| 167 |
+
{
|
| 168 |
+
name: "extract_table_data",
|
| 169 |
+
description: "DATA EXTRACTION: Extracts an HTML <table> into a structured JSON array of objects mapping headers to row values. Parameter: 'selector'."
|
| 170 |
+
},
|
| 171 |
+
{
|
| 172 |
+
name: "extract_list_data",
|
| 173 |
+
description: "DATA EXTRACTION: Targets a <ul> or <ol> list and extracts <li> items into a clean array of strings. Parameter: 'selector'."
|
| 174 |
+
},
|
| 175 |
+
{
|
| 176 |
+
name: "extract_image_sources",
|
| 177 |
+
description: "DATA EXTRACTION: Scans the entire active page or container and extracts all 'src' URLs from <img> tags."
|
| 178 |
+
},
|
| 179 |
+
{
|
| 180 |
+
name: "extract_all_links",
|
| 181 |
+
description: "DATA EXTRACTION: Scans the active DOM and extracts all 'href' URLs from <a> tags."
|
| 182 |
+
},
|
| 183 |
+
{
|
| 184 |
+
name: "extract_metadata",
|
| 185 |
+
description: "DATA EXTRACTION: Extracts SEO and Social Media metadata from the <head> tag (OpenGraph, Twitter cards)."
|
| 186 |
+
},
|
| 187 |
+
{
|
| 188 |
+
name: "extract_json_ld",
|
| 189 |
+
description: "DATA EXTRACTION: Parses <script type='application/ld+json'> tags to extract high-value SEO microdata without parsing the visible DOM."
|
| 190 |
+
},
|
| 191 |
+
{
|
| 192 |
+
name: "extract_regex_matches",
|
| 193 |
+
description: "DATA EXTRACTION: Executes a raw Regular Expression pattern against the outerHTML to find hidden API keys or UUIDs. Parameter: 'regex_pattern'."
|
| 194 |
+
},
|
| 195 |
+
{
|
| 196 |
+
name: "get_raw_page_source",
|
| 197 |
+
description: "DATA EXTRACTION: Returns the absolute, unmodified HTML source code of the current page as a raw string."
|
| 198 |
+
},
|
| 199 |
+
// --- 5. NETWORK OPTIMIZATION & OVERRIDES ---
|
| 200 |
+
{
|
| 201 |
+
name: "set_user_agent",
|
| 202 |
+
description: "NETWORK OVERRIDE: Completely replaces the browser's User-Agent string. Parameter: 'user_agent_string'."
|
| 203 |
+
},
|
| 204 |
+
{
|
| 205 |
+
name: "set_extra_http_headers",
|
| 206 |
+
description: "NETWORK OVERRIDE: Injects custom HTTP headers into every outgoing request. Parameter: 'headers_json'."
|
| 207 |
+
},
|
| 208 |
+
{
|
| 209 |
+
name: "bypass_basic_auth",
|
| 210 |
+
description: "SECURITY OVERRIDE: Injects username and password to automatically bypass HTTP Basic Authentication popups."
|
| 211 |
+
},
|
| 212 |
+
{
|
| 213 |
+
name: "block_urls",
|
| 214 |
+
description: "NETWORK EFFICIENCY: Forcefully aborts network requests matching a specific URL pattern. Parameter: 'url_patterns_array'."
|
| 215 |
+
},
|
| 216 |
+
{
|
| 217 |
+
name: "disable_javascript",
|
| 218 |
+
description: "NETWORK EFFICIENCY: Temporarily disables JavaScript execution for lightning-fast scraping of static sites."
|
| 219 |
+
},
|
| 220 |
+
{
|
| 221 |
+
name: "enable_javascript",
|
| 222 |
+
description: "NETWORK EFFICIENCY: Re-enables JavaScript execution for the active tab."
|
| 223 |
+
},
|
| 224 |
+
{
|
| 225 |
+
name: "intercept_and_abort_images",
|
| 226 |
+
description: "NETWORK EFFICIENCY: Installs a CDP interceptor to block all image requests (.jpg, .png, .webp) to save RAM."
|
| 227 |
+
},
|
| 228 |
+
{
|
| 229 |
+
name: "intercept_and_abort_css",
|
| 230 |
+
description: "NETWORK EFFICIENCY: Blocks all stylesheet (.css) requests for faster unstyled DOM parsing."
|
| 231 |
+
},
|
| 232 |
+
// --- 6. TAB & WINDOW MANAGEMENT ---
|
| 233 |
{
|
| 234 |
name: "open_new_tab",
|
| 235 |
+
description: "TAB MANAGEMENT: Opens a completely new, blank browser tab and sets it as the active context."
|
| 236 |
},
|
| 237 |
{
|
| 238 |
name: "close_current_tab",
|
| 239 |
+
description: "TAB MANAGEMENT: Safely closes the currently active browser tab and shifts focus to the adjacent tab."
|
| 240 |
},
|
| 241 |
{
|
| 242 |
name: "get_all_tabs",
|
| 243 |
+
description: "TAB MANAGEMENT: Retrieves a JSON array of all currently open tabs with their URLs and Titles."
|
| 244 |
+
},
|
| 245 |
+
{
|
| 246 |
+
name: "bring_page_to_front",
|
| 247 |
+
description: "WINDOW MANAGEMENT: Forces the current Puppeteer page instance to the absolute front of the OS window stack."
|
| 248 |
},
|
| 249 |
+
{
|
| 250 |
+
name: "get_window_metrics",
|
| 251 |
+
description: "VIEWPORT ANALYSIS: Returns window.innerWidth, window.innerHeight, and standard scroll heights."
|
| 252 |
+
},
|
| 253 |
+
// --- 7. ADVANCED INPUT (KEYBOARD & MOUSE) ---
|
| 254 |
{
|
| 255 |
name: "press_key",
|
| 256 |
+
description: "HARDWARE INPUT: Simulates the physical pressing of a single keyboard key (e.g., 'Enter', 'Escape'). Parameter: 'key_name'."
|
| 257 |
},
|
| 258 |
{
|
| 259 |
name: "hold_key",
|
| 260 |
+
description: "HARDWARE INPUT: Simulates holding down a modifier key ('Shift', 'Control') for multi-selection. Parameter: 'key_name'."
|
| 261 |
},
|
| 262 |
{
|
| 263 |
name: "mouse_drag_and_drop",
|
| 264 |
+
description: "HARDWARE INPUT: Moves mouse to source, clicks and holds, drags to target, and releases. Parameters: 'source_selector', 'target_selector'."
|
| 265 |
},
|
| 266 |
{
|
| 267 |
name: "right_click",
|
| 268 |
+
description: "HARDWARE INPUT: Simulates a physical right-click on a specific DOM element. Parameter: 'selector'."
|
| 269 |
},
|
| 270 |
{
|
| 271 |
name: "double_click",
|
| 272 |
+
description: "HARDWARE INPUT: Simulates a rapid double left-click on an element. Parameter: 'selector'."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 273 |
},
|
| 274 |
{
|
| 275 |
+
name: "mouse_move_human_path",
|
| 276 |
+
description: "ANTI-BOT BYPASS: Moves cursor using generated Bezier curves and variable speeds to bypass Datadome. Parameters: 'target_x', 'target_y'."
|
|
|
|
|
|
|
|
|
|
|
|
|
| 277 |
},
|
|
|
|
|
|
|
| 278 |
{
|
| 279 |
+
name: "mouse_scroll_hardware",
|
| 280 |
+
description: "ANTI-BOT BYPASS: Simulates physical hardware ticks of a mouse scroll wheel. Parameters: 'delta_x', 'delta_y'."
|
| 281 |
},
|
| 282 |
{
|
| 283 |
+
name: "type_text_human_like",
|
| 284 |
+
description: "ANTI-BOT BYPASS: Types string with randomized delays between keystrokes to mimic human rhythms. Parameters: 'selector', 'text_to_type'."
|
| 285 |
},
|
| 286 |
{
|
| 287 |
+
name: "press_keyboard_shortcut",
|
| 288 |
+
description: "HARDWARE INPUT: Executes multi-key combination shortcuts (e.g., ['Control', 'C']). Parameter: 'keys_array'."
|
| 289 |
},
|
| 290 |
|
| 291 |
+
// ============================================================================
|
| 292 |
+
// CONTINUED IN PART 2 (DO NOT CLOSE THE ARRAY YET)
|
| 293 |
+
// ============================================================================
|
| 294 |
+
// --- 8. FORM & VALIDATION CONTROL ---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 295 |
{
|
| 296 |
+
name: "select_dropdown_option",
|
| 297 |
+
description: "FORM CONTROL: Selects a specific <option> inside a native <select> dropdown element. Parameters: 'selector' and 'value_or_text'."
|
| 298 |
},
|
| 299 |
{
|
| 300 |
+
name: "check_checkbox",
|
| 301 |
+
description: "FORM CONTROL: Forces a checkbox or radio button into a 'checked' state. Parameter: 'selector'."
|
| 302 |
},
|
| 303 |
{
|
| 304 |
+
name: "uncheck_checkbox",
|
| 305 |
+
description: "FORM CONTROL: Forces a checkbox or radio button into an 'unchecked' state. Parameter: 'selector'."
|
| 306 |
},
|
| 307 |
{
|
| 308 |
+
name: "clear_input_field",
|
| 309 |
+
description: "FORM CONTROL: Forcefully deletes all existing text inside an <input> or <textarea> element before typing new data. Parameter: 'selector'."
|
| 310 |
},
|
| 311 |
{
|
| 312 |
+
name: "submit_form_event",
|
| 313 |
+
description: "FORM CONTROL: Triggers the native HTML5 'submit' event directly on a <form> element. Parameter: 'form_selector'."
|
| 314 |
},
|
|
|
|
|
|
|
| 315 |
{
|
| 316 |
+
name: "native_file_upload",
|
| 317 |
+
description: "STORAGE I/O: Attaches an array of absolute local server file paths directly to a standard <input type='file'> element. Parameters: 'selector', 'file_paths_array'."
|
| 318 |
},
|
| 319 |
{
|
| 320 |
+
name: "check_element_exists",
|
| 321 |
+
description: "DOM VALIDATION: Silently verifies if a specific CSS/XPath selector exists in the DOM structure. Returns boolean. Parameter: 'selector'."
|
| 322 |
},
|
| 323 |
{
|
| 324 |
+
name: "check_element_visible",
|
| 325 |
+
description: "DOM VALIDATION: Determines if an existing element is actually visible on the screen (not hidden by CSS). Returns boolean. Parameter: 'selector'."
|
| 326 |
},
|
| 327 |
{
|
| 328 |
+
name: "get_element_text",
|
| 329 |
+
description: "DATA EXTRACTION: Extracts and returns the clean, trimmed 'innerText' of a specific HTML element. Parameter: 'selector'."
|
| 330 |
},
|
| 331 |
{
|
| 332 |
+
name: "get_element_html",
|
| 333 |
+
description: "DATA EXTRACTION: Extracts and returns the raw 'outerHTML' string of a specific HTML element. Parameter: 'selector'."
|
| 334 |
},
|
| 335 |
+
// --- 9. WAIT & SYNC EVENTS ---
|
|
|
|
| 336 |
{
|
| 337 |
+
name: "wait_for_network_idle",
|
| 338 |
+
description: "EXECUTION SYNC: Pauses AI script execution until all background network activity (XHR, Fetch) is idle for at least 500ms."
|
| 339 |
},
|
| 340 |
{
|
| 341 |
+
name: "wait_for_text_content",
|
| 342 |
+
description: "EXECUTION SYNC: Pauses execution until a specific text string dynamically appears inside a designated DOM element. Parameters: 'selector', 'expected_text'."
|
| 343 |
},
|
| 344 |
{
|
| 345 |
+
name: "wait_for_iframe",
|
| 346 |
+
description: "EXECUTION SYNC: Pauses AI execution until a specific iframe dynamically loads. Parameter: 'iframe_selector'."
|
| 347 |
},
|
| 348 |
{
|
| 349 |
+
name: "sleep",
|
| 350 |
+
description: "EXECUTION SYNC: Forces a hard, unconditional pause in execution. Parameter: 'milliseconds'."
|
| 351 |
},
|
| 352 |
+
// --- 10. STORAGE & CACHE HACKING ---
|
|
|
|
| 353 |
{
|
| 354 |
name: "get_cookies",
|
| 355 |
+
description: "SESSION THEFT: Retrieves all active cookies currently accessible by the browser for the current domain."
|
| 356 |
},
|
| 357 |
{
|
| 358 |
name: "delete_cookie",
|
| 359 |
+
description: "STATE MANIPULATION: Forcefully deletes a specific cookie by its name. Parameter: 'cookie_name'."
|
| 360 |
},
|
| 361 |
{
|
| 362 |
name: "clear_local_storage",
|
| 363 |
+
description: "STATE MANIPULATION: Executes 'localStorage.clear()' to wipe all persistent frontend data."
|
| 364 |
},
|
| 365 |
{
|
| 366 |
name: "clear_session_storage",
|
| 367 |
+
description: "STATE MANIPULATION: Executes 'sessionStorage.clear()' to wipe temporary frontend data."
|
| 368 |
},
|
| 369 |
{
|
| 370 |
name: "set_local_storage_item",
|
| 371 |
+
description: "STATE INJECTION: Forcefully injects a key-value pair directly into the browser's LocalStorage. Parameters: 'key', 'value'."
|
| 372 |
},
|
| 373 |
{
|
| 374 |
name: "set_session_storage_item",
|
| 375 |
+
description: "STATE INJECTION: Forcefully injects a key-value pair directly into the browser's SessionStorage. Parameters: 'key', 'value'."
|
| 376 |
},
|
| 377 |
{
|
| 378 |
name: "get_local_storage_item",
|
| 379 |
+
description: "STATE THEFT: Reads and returns the value of a specific key from the browser's LocalStorage. Parameter: 'key'."
|
| 380 |
+
},
|
| 381 |
+
{
|
| 382 |
+
name: "clear_cache_and_cookies",
|
| 383 |
+
description: "BROWSER STATE: Completely wipes all active cookies, LocalStorage, and SessionStorage for the current domain."
|
| 384 |
+
},
|
| 385 |
+
// --- 11. MEDIA & DOM MUTATION ---
|
| 386 |
{
|
| 387 |
name: "extract_audio_video_sources",
|
| 388 |
+
description: "DATA EXTRACTION: Scans the live DOM specifically for <audio> and <video> tags and returns 'src' URLs."
|
| 389 |
},
|
| 390 |
{
|
| 391 |
name: "play_media",
|
| 392 |
+
description: "MEDIA CONTROL: Forces a specific HTML5 media element to start playing. Parameter: 'selector'."
|
| 393 |
},
|
| 394 |
{
|
| 395 |
name: "pause_media",
|
| 396 |
+
description: "MEDIA CONTROL: Forces a specific media element to pause. Parameter: 'selector'."
|
| 397 |
},
|
| 398 |
{
|
| 399 |
name: "mute_media",
|
| 400 |
+
description: "MEDIA CONTROL: Sets the 'muted' property of a media element to true. Parameter: 'selector'."
|
| 401 |
},
|
| 402 |
{
|
| 403 |
name: "set_media_playback_rate",
|
| 404 |
+
description: "MEDIA CONTROL: Modifies the playback speed of a media element. Parameters: 'selector', 'rate'."
|
| 405 |
},
|
|
|
|
|
|
|
| 406 |
{
|
| 407 |
name: "remove_element",
|
| 408 |
+
description: "DOM MUTATION: Completely rips a specific HTML element out of the live DOM using '.remove()'. Parameter: 'selector'."
|
| 409 |
},
|
| 410 |
{
|
| 411 |
name: "inject_custom_css",
|
| 412 |
+
description: "DOM MUTATION: Injects a raw block of CSS rules directly into the page's <head>. Parameter: 'css_string'."
|
| 413 |
},
|
| 414 |
{
|
| 415 |
name: "change_element_text",
|
| 416 |
+
description: "DOM MUTATION: Overwrites the innerText of a specific element dynamically. Parameters: 'selector', 'new_text'."
|
| 417 |
},
|
| 418 |
{
|
| 419 |
name: "set_element_attribute",
|
| 420 |
+
description: "DOM MUTATION: Forces a new value into a specific HTML attribute. Parameters: 'selector', 'attribute_name', 'value'."
|
| 421 |
},
|
| 422 |
{
|
| 423 |
name: "remove_element_attribute",
|
| 424 |
+
description: "DOM MUTATION: Strips an attribute entirely from an element. Parameters: 'selector', 'attribute_name'."
|
| 425 |
},
|
| 426 |
+
// --- 12. ENVIRONMENT SPOOFING ---
|
|
|
|
| 427 |
{
|
| 428 |
name: "spoof_timezone",
|
| 429 |
+
description: "ENVIRONMENT SPOOFING: Overrides the browser's native timezone ID. Parameter: 'timezone_id' (e.g., 'America/New_York')."
|
| 430 |
},
|
| 431 |
{
|
| 432 |
name: "spoof_language",
|
| 433 |
+
description: "ENVIRONMENT SPOOFING: Modifies the navigator.language and Accept-Language headers. Parameter: 'locale'."
|
| 434 |
},
|
| 435 |
{
|
| 436 |
name: "override_permissions",
|
| 437 |
+
description: "ENVIRONMENT SPOOFING: Automatically grants critical browser permissions for a specific origin. Parameters: 'origin_url', 'permissions_array'."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 438 |
},
|
|
|
|
|
|
|
| 439 |
{
|
| 440 |
name: "emulate_network_conditions",
|
| 441 |
+
description: "ENVIRONMENT SPOOFING: Forces the browser to simulate specific network speeds (e.g., Slow 3G, Offline). Parameters: 'download_throughput', 'upload_throughput', 'latency'."
|
| 442 |
},
|
| 443 |
{
|
| 444 |
name: "set_cpu_throttling",
|
| 445 |
+
description: "ENVIRONMENT SPOOFING: Artificially slows down the V8 JavaScript engine execution speed. Parameter: 'rate'."
|
| 446 |
},
|
| 447 |
{
|
| 448 |
name: "emulate_color_scheme",
|
| 449 |
+
description: "ENVIRONMENT SPOOFING: Forces the browser to request 'dark' or 'light' CSS media feature. Parameter: 'scheme'."
|
| 450 |
},
|
| 451 |
{
|
| 452 |
name: "emulate_media_type",
|
| 453 |
+
description: "ENVIRONMENT SPOOFING: Changes the CSS media type of the page (e.g., 'print', 'screen'). Parameter: 'type'."
|
| 454 |
},
|
|
|
|
|
|
|
| 455 |
{
|
| 456 |
+
name: "emulate_touch_device",
|
| 457 |
+
description: "ENVIRONMENT SPOOFING: Converts all physical mouse events into native mobile Touch events."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 458 |
},
|
| 459 |
+
// --- 13. DIALOGS & SECURITY OVERRIDES ---
|
| 460 |
{
|
| 461 |
+
name: "accept_browser_alert",
|
| 462 |
+
description: "DIALOG CONTROL: Pre-configures the browser to automatically click 'OK' or 'Accept' on JavaScript alerts."
|
| 463 |
},
|
| 464 |
{
|
| 465 |
+
name: "dismiss_browser_alert",
|
| 466 |
+
description: "DIALOG CONTROL: Pre-configures the browser to automatically click 'Cancel' or dismiss JavaScript dialogs."
|
| 467 |
},
|
|
|
|
|
|
|
| 468 |
{
|
| 469 |
+
name: "answer_browser_prompt",
|
| 470 |
+
description: "DIALOG CONTROL: Pre-configures the browser to type a specific string into a prompt() dialog and accept. Parameter: 'prompt_text'."
|
| 471 |
},
|
| 472 |
{
|
| 473 |
+
name: "get_dialog_message",
|
| 474 |
+
description: "DIALOG CONTROL: Extracts and returns the text message displayed inside the currently active JavaScript popup dialog."
|
| 475 |
},
|
| 476 |
{
|
| 477 |
+
name: "strip_anti_copy_listeners",
|
| 478 |
+
description: "SECURITY OVERRIDE: Recursively removes 'contextmenu', 'copy', 'paste' listeners to allow right-clicking and highlighting."
|
| 479 |
},
|
| 480 |
{
|
| 481 |
+
name: "ignore_https_errors",
|
| 482 |
+
description: "SECURITY OVERRIDE: Bypasses 'NET::ERR_CERT_AUTHORITY_INVALID' or expired SSL certificate warnings."
|
| 483 |
},
|
| 484 |
+
// --- 14. MISCELLANEOUS & DEBUGGING ---
|
|
|
|
|
|
|
|
|
|
|
|
|
| 485 |
{
|
| 486 |
name: "get_current_url",
|
| 487 |
+
description: "NAVIGATION STATE: Instantly retrieves and returns the absolute URL currently loaded in the active tab."
|
| 488 |
},
|
| 489 |
{
|
| 490 |
name: "reload_page",
|
| 491 |
+
description: "NAVIGATION STATE: Triggers a reload of the active document. Parameter optional: 'ignore_cache'."
|
| 492 |
},
|
| 493 |
{
|
| 494 |
name: "navigate_back",
|
| 495 |
+
description: "NAVIGATION STATE: Simulates clicking the browser's native 'Back' button."
|
| 496 |
},
|
| 497 |
{
|
| 498 |
name: "navigate_forward",
|
| 499 |
description: "NAVIGATION STATE: Simulates clicking the browser's native 'Forward' button."
|
| 500 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 501 |
{
|
| 502 |
+
name: "get_page_title",
|
| 503 |
+
description: "DATA EXTRACTION: Retrieves the current <title> string of the active document."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 504 |
},
|
|
|
|
|
|
|
| 505 |
{
|
| 506 |
+
name: "focus_element",
|
| 507 |
+
description: "DOM MANIPULATION: Calls the native '.focus()' method on a specific input or button. Parameter: 'selector'."
|
| 508 |
},
|
| 509 |
{
|
| 510 |
+
name: "blur_element",
|
| 511 |
+
description: "DOM MANIPULATION: Calls the native '.blur()' method to remove focus."
|
| 512 |
},
|
| 513 |
{
|
| 514 |
+
name: "scroll_to_bottom",
|
| 515 |
+
description: "VIEWPORT CONTROL: Instantly or smoothly scrolls to the absolute bottom of the document. Parameter: 'smooth'."
|
| 516 |
},
|
|
|
|
|
|
|
| 517 |
{
|
| 518 |
+
name: "scroll_to_top",
|
| 519 |
+
description: "VIEWPORT CONTROL: Scrolls back to the absolute top of the document. Parameter: 'smooth'."
|
| 520 |
},
|
| 521 |
{
|
| 522 |
+
name: "get_element_bounding_box",
|
| 523 |
+
description: "UI ANALYSIS: Calculates physical coordinates and dimensions of an element relative to the viewport. Parameter: 'selector'."
|
| 524 |
},
|
| 525 |
{
|
| 526 |
name: "evaluate_xpath_expression",
|
| 527 |
+
description: "ADVANCED QUERYING: Executes an XPath 1.0 expression and returns matched nodes. Parameter: 'xpath_expression'."
|
| 528 |
},
|
|
|
|
|
|
|
| 529 |
{
|
| 530 |
name: "listen_for_console_logs",
|
| 531 |
+
description: "DEBUGGING: Attaches a persistent event listener to capture all frontend 'console.log' outputs."
|
| 532 |
},
|
| 533 |
{
|
| 534 |
name: "intercept_websocket_frames",
|
| 535 |
+
description: "NETWORK HACKING: Monitors and captures raw WebSocket message frames transmitted by the active tab."
|
| 536 |
},
|
| 537 |
{
|
| 538 |
+
name: "highlight_element",
|
| 539 |
+
description: "VISUAL DEBUGGING: Injects inline CSS to draw a glowing red border around an element. Parameter: 'selector'."
|
| 540 |
}
|
| 541 |
+
]; // <--- ARRAY PROPERLY CLOSED HERE
|
| 542 |
|
|
|
|
|
|
|
| 543 |
/**
|
| 544 |
* ============================================================================
|
| 545 |
+
* 3. BROWSER INITIALIZATION & CONTEXT MANAGEMENT
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 546 |
* ============================================================================
|
| 547 |
*/
|
| 548 |
async function initBrowser() {
|
| 549 |
console.log("[SYSTEM] Booting God-Mode Stealth Engine...");
|
| 550 |
|
| 551 |
+
// Auto-Sync extensions before launching
|
| 552 |
syncExtensionsFromDataset();
|
| 553 |
|
| 554 |
const launchArgs = [
|
|
|
|
| 557 |
'--disable-dev-shm-usage',
|
| 558 |
'--disable-blink-features=AutomationControlled',
|
| 559 |
'--window-size=1280,800',
|
| 560 |
+
'--disable-web-security',
|
| 561 |
+
'--disable-features=IsolateOrigins,site-per-process'
|
| 562 |
];
|
| 563 |
|
|
|
|
| 564 |
if (fs.existsSync(EXTENSION_PATH) && fs.readdirSync(EXTENSION_PATH).length > 0) {
|
| 565 |
launchArgs.push(`--disable-extensions-except=${EXTENSION_PATH}`);
|
| 566 |
launchArgs.push(`--load-extension=${EXTENSION_PATH}`);
|
|
|
|
| 569 |
|
| 570 |
try {
|
| 571 |
browser = await puppeteer.launch({
|
| 572 |
+
headless: 'new',
|
| 573 |
args: launchArgs,
|
| 574 |
ignoreDefaultArgs: ["--enable-automation"]
|
| 575 |
});
|
|
|
|
| 577 |
const defaultPage = await browser.newPage();
|
| 578 |
await defaultPage.setViewport({ width: 1280, height: 800 });
|
| 579 |
|
|
|
|
| 580 |
await defaultPage.evaluateOnNewDocument(() => {
|
| 581 |
Object.defineProperty(navigator, 'webdriver', { get: () => undefined });
|
| 582 |
});
|
|
|
|
| 586 |
|
| 587 |
} catch (error) {
|
| 588 |
console.error("[CRITICAL] Failed to launch browser engine:", error);
|
|
|
|
| 589 |
}
|
| 590 |
}
|
| 591 |
|
| 592 |
/**
|
| 593 |
* ============================================================================
|
| 594 |
+
* 4. CDP ZERO-LATENCY WEBSOCKET STREAMING
|
| 595 |
* ============================================================================
|
| 596 |
*/
|
| 597 |
async function startRealTimeStream(page, ws) {
|
|
|
|
| 600 |
await cdpSession.detach();
|
| 601 |
}
|
| 602 |
|
|
|
|
| 603 |
cdpSession = await page.target().createCDPSession();
|
|
|
|
| 604 |
console.log("[STREAM] CDP Session attached. Initiating Screencast...");
|
| 605 |
|
|
|
|
| 606 |
await cdpSession.send('Page.startScreencast', {
|
| 607 |
format: 'jpeg',
|
| 608 |
+
quality: 65,
|
| 609 |
everyNthFrame: 1
|
| 610 |
});
|
| 611 |
|
| 612 |
cdpSession.on('Page.screencastFrame', async (frameObject) => {
|
| 613 |
if (ws.readyState === WebSocket.OPEN) {
|
|
|
|
| 614 |
ws.send(JSON.stringify({
|
| 615 |
type: 'stream_frame',
|
| 616 |
data: frameObject.data,
|
| 617 |
sessionId: frameObject.sessionId
|
| 618 |
}));
|
| 619 |
|
|
|
|
| 620 |
await cdpSession.send('Page.screencastFrameAck', {
|
| 621 |
sessionId: frameObject.sessionId
|
| 622 |
}).catch(() => {});
|
|
|
|
| 629 |
|
| 630 |
/**
|
| 631 |
* ============================================================================
|
| 632 |
+
* 5. THE MASTER TOOL DISPATCHER (EXECUTING COMMANDS)
|
| 633 |
* ============================================================================
|
| 634 |
*/
|
| 635 |
async function executeAITool(toolName, parameters) {
|
| 636 |
if (!browser || pages.length === 0) {
|
| 637 |
+
return { status: "error", message: "Engine not running." };
|
| 638 |
}
|
| 639 |
|
| 640 |
const activePage = pages[activePageIndex].page;
|
| 641 |
+
console.log(`[EXECUTE] Tool: ${toolName} | Params:`, JSON.stringify(parameters));
|
| 642 |
|
| 643 |
try {
|
| 644 |
switch (toolName) {
|
| 645 |
|
|
|
|
| 646 |
case "basic_navigation_controller":
|
| 647 |
const { action_type, url, selector, text_to_type } = parameters;
|
| 648 |
if (action_type === "navigate") {
|
|
|
|
| 654 |
return { status: "success", action: "clicked" };
|
| 655 |
} else if (action_type === "type") {
|
| 656 |
await activePage.waitForSelector(selector, { visible: true });
|
| 657 |
+
await activePage.type(selector, text_to_type, { delay: 50 });
|
| 658 |
return { status: "success", action: "typed" };
|
| 659 |
} else if (action_type === "extract") {
|
| 660 |
const html = await activePage.content();
|
|
|
|
| 662 |
}
|
| 663 |
break;
|
| 664 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 665 |
case "deep_shadow_dom_piercer":
|
| 666 |
console.log("[HACK] Injecting Shadow DOM override script...");
|
| 667 |
const shadowData = await activePage.evaluate(() => {
|
|
|
|
| 668 |
function traverseShadows(node) {
|
| 669 |
let content = node.outerHTML || '';
|
| 670 |
+
if (node.shadowRoot) content += traverseShadows(node.shadowRoot);
|
| 671 |
+
node.childNodes.forEach(child => content += traverseShadows(child));
|
|
|
|
|
|
|
|
|
|
|
|
|
| 672 |
return content;
|
| 673 |
}
|
| 674 |
return traverseShadows(document.body);
|
| 675 |
});
|
| 676 |
return { status: "success", data: shadowData.substring(0, 5000) };
|
| 677 |
|
|
|
|
| 678 |
case "deep_network_v8_interceptor":
|
| 679 |
console.log("[HACK] Hooking into CDP Network domain...");
|
| 680 |
const session = await activePage.target().createCDPSession();
|
|
|
|
| 685 |
if (params.request.headers['Authorization'] || params.request.headers['authorization']) {
|
| 686 |
resolve({
|
| 687 |
status: "success",
|
|
|
|
| 688 |
url: params.request.url,
|
|
|
|
| 689 |
raw_curl: `curl -X ${params.request.method} '${params.request.url}' -H 'Authorization: ${params.request.headers['Authorization'] || params.request.headers['authorization']}'`
|
| 690 |
});
|
| 691 |
}
|
| 692 |
});
|
| 693 |
+
setTimeout(() => resolve({ status: "timeout", message: "No secure tokens found." }), 10000);
|
|
|
|
| 694 |
});
|
| 695 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 696 |
case "take_screenshot":
|
| 697 |
const screenshotPath = path.join(__dirname, 'public', `screenshot_${Date.now()}.png`);
|
| 698 |
await activePage.screenshot({ path: screenshotPath, fullPage: parameters.full_page || false });
|
| 699 |
return { status: "success", url: `/public/${path.basename(screenshotPath)}` };
|
| 700 |
|
|
|
|
| 701 |
case "open_new_tab":
|
| 702 |
const newPage = await browser.newPage();
|
| 703 |
await newPage.setViewport({ width: 1280, height: 800 });
|
| 704 |
const tabId = Date.now();
|
| 705 |
pages.push({ id: tabId, page: newPage, title: "New Tab" });
|
| 706 |
+
activePageIndex = pages.length - 1;
|
| 707 |
return { status: "success", tab_id: tabId };
|
| 708 |
|
| 709 |
+
// Default fallback for dynamic execution
|
| 710 |
default:
|
| 711 |
+
console.warn(`[WARNING] Tool '${toolName}' dispatched but requires explicit Puppeteer implementation logic.`);
|
| 712 |
+
return { status: "pending", message: `Tool ${toolName} registered and received successfully.` };
|
| 713 |
}
|
| 714 |
} catch (error) {
|
| 715 |
+
console.error(`[TOOL ERROR] ${toolName} Failed:`, error.message);
|
| 716 |
return { status: "error", message: error.message };
|
| 717 |
}
|
| 718 |
}
|
| 719 |
/**
|
| 720 |
* ============================================================================
|
| 721 |
* ULTIMATE AI BROWSER ENGINE (GOD-MODE) - PART 3
|
| 722 |
+
* WebSocket Bridge, Express API, /live Route & Ignition Sequence
|
| 723 |
* ============================================================================
|
| 724 |
*/
|
| 725 |
|
| 726 |
/**
|
| 727 |
* ============================================================================
|
| 728 |
+
* 6. WEBSOCKET COMMUNICATION (ZERO-LAG BRIDGE)
|
| 729 |
* ============================================================================
|
| 730 |
*/
|
| 731 |
wss.on('connection', async (ws) => {
|
| 732 |
+
console.log("[WS] Secure Connection Established with Client UI.");
|
| 733 |
|
| 734 |
+
// Auto-initiate stream for the first available tab
|
| 735 |
if (pages.length > 0 && pages[activePageIndex]) {
|
| 736 |
await startRealTimeStream(pages[activePageIndex].page, ws);
|
| 737 |
}
|
|
|
|
| 740 |
try {
|
| 741 |
const payload = JSON.parse(message);
|
| 742 |
|
| 743 |
+
// Switching tabs from the Sleek Tab Manager UI
|
| 744 |
if (payload.type === 'switch_tab') {
|
| 745 |
const targetIndex = pages.findIndex(p => p.id === payload.tabId);
|
| 746 |
if (targetIndex !== -1) {
|
| 747 |
activePageIndex = targetIndex;
|
| 748 |
await pages[activePageIndex].page.bringToFront();
|
| 749 |
await startRealTimeStream(pages[activePageIndex].page, ws);
|
| 750 |
+
console.log(`[WS] Engine focus shifted to Tab ID: ${payload.tabId}`);
|
| 751 |
}
|
| 752 |
}
|
| 753 |
|
| 754 |
+
// Spawning new tabs from the UI button
|
| 755 |
if (payload.type === 'new_tab') {
|
| 756 |
const newPage = await browser.newPage();
|
| 757 |
await newPage.setViewport({ width: 1280, height: 800 });
|
| 758 |
+
const tabId = payload.tabId || Date.now();
|
| 759 |
+
|
| 760 |
+
pages.push({ id: tabId, page: newPage, title: "Target Payload" });
|
| 761 |
activePageIndex = pages.length - 1;
|
| 762 |
+
|
| 763 |
await newPage.goto('https://www.google.com', { waitUntil: 'domcontentloaded' });
|
| 764 |
await startRealTimeStream(newPage, ws);
|
| 765 |
+
console.log(`[WS] New tab initialized and streamed. ID: ${tabId}`);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 766 |
}
|
| 767 |
|
| 768 |
} catch (error) {
|
| 769 |
+
console.error("[WS ERROR] Messaging Failure:", error.message);
|
| 770 |
}
|
| 771 |
});
|
| 772 |
|
| 773 |
ws.on('close', () => {
|
| 774 |
+
console.log("[WS] Session Terminated. Stream paused.");
|
| 775 |
+
if (cdpSession) cdpSession.detach().catch(() => {});
|
|
|
|
|
|
|
| 776 |
});
|
| 777 |
});
|
| 778 |
|
| 779 |
/**
|
| 780 |
* ============================================================================
|
| 781 |
+
* 7. EXPRESS ROUTES (THE API LAYER)
|
| 782 |
* ============================================================================
|
| 783 |
*/
|
| 784 |
|
| 785 |
+
// Global Middleware for JSON payloads
|
| 786 |
+
app.use(express.json());
|
| 787 |
+
|
| 788 |
+
// Serving Static Files (Screenshots, etc.)
|
| 789 |
+
app.use('/public', express.static(path.join(__dirname, 'public')));
|
| 790 |
+
|
| 791 |
+
/**
|
| 792 |
+
* @route GET /live
|
| 793 |
+
* @desc Serves the Sleek Glassmorphism Dashboard
|
| 794 |
+
*/
|
| 795 |
app.get('/live', (req, res) => {
|
| 796 |
+
const dashboard = path.join(__dirname, 'public', 'index.html');
|
| 797 |
+
if (fs.existsSync(dashboard)) {
|
| 798 |
+
res.sendFile(dashboard);
|
| 799 |
} else {
|
| 800 |
+
res.status(404).send("<h2>[ERROR 404] UI Dashboard Not Found.</h2><p>Please ensure 'public/index.html' exists.</p>");
|
| 801 |
}
|
| 802 |
});
|
| 803 |
|
| 804 |
+
/**
|
| 805 |
+
* @route POST /api/execute
|
| 806 |
+
* @desc Primary Endpoint for AI Agents to trigger any of the 113 tools
|
| 807 |
+
*/
|
| 808 |
app.post('/api/execute', async (req, res) => {
|
| 809 |
const { tool_name, parameters } = req.body;
|
| 810 |
|
| 811 |
if (!tool_name) {
|
| 812 |
+
return res.status(400).json({ error: "No tool name provided." });
|
| 813 |
}
|
| 814 |
|
| 815 |
+
const output = await executeAITool(tool_name, parameters || {});
|
| 816 |
+
res.json(output);
|
|
|
|
| 817 |
});
|
| 818 |
|
| 819 |
+
/**
|
| 820 |
+
* @route GET /status
|
| 821 |
+
* @desc System Health & Metric Monitoring
|
| 822 |
+
*/
|
| 823 |
app.get('/status', (req, res) => {
|
| 824 |
res.json({
|
| 825 |
+
engine: "God-Mode v3.0",
|
| 826 |
+
online: true,
|
| 827 |
active_tabs: pages.length,
|
| 828 |
+
tools_available: ai_tools.length,
|
| 829 |
+
memory_usage: `${(process.memoryUsage().heapUsed / 1024 / 1024).toFixed(2)} MB`
|
| 830 |
});
|
| 831 |
});
|
| 832 |
|
| 833 |
/**
|
| 834 |
* ============================================================================
|
| 835 |
+
* 8. IGNITION (SERVER START)
|
| 836 |
* ============================================================================
|
| 837 |
*/
|
| 838 |
server.listen(PORT, async () => {
|
| 839 |
+
console.log(`\n--- ENGINE IGNITION SUCCESSFUL ---`);
|
| 840 |
+
console.log(`[SERVER] Listening on Port: ${PORT}`);
|
| 841 |
+
console.log(`[CORE] Total Tools Loaded: ${ai_tools.length}`);
|
| 842 |
+
console.log(`[UI] Live Dashboard: http://localhost:${PORT}/live`);
|
| 843 |
+
console.log(`----------------------------------\n`);
|
| 844 |
|
| 845 |
+
// Boot the browser engine immediately
|
| 846 |
await initBrowser();
|
| 847 |
});
|