PageSourceSearch

https://www.harpersbazaar.com.hk/javascript/overwriteEventListener.js

js harpersbazaar.com.hk collected 2026-10-02 06:17:01 UTC 1,724 bytes, 48 lines download raw bytes

1(function(){
2  const addEventHook = window.addEventListener
3  window.addEventListener = function() {
4    let finalArguments = arguments
5    const originCb = arguments[1]
6    try {
7      if (arguments[0] === 'message') {
8        //iasAdx : Only receive message from Google iframe
9        if (arguments[1].toString()?.includes('setIframesHtmlContents') && arguments[1].toString()?.includes('slotRenderEnded')) {
10          const cb = (t) => {
11            if(!t || !(t.origin && t.origin.includes('googlesyndication.com'))) return
12            originCb(t)
13          }
14          finalArguments[1] = cb
15          console.log('Overwrite iasADX message')
16        }
17        
18      }
19    } catch (err) {
20      console.error(err)
21    }
22    addEventHook.apply(window, finalArguments)
23  }
24  window.googletag = window.googletag || { cmd: [] };
25  if(!window.googletag.cmd) return
26  window.googletag.cmd.push(function() {
27    const gamAddEventHook = window.googletag.pubads().addEventListener
28    window.googletag.pubads().addEventListener = function() {
29      let finalArguments = arguments
30      try {
31        if (arguments?.[0]  === 'slotRenderEnded' && arguments[1].toString()?.includes('.matchSlotToHtml') && arguments[1].toString()?.includes('.isBackfill')) {
32          const originCb = arguments[1]
33          const cb = (t) =>{
34            originCb(t)
35            setTimeout(()=>{
36              // Avoiding duplicate event callbacks
37              window.googletag.pubads().removeEventListener('slotRenderEnded',cb)
38            },2000)
39          }
40          finalArguments[1] = cb
41        }
42      } catch (err) {
43        console.error(err)
44      }
45      gamAddEventHook.apply(window.googletag.pubads(), finalArguments)
46    }
47  })
48})()

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.