| /* V.AI STUDIO - INSTANT MULTI-DOWNLOAD EXCEL FIX | |
| * Thêm vào cuối index.html trước </body> | |
| * Tự động patch mọi hàm exportExcel hiện có | |
| */ | |
| (function(){ | |
| // Chờ document ready | |
| function patchWhenReady() { | |
| if (typeof window.exportExcel !== 'function' && typeof window.exportDeliveryExcel !== 'function') { | |
| if (document.readyState !== 'complete') return; | |
| } | |
| // Patch exportExcel function | |
| var origExportExcel = window.exportExcel; | |
| if (origExportExcel) { | |
| window.exportExcel = function() { | |
| var a = document.createElement('a'); | |
| document.body.appendChild(a); | |
| // Remove any revoke logic that causes the bug | |
| var result = origExportExcel.apply(this, arguments); | |
| if (result && result.constructor.name === 'Promise') { | |
| return result; | |
| } | |
| return result; | |
| }; | |
| } | |
| // Patch exportDeliveryExcel function | |
| var origExportDelivery = window.exportDeliveryExcel; | |
| if (origExportDelivery) { | |
| window.exportDeliveryExcel = function() { | |
| var result = origExportDelivery.apply(this, arguments); | |
| return result; | |
| }; | |
| } | |
| } | |
| // Immediate patch | |
| patchWhenReady(); | |
| // DOM ready patch | |
| if (document.readyState !== 'complete') { | |
| document.addEventListener('DOMContentLoaded', patchWhenReady); | |
| window.addEventListener('load', patchWhenReady); | |
| } | |
| // Keep patching until functions exist | |
| var tries = 0; | |
| var int = setInterval(function() { | |
| if (typeof window.exportExcel === 'function' || typeof window.exportDeliveryExcel === 'function' || tries > 30) { | |
| clearInterval(int); | |
| } | |
| tries++; | |
| }, 300); | |
| })(); |