File size: 2,178 Bytes
3b63ecd 41709e3 3b63ecd 41709e3 3b63ecd 41709e3 3b63ecd 41709e3 3b63ecd | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | /**
* V.AI STUDIO - Auto Excel Fix Loader v2.0
* Tự động tải fix script nếu chưa có, inject vào cuối body
*/
(function() {
'use strict';
// Kiểm tra xem file fix đã tồn tại chưa
var fixFile = 'vai-quote-excel-order-fix-v1050.js';
// Kiểm tra script đã load chưa
function checkFixLoaded() {
return typeof window.VAI_FIX !== 'undefined' ||
document.querySelector('script[src*="vai-quote-excel-order-fix"]');
}
// Inject script tag
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 script loaded successfully');
};
script.onerror = function() {
console.warn('[Auto Loader] Failed to load fix script, using inline fallback');
applyInlineFix();
};
document.head.appendChild(script);
}
// Inline fix fallback
function applyInlineFix() {
// Patch URL.revokeObjectURL
var originalRevoke = URL.revokeObjectURL;
URL.revokeObjectURL = function(url) {
if (url && url.startsWith('blob:')) {
setTimeout(function() {
try { originalRevoke.call(URL, url); } catch(e) {}
}, 300000);
return;
}
return originalRevoke.apply(this, arguments);
};
console.log('[Auto Loader] Inline fix applied');
}
// Chờ DOM ready
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', injectFix);
} else {
injectFix();
}
// Thử lại sau 2s nếu chưa load
setTimeout(injectFix, 2000);
setTimeout(injectFix, 5000);
})();
// Legacy support for older fix loaders
window.__VAI_BLOB_REGISTRY = window.__VAI_BLOB_REGISTRY || { blobs: [], registry: [], isUnloading: false }; |