bep40 commited on
Commit
85574f2
·
verified ·
1 Parent(s): c18274e

Upload excel-multi-fix-instant.js

Browse files
Files changed (1) hide show
  1. excel-multi-fix-instant.js +55 -0
excel-multi-fix-instant.js ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* V.AI STUDIO - INSTANT MULTI-DOWNLOAD EXCEL FIX
2
+ * Thêm vào cuối index.html trước </body>
3
+ * Tự động patch mọi hàm exportExcel hiện có
4
+ */
5
+ (function(){
6
+ // Chờ document ready
7
+ function patchWhenReady() {
8
+ if (typeof window.exportExcel !== 'function' && typeof window.exportDeliveryExcel !== 'function') {
9
+ if (document.readyState !== 'complete') return;
10
+ }
11
+
12
+ // Patch exportExcel function
13
+ var origExportExcel = window.exportExcel;
14
+ if (origExportExcel) {
15
+ window.exportExcel = function() {
16
+ var a = document.createElement('a');
17
+ document.body.appendChild(a);
18
+
19
+ // Remove any revoke logic that causes the bug
20
+ var result = origExportExcel.apply(this, arguments);
21
+ if (result && result.constructor.name === 'Promise') {
22
+ return result;
23
+ }
24
+ return result;
25
+ };
26
+ }
27
+
28
+ // Patch exportDeliveryExcel function
29
+ var origExportDelivery = window.exportDeliveryExcel;
30
+ if (origExportDelivery) {
31
+ window.exportDeliveryExcel = function() {
32
+ var result = origExportDelivery.apply(this, arguments);
33
+ return result;
34
+ };
35
+ }
36
+ }
37
+
38
+ // Immediate patch
39
+ patchWhenReady();
40
+
41
+ // DOM ready patch
42
+ if (document.readyState !== 'complete') {
43
+ document.addEventListener('DOMContentLoaded', patchWhenReady);
44
+ window.addEventListener('load', patchWhenReady);
45
+ }
46
+
47
+ // Keep patching until functions exist
48
+ var tries = 0;
49
+ var int = setInterval(function() {
50
+ if (typeof window.exportExcel === 'function' || typeof window.exportDeliveryExcel === 'function' || tries > 30) {
51
+ clearInterval(int);
52
+ }
53
+ tries++;
54
+ }, 300);
55
+ })();