V.AISTUDIO / EXCEL_FIX_BOOKMARK.js
bep40's picture
Upload EXCEL_FIX_BOOKMARK.js
94e690d verified
Raw
History Blame
2.18 kB
/* === V.AI STUDIO EXCEL MULTI-DOWNLOAD FIX ===
* Copy toàn bộ nội dung này vào Bookmark URL (bookmarklet)
* Hoặc paste vào Console (F12) để chạy ngay
*/
(function(){
'use strict';
console.log('[VAI EXCEL FIX] Starting...');
// Blob registry để không revoke ngay
window._excelBlobRegistry = window._excelBlobRegistry || [];
// Cleanup khi đóng tab
function cleanupBlobs() {
window._excelBlobRegistry.forEach(function(e){
try { URL.revokeObjectURL(e.url); } catch(err) {}
});
window._excelBlobRegistry = [];
}
window.addEventListener('pagehide', cleanupBlobs);
window.addEventListener('beforeunload', cleanupBlobs);
window.addEventListener('unload', cleanupBlobs);
// Override URL.revokeObjectURL - không revoke blob URL
var origRevoke = URL.revokeObjectURL;
URL.revokeObjectURL = function(url) {
if (!url || typeof url !== 'string' || !url.startsWith('blob:')) {
return origRevoke.call(this, url);
}
var exists = window._excelBlobRegistry.find(function(e){ return e.url === url; });
if (!exists) {
window._excelBlobRegistry.push({url: url, created: Date.now()});
return;
}
return origRevoke.call(this, url);
};
// Override setTimeout - chặn revoke 60s
var origSetTimeout = window.setTimeout;
window.setTimeout = function(fn, delay) {
try {
var fnStr = fn.toString();
if (fnStr.includes('revokeObjectURL') && delay === 60000) {
console.log('[FIX] Blocked 60s revoke timeout');
return null;
}
} catch(e) {}
return origSetTimeout.apply(this, arguments);
};
// Load script fix nếu chưa có
if (typeof window.exportExcel !== 'function' || typeof window._doExportExcel !== 'function') {
var s = document.createElement('script');
s.src = 'https://huggingface.co/spaces/bep40/V.AISTUDIO/resolve/main/qr-payment-v1039.js?_t=' + Date.now();
document.head.appendChild(s);
}
console.log('[VAI EXCEL FIX] Applied successfully - Excel multi-download ready');
alert('✅ Excel multi-download fix đã áp dụng!\nBây giờ bạn có thể tải Excel nhiều lần.');
})();