| |
| |
| |
| |
| |
| |
| (function() { |
| 'use strict'; |
| |
| |
| var fixFile = 'vai-excel-fix-v2.js'; |
| var fixFileLegacy = 'vai-quote-excel-order-fix-v1050.js'; |
| |
| |
| function checkFixLoaded() { |
| return (typeof window.VAI_EXCEL_FIX !== 'undefined') || |
| (typeof window.VAI_FIX !== 'undefined') || |
| document.querySelector('script[src*="vai-excel-fix"]'); |
| } |
| |
| |
| function injectFix() { |
| if (checkFixLoaded()) { |
| console.log('[Auto Loader] Fix script already loaded'); |
| return; |
| } |
| |
| var script = document.createElement('script'); |
| script.src = '/' + fixFile + '?v=' + Date.now(); |
| script.onload = function() { |
| console.log('[Auto Loader] Excel fix v2 loaded successfully - multi-download enabled'); |
| }; |
| script.onerror = function() { |
| console.warn('[Auto Loader] v2 failed, trying legacy fix'); |
| var legacy = document.createElement('script'); |
| legacy.src = '/' + fixFileLegacy + '?v=' + Date.now(); |
| legacy.onload = function() { |
| console.log('[Auto Loader] Legacy fix loaded'); |
| }; |
| document.head.appendChild(legacy); |
| }; |
| |
| document.head.appendChild(script); |
| } |
| |
| |
| function applyInlineFix() { |
| var originalRevoke = URL.revokeObjectURL; |
| URL.revokeObjectURL = function(url) { |
| if (!url || typeof url !== 'string') return originalRevoke.apply(this, arguments); |
| if (url.startsWith('blob:')) { |
| |
| window.__VAI_BLOB_REGISTRY = window.__VAI_BLOB_REGISTRY || { blobs: [], isUnloading: false }; |
| window.__VAI_BLOB_REGISTRY.blobs.push({ url: url, revoked: false }); |
| window.addEventListener('beforeunload', function() { |
| window.__VAI_BLOB_REGISTRY.isUnloading = true; |
| window.__VAI_BLOB_REGISTRY.blobs.forEach(function(b) { |
| if (!b.revoked) try { URL.revokeObjectURL(b.url); b.revoked = true; } catch(e) {} |
| }); |
| }); |
| return; |
| } |
| return originalRevoke.apply(this, arguments); |
| }; |
| |
| console.log('[Auto Loader] Inline fallback applied'); |
| } |
| |
| |
| if (document.readyState === 'loading') { |
| document.addEventListener('DOMContentLoaded', injectFix); |
| } else { |
| injectFix(); |
| } |
| |
| |
| setTimeout(injectFix, 2000); |
| setTimeout(injectFix, 5000); |
| |
| })(); |
|
|
| |
| window.__VAI_BLOB_REGISTRY = window.__VAI_BLOB_REGISTRY || { blobs: [], registry: [], isUnloading: false }; |