### Manage Chrome Storage with ttStorage and ttCache Source: https://context7.com/mephiles/torntools_extension/llms.txt Illustrates how to interact with Chrome's local storage for API keys and user settings using `ttStorage`. It covers getting, setting, and deep merging data, as well as managing temporary data with time-to-live (TTL) using `ttCache`. API usage tracking and storage size retrieval are also shown. ```javascript // Get data from Chrome storage const apiKey = await ttStorage.get("api"); const settings = await ttStorage.get("settings"); console.log(apiKey.torn.key); // Set multiple values await ttStorage.set({ settings: { pages: { sidebar: { barLinks: true } } } }); // Deep merge changes (preserves other settings) await ttStorage.change({ settings: { pages: { items: { quickItems: false } } } }); // Cache temporary data with TTL await ttCache.set( { npcTimes: npcData }, 2 * TO_MILLIS.HOURS, // Time-to-live: 2 hours "npcs" // Section name ); // Check if cache is valid if (ttCache.hasValue("npcs", "npcTimes")) { const cached = ttCache.get("npcs", "npcTimes"); console.log("Using cached data:", cached); } // Track API usage await ttUsage.add("tornv2"); await ttUsage.add("yata"); // Clean expired cache entries await ttCache.refresh(); // Get storage size const size = await ttStorage.getSize(); console.log(`Using ${size.bytes} bytes (${size.percentage}%)`); ``` -------------------------------- ### Manually Trigger Data Fetch via Chrome Runtime (JavaScript) Source: https://context7.com/mephiles/torntools_extension/llms.txt Demonstrates how to manually trigger a data fetch operation from a content script using `chrome.runtime.sendMessage`. This example specifically requests user profile and bars data from the 'tornv2' location. It includes basic error handling for the response. This method is used for on-demand updates or specific actions initiated by the user or script logic. ```javascript // Example: Manually trigger user data update from content script chrome.runtime.sendMessage({ action: "fetchRelay", location: "tornv2", options: { section: "user", selections: ["profile", "bars"] } }, (response) => { if (response.error) { console.error("Fetch failed:", response.error); } else { console.log("User data:", response); } }); ``` -------------------------------- ### Array and Utility Functions in TornTools Source: https://context7.com/mephiles/torntools_extension/llms.txt This snippet showcases various utility functions and array extensions provided by the TornTools extension. These include methods for array manipulation (getting last item, inserting, summing, comparing), asynchronous delays, searching nested objects, cookie handling, random string generation, array rotation, hashing, and clipboard operations. ```javascript // Array extensions const lastItem = [1, 2, 3, 4].last(); // 4 [1, 2, 3].insertAt(1, 99); // [1, 99, 2, 3] [5, 10, 15].totalSum(); // 30 [1, 2, 3].equals([1, 2, 3]); // true // Sleep/delay await sleep(2000); // Wait 2 seconds // Find items in nested objects const items = findItemsInObject(torndata.items, { type: "Drug" }); // Returns array of items where type === "Drug" const users = findItemsInList(factionData.members, { status: "Online" }); // Returns array of members where status === "Online" // Cookie handling const sid = getCookie("sid"); // Get Torn session ID // Random string generation randomString(16); // "a3f9d2c1e8b4f7a9" // Rotation utilities rotateArray([1, 2, 3, 4], 2); // [3, 4, 1, 2] rotatePrevious(currentIndex, maxLength); // Get previous index with wrap rotateNext(currentIndex, maxLength); // Get next index with wrap // Hash functions hashCode("some string"); // Generate numeric hash await sha256("password"); // SHA-256 hash // Clipboard await copyToClipboard("text to copy"); ``` -------------------------------- ### Create Custom UI Containers with JavaScript Source: https://context7.com/mephiles/torntools_extension/llms.txt Creates various custom UI containers like standard containers with headers, collapsible content, filter containers, and drag-and-drop enabled containers. It also includes functionality to find, update, and remove existing containers. ```javascript // Create a standard TornTools container with header and collapsible content const { container, content, options } = createContainer("Stat Tracker", { id: "tt-stat-tracker", parentElement: document.find(".content-wrapper"), collapsible: true, showHeader: true, contentBackground: true, class: "custom-class", applyRounding: true, compact: false }); // Add content to the container content.appendChild(document.newElement({ type: "div", class: "stat-display", children: [ document.newElement({ type: "span", text: "Strength: " }), document.newElement({ type: "strong", text: "1,000,000" }) ] })); // Add options to header options.appendChild(document.newElement({ type: "button", text: "Refresh", events: { click: () => console.log("Refreshing...") } })); // Create a filter container const filterContainer = createContainer("Filters", { filter: true, flexContainer: true }); // Create container with drag-drop support const quickItemsContainer = createContainer("Quick Items", { allowDragging: true, contentBackground: false }); // Find existing container const existingContainer = findContainer("Stat Tracker"); if (existingContainer) { existingContainer.find("main").innerHTML = "
Updated content
"; } // Remove container removeContainer("Stat Tracker"); ``` -------------------------------- ### Item Market API Source: https://github.com/mephiles/torntools_extension/wiki/API-usage Fetch data related to items available in the item market and player bazaars. ```APIDOC ## GET /api/item_market ### Description Retrieves information about items in the item market and player bazaars. ### Method GET ### Endpoint `/api/item_market` ### Parameters #### Query Parameters - **fields** (string) - Required - A comma-separated list of fields to retrieve. Available fields: bazaar, itemmarket ### Request Example ``` GET /api/item_market?fields=bazaar,itemmarket ``` ### Response #### Success Response (200) - **data** (object) - An object containing the requested item market data fields. #### Response Example ```json { "status": "success", "data": { "bazaar": [ { "item_id": 1, "name": "Small Med Kit", "price": 15000, "user_id": 123456 }, { "item_id": 2, "name": "Temporary Tattoo", "price": 150000, "user_id": 987654 } ], "itemmarket": [ { "item_id": 1, "name": "Small Med Kit", "total_price": 14500, "total_quantity": 100 }, { "item_id": 2, "name": "Temporary Tattoo", "total_price": 145000, "total_quantity": 50 } ] } } ``` ``` -------------------------------- ### Fetch Data from Torn API using fetchData Source: https://context7.com/mephiles/torntools_extension/llms.txt Demonstrates how to fetch data from various APIs including Torn API v2, external services like YATA, and TornStats. It shows how to specify API endpoints, select data fields, handle optional API keys, and utilize relay functionality for content scripts. Error handling for network issues is also included. ```javascript // Fetch user profile and bars data from Torn API v2 const userData = await fetchData("tornv2", { section: "user", selections: ["profile", "bars", "cooldowns"], key: "YOUR_API_KEY" // Optional, uses stored key by default }); console.log(userData.profile.name); console.log(userData.bars.energy.current); console.log(userData.bars.energy.maximum); // Fetch faction member data with error handling try { const factionData = await fetchData("tornv2", { section: "faction", selections: ["basic", "members"], relay: true // Routes through background worker if called from content script }); for (const [id, member] of Object.entries(factionData.members)) { console.log(`${member.name} - Status: ${member.status.state}`); } } catch (error) { if (error.code === CUSTOM_API_ERROR.NO_NETWORK) { console.warn("Network unavailable"); } else { console.error("API error:", error.message); } } // Fetch from external service (YATA NPC loot times) const npcData = await fetchData("yata", { section: "loot", id: "timings" }); // Fetch TornStats battle estimates const statsData = await fetchData(FETCH_PLATFORMS.tornstats, { section: "spy", id: "2087524", // User ID key: "YOUR_TORNSTATS_KEY" }); ``` -------------------------------- ### Company API Source: https://github.com/mephiles/torntools_extension/wiki/API-usage Retrieve information about companies, including their profiles and employee lists. ```APIDOC ## GET /api/company ### Description Retrieves information about a company, such as its profile details and list of employees. ### Method GET ### Endpoint `/api/company` ### Parameters #### Query Parameters - **fields** (string) - Required - A comma-separated list of fields to retrieve. Available fields: profile, employees ### Request Example ``` GET /api/company?fields=profile,employees ``` ### Response #### Success Response (200) - **data** (object) - An object containing the requested company data fields. #### Response Example ```json { "status": "success", "data": { "profile": { "name": "Example Company", "ID": 101, "type": "Law Firm" }, "employees": [ { "name": "Employee One", "ID": 111111 }, { "name": "Employee Two", "ID": 222222 } ] } } ``` ``` -------------------------------- ### Custom Event System for TornTools Source: https://context7.com/mephiles/torntools_extension/llms.txt This snippet demonstrates how to listen to and trigger custom events within the TornTools extension. It utilizes a predefined set of event channels for various in-game actions and features. No external dependencies are required, as it relies on the extension's internal event management system. ```javascript // Listen to internal TornTools events CUSTOM_LISTENERS[EVENT_CHANNELS.CHAT_MESSAGE].push(({ message }) => { console.log("New chat message:", message.text); console.log("From:", message.author); }); CUSTOM_LISTENERS[EVENT_CHANNELS.ITEM_ITEMS_LOADED].push(({ tab }) => { console.log("Items loaded in tab:", tab.dataset.info); }); CUSTOM_LISTENERS[EVENT_CHANNELS.FEATURE_ENABLED].push(({ name }) => { console.log(`Feature "${name}" was enabled`); }); // Trigger custom events triggerCustomListener(EVENT_CHANNELS.STAKEOUT_UPDATE, { id: 2087524, status: "Online" }); // Available event channels (60+ total): EVENT_CHANNELS.CHAT_MESSAGE EVENT_CHANNELS.CHAT_OPENED EVENT_CHANNELS.FEATURE_ENABLED EVENT_CHANNELS.FEATURE_DISABLED EVENT_CHANNELS.ITEM_ITEMS_LOADED EVENT_CHANNELS.ITEM_SWITCH_TAB EVENT_CHANNELS.ITEM_AMOUNT EVENT_CHANNELS.FACTION_INFO EVENT_CHANNELS.STAKEOUT_UPDATE EVENT_CHANNELS.API_FETCH_COMPLETE // ... and many more ``` -------------------------------- ### Checking for Mobile Support (JavaScript) Source: https://github.com/mephiles/torntools_extension/blob/master/CONTRIBUTING.md This code snippet shows the recommended way to check for mobile device support within the extension. It emphasizes using the `checkMobile()` function instead of relying on global variables. ```javascript async function someFeatureFunction() { if (await checkMobile()) { console.log("Running on mobile."); // Mobile-specific logic } else { console.log("Running on desktop."); // Desktop-specific logic } } ``` -------------------------------- ### Faction Data API Source: https://github.com/mephiles/torntools_extension/wiki/API-usage Access basic and detailed information about a faction, including its members and activities. ```APIDOC ## GET /api/faction ### Description Retrieves information about a faction. Note: Access to this endpoint requires the user to have granted faction API access. ### Method GET ### Endpoint `/api/faction` ### Parameters #### Query Parameters - **fields** (string) - Required - A comma-separated list of fields to retrieve. Available fields: basic, crimes, positions ### Request Example ``` GET /api/faction?fields=basic,crimes ``` ### Response #### Success Response (200) - **data** (object) - An object containing the requested faction data fields. #### Response Example ```json { "status": "success", "data": { "basic": { "name": "Faction Name", "tag": "TAG", "id": 789 }, "crimes": [ { "name": "Rob Train", "level": 10 }, { "name": "Organized Crime", "level": 25 } ] } } ``` ``` -------------------------------- ### Timed Background Updates (JavaScript) Source: https://context7.com/mephiles/torntools_extension/llms.txt An asynchronous function designed to run periodically (e.g., every 31 seconds via an alarm) to perform various background update tasks. It fetches and updates user data, monitors player and faction stakeouts, retrieves NPC loot times, updates stock market data, and refreshes faction and global game data. Dependencies include various `update*` functions and potentially `chrome.runtime` for messaging. ```javascript // Background worker automatically runs every 31 seconds via alarm async function timedUpdates() { // Update user data with smart delays await updateUserdata(); // Fetches essential (30s) and basic (120s) selections // Monitor specific players for status changes await updateStakeouts(); // Monitor faction members await updateFactionStakeouts(); // Get NPC loot times from external services await updateNPCs(); // Update stock market data await updateStocks(); // Refresh faction data await updateFactiondata(); // Update global game data (items, education, etc.) await updateTorndata(); } ``` -------------------------------- ### User Data API Source: https://github.com/mephiles/torntools_extension/wiki/API-usage Retrieve detailed information about a user's profile, including stats, inventory, and activity. ```APIDOC ## GET /api/user ### Description Retrieves a comprehensive set of data fields for a specific user. This endpoint provides granular information across various aspects of a user's in-game presence. ### Method GET ### Endpoint `/api/user` ### Parameters #### Query Parameters - **fields** (string) - Required - A comma-separated list of fields to retrieve. Available fields: ammo, attacks, bars, battlestats, bazaar, cooldowns, crimes, display, education, icons, inventory, merits, money, networth, newevents, newmessages, perks, personalstats, profile, refills, stocks, timestamp, travel, weaponexp, workstats, properties ### Request Example ``` GET /api/user?fields=profile,battlestats,money ``` ### Response #### Success Response (200) - **data** (object) - An object containing the requested user data fields. #### Response Example ```json { "status": "success", "data": { "profile": { "name": "User Name", "ID": 123456 }, "battlestats": { "strength": 100000, "defense": 100000, "speed": 100000, "dexterity": 100000 }, "money": 500000000 } } ``` ``` -------------------------------- ### Query DOM Elements using Extended Methods (JavaScript) Source: https://context7.com/mephiles/torntools_extension/llms.txt Provides extended query methods on the `document` and `Element` objects for simplified DOM traversal. `find` is equivalent to `querySelector`, and `findAll` is equivalent to `querySelectorAll`. These methods can be called on the global `document` or any existing DOM element to search within its context. ```javascript // Query helpers (extended Document/Element) const element = document.find(".selector"); // querySelector const elements = document.findAll(".selector"); // querySelectorAll const child = element.find(".child-selector"); // From specific element ``` -------------------------------- ### Torn Stats API Source: https://github.com/mephiles/torntools_extension/wiki/API-usage Access general statistics and data points related to the Torn game world. ```APIDOC ## GET /api/torn ### Description Retrieves general statistics and data points about the Torn game world. ### Method GET ### Endpoint `/api/torn` ### Parameters #### Query Parameters - **fields** (string) - Required - A comma-separated list of fields to retrieve. Available fields: bank, education, honors, items, medals, pawnshop, properties, stocks, stats ### Request Example ``` GET /api/torn?fields=bank,stocks ``` ### Response #### Success Response (200) - **data** (object) - An object containing the requested Torn statistics data fields. #### Response Example ```json { "status": "success", "data": { "bank": { "checking": 1000000000, "savings": 5000000000 }, "stocks": [ { "company_id": 1, "ticker": "AP", "price": 1200000, "quantity": 500 }, { "company_id": 2, "ticker": "OMNI", "price": 750000, "quantity": 1000 } ] } } ``` ``` -------------------------------- ### Filter System for User Lists in TornTools Source: https://context7.com/mephiles/torntools_extension/llms.txt This code defines a filter system for dynamically filtering user lists within the TornTools extension. It allows users to set criteria such as level range and online status. The filter state is automatically persisted using Chrome storage, ensuring continuity across sessions. ```javascript // Create a filter UI for user lists const FILTER_DEFAULTS = { level: { min: 0, max: 100 }, status: ["Online", "Idle", "Offline"], faction: { name: "", id: "" } }; const filters = createFilterSection({ title: "Member Filters", defaults: FILTER_DEFAULTS, callback: applyFilters }); function applyFilters() { const levelMin = filters.level.min; const levelMax = filters.level.max; const selectedStatuses = filters.status; for (const row of document.findAll(".member-row")) { const level = parseInt(row.dataset.level); const status = row.dataset.status; const matchesLevel = level >= levelMin && level <= levelMax; const matchesStatus = selectedStatuses.includes(status); if (matchesLevel && matchesStatus) { row.style.display = ""; } else { row.style.display = "none"; } } } // Filter container state is automatically saved to Chrome storage // and persists across page reloads ``` -------------------------------- ### Feature Registration in Feature Manager (JavaScript) Source: https://github.com/mephiles/torntools_extension/blob/master/CONTRIBUTING.md This snippet demonstrates how to register a feature within the Feature Manager. It outlines the properties required for feature configuration, including name, scope, enablement checks, initialization, execution, cleanup, and dependency management. Features are encapsulated in anonymous functions. ```javascript "use strict"; (function() { const featureName = "My Feature"; const featureScope = "page"; function isFeatureEnabled() { // Check feature settings and return true/false return true; } function initializeFeature() { // Code to run once when the feature is enabled console.log(featureName + " initialized."); } function executeFeature() { // Code to run every time the feature is started console.log(featureName + " executed."); } function cleanupFeature() { // Code to run every time the feature is stopped console.log(featureName + " cleaned up."); } const loadListeners = { // Define conditions for reloading the feature }; function checkRequirements() { // Evaluate feature requirements (e.g., mobile, API access) // Return a string with the reason if requirements are not met return null; // Or a string like "Missing API Access" } FeatureManager.register({ // Assuming FeatureManager is a global object name: featureName, scope: featureScope, enabled: isFeatureEnabled, initialise: initializeFeature, execute: executeFeature, cleanup: cleanupFeature, loadListeners: loadListeners, requirements: checkRequirements }); })(); ``` -------------------------------- ### Wait for Elements and Conditions in DOM (JavaScript) Source: https://context7.com/mephiles/torntools_extension/llms.txt These functions enable asynchronous waiting for specific DOM elements to appear or for certain conditions to be met before proceeding. This is crucial for scripts that interact with dynamically loaded content. `requireElement` waits for an element, optionally with continuous checking. `requireCondition` waits for a custom condition. Various `require*` functions are specific to Torn.js. ```javascript // Wait for elements to appear in DOM const sidebar = await requireElement("#sidebar"); const chatBox = await requireElement(".chat-box-wrap", { continuous: true // Keep checking if element gets removed/re-added }); // Wait for specific conditions await requireCondition(() => { return document.find(".items-list") && document.find(".items-list").children.length > 0; }); // Wait for page-specific elements await requireSidebar(); // Wait for Torn sidebar to load await requireChatsLoaded(); // Wait for chat system await requireContent(); // Wait for main content area await requireItemsLoaded(); // Wait for items page to load ``` -------------------------------- ### Format Numbers with Options (JavaScript) Source: https://context7.com/mephiles/torntools_extension/llms.txt This function formats numerical values according to specified options, such as adding commas for thousands separators, including currency symbols, controlling decimal places, or shortening large numbers with suffixes like 'mil'. It enhances the readability of numerical data presented to the user. Inputs include the number and an optional configuration object. ```javascript // Format numbers with currency formatNumber(1234567); // "1,234,567" formatNumber(1234567, { currency: true }); // "$1,234,567" formatNumber(1234.567, { decimals: 2 }); // "1,234.57" formatNumber(1234567, { shorten: true }); // "1.23mil" ``` -------------------------------- ### Create Complex DOM Elements with Events (JavaScript) Source: https://context7.com/mephiles/torntools_extension/llms.txt This function allows for the creation of complex DOM elements, including nested structures, with specified attributes, classes, IDs, text content, and event listeners. It simplifies the process of dynamically generating HTML content. Dependencies include the browser's DOM API. Inputs are an object configuration; outputs are DOM elements. ```javascript const button = document.newElement({ type: "button", class: ["tt-btn", "primary"], id: "my-action-btn", text: "Click Me", attributes: { "data-action": "submit", "aria-label": "Submit form" }, events: { click: (event) => { console.log("Button clicked!"); }, mouseenter: () => { console.log("Mouse over"); } } }); const panel = document.newElement({ type: "div", class: "info-panel", children: [ document.newElement({ type: "h3", text: "Player Stats" }), document.newElement({ type: "ul", children: [ document.newElement({ type: "li", text: "Level: 50" }), document.newElement({ type: "li", text: "Age: 1000 days" }) ] }) ] }); ``` -------------------------------- ### Handling CSS Class Selectors (CSS/JavaScript) Source: https://github.com/mephiles/torntools_extension/blob/master/CONTRIBUTING.md This guideline explains how to safely select HTML elements using CSS classes that contain underscores. It recommends using attribute selectors to avoid issues with potential class name changes. ```css /* Instead of .SOMENAME_xyz */ [class*='SOMENAME_'] { /* Your styles here */ } ``` -------------------------------- ### Format Time Values with Types (JavaScript) Source: https://context7.com/mephiles/torntools_extension/llms.txt This function formats time durations or timestamps into human-readable strings. It supports various output types including 'normal' (h:m:s), 'timer' (HH:MM:SS), 'wordTimer' (e.g., '1 hour 1 minute'), and 'ago' for relative time. It takes a time object (primarily seconds) and an options object to specify the format. Dependencies include time constants like `TO_MILLIS`. ```javascript // Format time values formatTime( { seconds: 3661 }, // Time object { type: "normal" } // Type: normal, timer, wordTimer, ago ); // "1h 1m 1s" formatTime({ seconds: 3661 }, { type: "timer" }); // "01:01:01" formatTime({ seconds: 3661 }, { type: "wordTimer" }); // "1 hour 1 minute" // Format relative time formatTime({ seconds: Date.now() - 3600000 }, { type: "ago" }); // "1 hour ago" ``` -------------------------------- ### Format Dates Respecting User Settings (JavaScript) Source: https://context7.com/mephiles/torntools_extension/llms.txt Formats a JavaScript `Date` object into a string based on user-defined formatting preferences, typically stored in `settings.formatting.date`. This ensures dates are displayed consistently according to regional standards (e.g., 'eu' for DD/MM/YYYY, 'us' for MM/DD/YYYY). ```javascript // Date formatting (respects user settings) const formatted = formatDate(new Date(), settings.formatting.date); // If settings.formatting.date is "eu": "15/10/2025" // If settings.formatting.date is "us": "10/15/2025" ``` -------------------------------- ### Time Constants for Millisecond Calculations (JavaScript) Source: https://context7.com/mephiles/torntools_extension/llms.txt Defines constants for common time intervals (minutes, hours, days, weeks) in milliseconds. These constants simplify time-related calculations and improve code readability by avoiding magic numbers. They are essential for use with time formatting and parsing functions. ```javascript // Time constants const fiveMinutes = 5 * TO_MILLIS.MINUTES; // 300000 const oneHour = TO_MILLIS.HOURS; // 3600000 const oneDay = TO_MILLIS.DAYS; // 86400000 const oneWeek = TO_MILLIS.WEEKS; // 604800000 ``` -------------------------------- ### Parse Time Strings to Milliseconds (JavaScript) Source: https://context7.com/mephiles/torntools_extension/llms.txt Converts various string representations of time durations (e.g., '2h 30m', '1d 5h', '45s') into their equivalent value in milliseconds. This is useful for calculations and setting timeouts. It relies on predefined time constants for conversions. ```javascript // Parse time strings to milliseconds textToTime("2h 30m"); // 9000000 (milliseconds) textToTime("1d 5h"); // 104400000 textToTime("45s"); // 45000 ``` -------------------------------- ### Register Feature with Lifecycle Hooks in JavaScript Source: https://context7.com/mephiles/torntools_extension/llms.txt Registers a complete feature with its name, scope, enabled check, initialization, execution, cleanup logic, watched storage keys, requirements check, and options. This function is crucial for modularizing and managing different functionalities within the extension. ```javascript // Register a complete feature with all lifecycle hooks featureManager.registerFeature( "Item Values", // Feature name "items", // Scope/page () => settings.pages.items.values, // Enabled check function initializeItemValues, // Initialize (runs once) showValues, // Execute (main logic) removeValues, // Cleanup (when disabled) { storage: ["settings.pages.items.values"] // Watch these storage keys }, async () => { if (!hasAPIData()) return "No API access."; await checkDevice(); }, { triggerCallback: true } // Options ); function initializeItemValues() { // Setup event listeners - runs only once CUSTOM_LISTENERS[EVENT_CHANNELS.ITEM_ITEMS_LOADED].push(({ tab }) => { if (!featureManager.get("Item Values").enabled()) return; showValues(tab); }); } async function showValues() { // Main feature logic - runs on enable and settings change await requireItemsLoaded(); for (const item of document.findAll(".items-cont > li[data-item]")) { const id = item.dataset.item; const price = torndata.items[id].market_value; const quantity = parseInt(item.find(".item-amount").textContent) || 1; const priceElement = document.newElement({ type: "span", class: "tt-item-price", text: formatNumber(price * quantity, { currency: true }) }); item.find(".name-wrap").appendChild(priceElement); } } function removeValues() { // Cleanup - runs on disable for (const element of document.findAll(".tt-item-price")) { element.remove(); } } ``` -------------------------------- ### JavaScript Strict Mode Declaration Source: https://github.com/mephiles/torntools_extension/blob/master/CONTRIBUTING.md Ensures that all JavaScript code within the extension operates in strict mode. This helps catch common coding errors and insecure features by throwing exceptions. ```javascript "use strict"; ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.