File size: 770 Bytes
c258daa
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
(function () {
  function overrideContent() {
    // Style overrides
    document.querySelectorAll('h1').forEach(h => h.style.color = 'red');
    document.querySelectorAll('p').forEach(p => p.style.color = 'coral');
    document.body.style.backgroundColor = 'green';

    // Intercept <a> tag clicks to trigger dynamic loading
    document.querySelectorAll('a').forEach(a => {
      a.addEventListener('click', function (e) {
        e.preventDefault();
        const targetUrl = this.href;
        window.parent.postMessage({ type: 'navigate', url: targetUrl }, '*');
      });
    });
  }

  if (document.readyState !== 'loading') {
    overrideContent();
  } else {
    document.addEventListener('DOMContentLoaded', overrideContent);
  }
})();