1/** 2 * Instagram In-App Browser Crash Guard 3 * 4 * Instagram's PageTranslationRequiredListener.js tries to access window.webkit.messageHandlers 5 * but crashes when it's undefined. This guard provides a safe stub to prevent crashes. 6 * 7 * Issue: TypeError: undefined is not an object (evaluating 'window.webkit.messageHandlers') 8 * Browser: Instagram 400.1.0+ on iOS 9 * 10 * Served as a static external script (see src/components/InstagramCrashGuard.tsx) so it can run 11 * via next/script's "beforeInteractive" strategy without React 19's inline-script warning. 12 */ 13(function () { 14 try { 15 // Instagram In-App Browser detection 16 var isInstagram = /Instagram/i.test(navigator.userAgent); 17 18 if (isInstagram && typeof window !== 'undefined') { 19 // Polyfill window.webkit.messageHandlers to prevent Instagram's script from crashing 20 if (!window.webkit) { 21 // noinspection JSConstantReassignment 22 window.webkit = {}; 23 } 24 if (!window.webkit.messageHandlers) { 25 window.webkit.messageHandlers = {}; 26 } 27 28 // Stub for Instagram's translation handlers 29 ['IABTranslationJS', 'IABUserAgentLanguageDetectionJS'].forEach(function (handler) { 30 if (!window.webkit.messageHandlers[handler]) { 31 window.webkit.messageHandlers[handler] = { 32 postMessage: function (message) { 33 // Silent stub - prevent crash but don't break functionality 34 console.debug('[Instagram Guard] Intercepted message to', handler, message); 35 } 36 }; 37 } 38 }); 39 } 40 } catch (e) { 41 console.error('[Instagram Guard] Failed to initialize:', e); 42 } 43})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.