PageSourceSearch

https://www.international-adviser.com/wp-content/themes/ia-new/inc/assets/js/dtct.js?ver=7.0.6

js international-adviser.com collected 2026-10-02 03:57:38 UTC 5,082 bytes, 193 lines download raw bytes

1
2var boolLogging = true;
3var boolShowFallback = false;
4var boolGAEventFired = false;
5
6
7
8class Test {
9    state = 0;
10    reason = '';
11    
12    constructor(name, onload, funcStart, funcFinish = null) {
13        this.name = name;
14        this.onload = onload;
15        this.funcStart = funcStart;
16        this.funcFinish = funcFinish;
17    }
18
19    get blocked() {
20        return (this.state == -1);
21    }
22
23    get complete() {
24        return (this.state !== 0);
25    }
26
27    start() {
28        if (boolLogging) { console.time("Test" + this.name); }
29        this.funcStart();
30    }
31
32    finish(state, reason = '') {
33        if (boolLogging) { console.timeEnd("Test" + this.name); }
34        this.state = state;
35        this.reason = reason;
36
37        if (this.blocked) {
38            if (boolLogging) { console.log(`%cResult from [${this.name}] test: ${this.state} (Reason: ${this.reason})`, 'color: red'); }
39            doLogoFallback();
40        } else {
41            if (boolLogging) { console.log(`%cResult from [${this.name}] test: Not Blocked`, 'color: green'); }
42        }
43    }
44}
45
46var oTests = new Object();
47addTest('AdFire', false, testAdFire);
48addTest('Library', false, testLibrary);
49addTest('Block', true, testBlock);
50addTest('Dummy', false, testDummy);
51
52var iTestDummyVar = iTestDummyVar || 0;
53var signAbort;
54var iWait = 2000;
55var oWaitOpaque, oWaitAdfire;
56
57var boolWaiting = false;
58
59
60
61
62function testAdFire() {
63
64}
65
66function testLibrary() {
67    let sLibrary = 'https://securepubads.g.doubleclick.net/pagead/ppub_config?ippd=staging.international-adviser.com';
68
69    try {
70        let reqLibraryNoCors = new Request(sLibrary, {method: "HEAD", mode: "no-cors" });
71        let contRequest = new AbortController();
72        signAbort = contRequest.signal;
73    
74        fetch(reqLibraryNoCors, { signAbort } )
75            .then(response => {
76                if (response.ok) {
77                    if (response.redirected) {
78                        // ad block redirect?
79                        oTests['Library'].finish(-1, 'Redirected');
80    
81                    } else {
82                        // not blocked
83                        oTests['Library'].finish(1, '');
84                    }
85                } else {
86                    if (response.type == 'opaque') {
87                        doWaitOpaque();    
88                    } else {
89                        oTests['Library'].finish(-1, 'Response Not OK');    
90                    }
91                    
92                }
93            })
94            .catch(error => {
95                oTests['Library'].finish(-1, `Error: Likely Blocked At Browser`);   
96            });    
97    } catch (ex) {
98        oTests['Library'].finish(-1, 'Exception');   
99    }
100
101}
102
103function doWaitOpaque() {
104    if (!boolWaiting) {
105        boolWaiting = true;
106        oWaitOpaque = setTimeout(function() {
107            doCheck();
108        }, iWait);
109    }
110}
111
112function doCheck() {
113    if (googletag) {
114        if (googletag.getVersion() && googletag.getVersion() !== '') {
115            oTests['Library'].finish(1, 'Version Check Passed');
116        } else {
117            oTests['Library'].finish(-1, 'Version Check Failed [Empty]');
118        }
119    } else {
120        oTests['Library'].finish(-1, 'Version Check Failed [GT Null]');
121    }
122}
123
124function testBlock() {
125    const el = document.querySelector(".showy");
126    const displayStyle = window.getComputedStyle(el, null).display.toLowerCase();
127
128    if (el) {
129        if (el.clientHeight == 0 || el.clientWidth == 0 || displayStyle.startsWith("none")) {
130            // hidden
131            oTests['Block'].finish(-1, 'Block Hidden');
132
133        } else {
134            // shown
135            oTests['Block'].finish(1, '');
136        }    
137    } else {
138        // removed
139        oTests['Block'].finish(-1, 'Block Removed');
140    }
141}
142
143function testDummy() {
144    if (iTestDummyVar === 1) {
145        // library loaded
146        oTests['Dummy'].finish(1, '');
147    } else {
148        oTests['Dummy'].finish(-1, 'Variable Not Changed');
149    }
150}
151
152startTests(false);
153
154window.addEventListener("load", () => {
155    startTests(true);
156});
157
158function startTests(onload) {
159    Object.values(oTests).forEach(oTest => {
160        if (oTest.onload == onload) {
161            oTest.start();
162        }
163    });
164}
165
166function addTest(name, onload, funcStart, funcFinish = null) {
167    oTests[name] = new Test(name, onload, funcStart, funcFinish);
168}
169
170document.onreadystatechange = function () {
171    if (document.readyState == "complete" && !boolWaiting) {
172        showLogoFallback();
173    }
174}
175
176function showLogoFallback() {
177    
178    var elBody = document.querySelector('body');
179
180    if (elBody && !boolGAEventFired) {
181        elBody.classList.toggle("show-image", boolShowFallback);
182    }
183}
184
185function doLogoFallback() {
186    boolShowFallback = true;
187    showLogoFallback();
188}
189
190function doGtmCallback() {
191    //clearTimeout(oWaitOpaque);
192    //oTests['Library'].finish(1, 'opaque');
193}

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.