Spaces:
Running
Running
Upload static/wc_shorts_inject.js
Browse files- static/wc_shorts_inject.js +36 -0
static/wc_shorts_inject.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* WC Shorts Inject — Chạy SAU app_v2.js
|
| 3 |
+
*/
|
| 4 |
+
(function(){
|
| 5 |
+
'use strict';
|
| 6 |
+
function inject(){
|
| 7 |
+
const wcSection = document.getElementById('wc2026-live-section');
|
| 8 |
+
const homeEl = document.getElementById('view-home');
|
| 9 |
+
if(!homeEl) return;
|
| 10 |
+
if(document.getElementById('wc-shorts-slide-section')) return;
|
| 11 |
+
if(typeof renderWCSSlideSection !== 'function'){ setTimeout(inject, 500); return; }
|
| 12 |
+
const div = document.createElement('div');
|
| 13 |
+
div.id = 'wc-shorts-slide-container-tmp'; div.style.display = 'none';
|
| 14 |
+
if(wcSection && wcSection.parentNode){ wcSection.parentNode.insertBefore(div, wcSection); }
|
| 15 |
+
else { homeEl.insertBefore(div, homeEl.firstChild); }
|
| 16 |
+
renderWCSSlideSection(div);
|
| 17 |
+
const section = div.querySelector('.wc-shorts-slide-section');
|
| 18 |
+
if(section){
|
| 19 |
+
section.id = 'wc-shorts-slide-section';
|
| 20 |
+
if(wcSection && wcSection.parentNode) wcSection.parentNode.insertBefore(section, wcSection);
|
| 21 |
+
div.remove();
|
| 22 |
+
}
|
| 23 |
+
}
|
| 24 |
+
if(document.readyState === 'loading') document.addEventListener('DOMContentLoaded', ()=> setTimeout(inject, 800));
|
| 25 |
+
else setTimeout(inject, 800);
|
| 26 |
+
const origLoadHome = window.loadHome;
|
| 27 |
+
if(origLoadHome){
|
| 28 |
+
window.loadHome = function(){
|
| 29 |
+
const result = origLoadHome.apply(this, arguments);
|
| 30 |
+
setTimeout(inject, 200); setTimeout(inject, 800); setTimeout(inject, 2000);
|
| 31 |
+
return result;
|
| 32 |
+
};
|
| 33 |
+
}
|
| 34 |
+
let retries = 0;
|
| 35 |
+
const retryIv = setInterval(()=>{ retries++; inject(); if(retries > 20) clearInterval(retryIv); }, 1000);
|
| 36 |
+
})();
|