PageSourceSearch

https://www.w3schools.com/lib/uic_prov.js?v=1.5.3

js w3schools.com collected 2026-09-24 08:23:53 UTC 21,071 bytes, 392 lines download raw bytes

1const adRnd = Math.random();
2let provider = (adRnd < 0.95 ? "sparteo" : "google");
3let pageType = "";
4
5const uic_prov_pre = (pt, provParam, subjectFolder) => {
6  if (pt == "default" || pt == "landing" || pt == "tryit" || pt == "tryitdb" || pt == "exercise" || pt == "xrcise" || pt == "video" || pt == "explainer" || pt == "practice" || pt == "challenge" || pt == "tut_xrcise" || pt == "tut_xrcise_fixed" || pt == "tools") { pageType = pt; }
7  if (pageType == "video" || pageType == "explainer" ) { provider = "sparteo"; }
8  if (provParam == "snigel" || provParam == "sparteo" || provParam == "google") { provider = provParam; }
9  if (!_uic_u_ok()) {
10    if (pageType != "landing") {
11      if (provider == "sparteo") {
12        window._hbdbrk = window._hbdbrk || [];
13        window._hbdbrk.push([
14          "_vars",
15          { page_type: pageType, custom1: subjectFolder, custom5: "unknown"}
16        ]);
17      } else if (provider == "google") {
18        window.googletag = window.googletag || {cmd: []};
19        if (pageType == "default" || pageType == "challenge" || pageType == "tut_xrcise" || pageType == "tut_xrcise_fixed" || pageType == "tools") {
20          googletag.cmd.push(function() {
21            let leaderMapping = googletag.sizeMapping().addSize([0, 0], [[320, 50], [300, 250]] ).addSize([512, 0], [[320, 50], [300, 250]]).addSize([774, 0], [[320, 50], [468, 60], [300, 250], [728, 90]]).addSize([993, 0], [[320, 50], [468, 60]]).addSize([1176, 0], [[320, 50], [468, 60], [728, 90]]).addSize([1465, 0], [[320, 50], [468, 60], [300, 250], [728, 90], [970, 90], [970, 250]]).build();
22            googletag.defineSlot('/16833175/MainLeaderboard', [[320, 50], [468, 60], [728, 90], [970, 90]], 'div-gpt-ad-1422003450156-2').defineSizeMapping(leaderMapping).addService(googletag.pubads());
23            let stickyMapping = googletag.sizeMapping().addSize([0, 0], []).addSize([992, 0], [120, 600]).addSize([1261, 0], [[120, 600], [160, 600]]).addSize([1701, 0], [[120, 600], [160, 600],  [300, 600], [300, 1050]]).build();
24            googletag.defineSlot('/16833175/StickySkyScraper', [[120, 600], [160, 600], [300, 600], [300, 1050]], 'div-gpt-ad-1472547360578-0').defineSizeMapping(stickyMapping).addService(googletag.pubads());
25            let mcontMapping = googletag.sizeMapping().addSize([0, 0], [[320, 50], [300, 250]] ).addSize([512, 0], [[320, 50], [300, 250]]).addSize([774, 0], [[320, 50], [468, 60], [300, 250], [728, 90]]).addSize([993, 0], [[320, 50], [468, 60]]).addSize([1176, 0], [[320, 50], [468, 60], [728, 90]]).addSize([1465, 0], [[320, 50], [468, 60], [300, 250], [728, 90], [970, 90], [970, 250]]).build();
26            googletag.defineSlot('/16833175/MidContent', [[300, 250], [336, 280], [320, 50], [468, 60], [728, 90], [970, 90]], 'div-gpt-ad-1493883843099-0').defineSizeMapping(mcontMapping).setCollapseEmptyDiv(true).addService(googletag.pubads());
27            googletag.pubads().enableSingleRequest();
28            googletag.pubads().setTargeting('page_section', subjectFolder);
29            googletag.pubads().disableInitialLoad();
30            googletag.pubads().setCentering(true);
31          });
32        } else if (pageType == "exercise" || pageType == "xrcise") {
33          googletag.cmd.push(function() {
34            let leaderMapping = googletag.sizeMapping().addSize([0, 0], [320, 50]).addSize([468, 0], [[320, 50], [468, 60]]).addSize([728, 0], [[320, 50], [468, 60], [728, 90]]).addSize([970, 0], [[320, 50], [468, 60], [728, 90], [970, 90]]).build();
35            googletag.defineSlot('/16833175/TryitLeaderboard', [[320, 50], [468, 60], [728, 90], [970, 90]], 'div-gpt-ad-1428407818244-0').defineSizeMapping(leaderMapping).addService(googletag.pubads());
36            googletag.pubads().enableSingleRequest();
37            googletag.pubads().setTargeting('page_section', subjectFolder);
38            googletag.pubads().disableInitialLoad();
39            googletag.pubads().setCentering(true);
40          });
41        } else if (pageType == "tryitdb" || pageType == "tryit") {
42          googletag.cmd.push(function() {
43            let leaderMapping = googletag.sizeMapping().addSize([0, 0], [320, 50]).addSize([468, 0], [[320, 50], [468, 60]]).addSize([728, 0], [[320, 50], [468, 60], [728, 90]]).addSize([970, 0], [[320, 50], [468, 60], [728, 90], [970, 90]]).build();
44            googletag.defineSlot('/16833175/TryitLeaderboard', [[320, 50], [468, 60], [728, 90], [970, 90]], 'div-gpt-ad-1428407818244-0').defineSizeMapping(leaderMapping).addService(googletag.pubads());
45            let stickyMapping = googletag.sizeMapping().addSize([0, 0], []).addSize([992, 0], [[120, 600], [160, 600]]).addSize([1820, 0], [160, 600]).addSize([1683, 0], [[120, 600], [160, 600], [300, 250], [300, 600], [300, 1050]]).build();
46            googletag.defineSlot('/16833175/StickySkyScraper', [[120, 600], [160, 600], [300, 250], [300, 600], [300, 1050]], 'div-gpt-ad-1472547360578-0').defineSizeMapping(stickyMapping).addService(googletag.pubads());
47            googletag.pubads().enableSingleRequest();
48            googletag.pubads().setTargeting('page_section', subjectFolder);
49            googletag.pubads().disableInitialLoad();
50            googletag.pubads().setCentering(true);
51          });
52        }
53      }
54    }
55  } else if (_uic_u_ok()) {
56    if (pageType == "video") {
57      window._hbdbrk = window._hbdbrk || [];
58      window._hbdbrk.push([
59        "_vars",
60        { page_type: pageType, custom1: subjectFolder, custom5: "premium" }
61      ]);
62    }
63  }
64  if ( (!_uic_u_ok() && (pageType != "landing")) || (_uic_u_ok() && (pageType == "video"))) {
65    (function(){
66    const provLoader=document.createElement('script');
67    provLoader.type='text/javascript';
68    if (provider == "sparteo") {
69      provLoader.async=true;
70      provLoader.setAttribute("data-cfasync", "false");
71      provLoader.src='https://www.flashb.id/universal/55f786fc-6e0e-5368-ade6-451e5d54251d.js';
72    } else if ( provider == "snigel") {
73      provLoader.async=true;
74      provLoader.src='https://cdn.snigelweb.com/adengine/w3schools.com/loader.js';
75    } else if ( provider == "google") {
76      provLoader.async=true;
77      provLoader.src='https://securepubads.g.doubleclick.net/tag/js/gpt.js';
78      provLoader.setAttribute("crossorigin", "anonymous");
79    }
80    (document.getElementsByTagName('head')[0]||document.getElementsByTagName('body')[0]).appendChild(provLoader);
81    })();
82  }
83}
84
85const uic_prov_sec = () => {
86  if (!_uic_u_ok()) {
87    if (provider == "sparteo" && (pageType == "default" || pageType == "video" || pageType == "challenge" || pageType == "tut_xrcise" || pageType == "tut_xrcise_fixed" || pageType == "tools")) {
88      window.addEventListener("scroll", fix_stickyad);
89      window.addEventListener("resize", fix_stickyad);
90    } else {
91      if (pageType == "default" || pageType == "video" || pageType == "challenge" || pageType == "tut_xrcise" || pageType == "tut_xrcise_fixed" || pageType == "tools") {
92        const mainHeight = Number(w3_getStyleValue(document.getElementById("main"), "height").replace("px", ""));
93        if (provider == "google") {
94          const midAdElement = document.getElementById("div-gpt-ad-1493883843099-0");
95          if (mainHeight > 2000) {
96            if (midAdElement) {
97              googletag.cmd.push(function () { googletag.display('div-gpt-ad-1493883843099-0'); });
98              googletag.cmd.push(function () { googletag.display('div-gpt-ad-1472547360578-0'); });
99            } else {
100              googletag.cmd.push(function () { googletag.display('div-gpt-ad-1472547360578-0'); });
101            }
102          } else if (midAdElement) { 
103            googletag.cmd.push(function () { googletag.display('div-gpt-ad-1493883843099-0'); });
104          }
105          googletag.enableServices();
106          googletag.pubads().refresh();
107        }
108        window.addEventListener("scroll", fix_stickyad);
109        window.addEventListener("resize", fix_stickyad);
110      } else if (pageType == "tryitdb" || pageType == "tryit") {
111        if (provider == "google") {
112          googletag.cmd.push(function () { googletag.display('div-gpt-ad-1472547360578-0'); });
113          googletag.enableServices();
114          googletag.pubads().refresh();
115        }
116      } else if (pageType == "xrcise") {       
117        if (provider == "google") {
118          googletag.enableServices();
119          googletag.pubads().refresh();
120        }
121      }
122    }
123  }
124}
125
126const uic_prov_al = () => {
127  const mainLeaderboard = document.getElementById("mainLeaderboard");
128  const midContent = document.getElementById("midcontentadcontainer");
129  const wideSkyscraper = document.getElementById("skyscraper");
130  const vidPos = document.getElementById("vidpos");
131  const stickySkyscraper = document.getElementById("stickyadcontainer");
132  const bottom = document.getElementById("bottomads");
133  const tryitLeaderboard = document.getElementById("tryitLeaderboard");
134  const sqlstickyadcontainer = document.getElementById("sqlstickyadcontainer");
135  const bottomPlacement = document.getElementById("bottomad");
136  const internalAd = document.getElementById("upperfeatureshowcaselink");
137  const stickyPos = document.getElementById("stickypos");
138  if (_uic_u_ok()) {
139    if (pageType == "default" || pageType == "video" || pageType == "challenge" || pageType == "tut_xrcise" || pageType == "tut_xrcise_fixed" || pageType == "tools") {
140      if (mainLeaderboard) { mainLeaderboard.remove(); }
141      if (midContent) {
142        const previousSibling = midContent.previousElementSibling;
143        if (previousSibling) { previousSibling.remove(); }
144        midContent.remove();
145      }
146      const mainElement = document.getElementById("main");
147      if (mainElement) {
148        mainElement.classList.remove("l10");
149        mainElement.classList.add("l12");
150        mainElement.style.width = "100%";
151        mainElement.style.borderRight = "none";
152      }
153      const rightElement = document.getElementById("right");
154      if (rightElement) { rightElement.remove(); }
155      if (bottom.length > 0) {
156        const bottomAdParentElement = bottom[0].parentElement;
157        if (bottomAdParentElement) {
158          const previousElement = bottomAdParentElement.previousElementSibling;
159          if (previousElement) { previousElement.remove(); }
160          bottomAdParentElement.remove();
161        }
162      }
163      if (typeof fix_stickyad === "function") { 
164        window.removeEventListener("scroll", fix_stickyad);
165        window.removeEventListener("resize", fix_stickyad);
166      }
167    } else if (pageType == "tryit") {
168      if (tryitLeaderboard) { tryitLeaderboard.remove(); }
169      const breadcrumb = document.getElementById("breadcrumb");
170      const container = document.getElementById("container");
171      const tryTopNav = document.getElementsByClassName("trytopnav");
172      const dragBar = document.getElementById("dragbar");
173      if (breadcrumb) {
174        if (tryTopNav.length > 0) { tryTopNav[0].style.top = "40px"; }
175        if (dragBar) { dragBar.style.top = "85px"; }
176        if (container) { container.style.top = "85px"; }
177      } else {
178        if (container) {
179          if (tryTopNav.length > 0) { tryTopNav[0].style.top = "0px"; }
180          if (dragBar) { dragBar.style.top = "45px"; }
181          container.style.top = "45px";
182          container.style.setProperty("width", "calc(100%)", "important");
183          tryTopNav[0].style.setProperty("width", "calc(100%)", "important");
184        } else {
185          const altContainer = document.getElementsByClassName("container");
186          if (altContainer.length > 0) { altContainer[0].style.top = "0px"; }
187        }
188      }
189    } else if (pageType == "tryitdb") {
190      document.getElementById("tryitLeaderboard").remove();
191      document.getElementById("sqlstickyadcontainer").remove();
192    } else if (pageType == "xrcise") {
193      document.getElementById("tryitLeaderboard").parentElement.parentElement.remove();
194    } else if (pageType == "exercise") {
195      if (tryitLeaderboard) { tryitLeaderboard.parentElement.parentElement.remove();}
196      document.getElementById("menubtn").style.left = "";
197      document.getElementById("menubtn").style.right = "20px";
198      document.getElementById("assignmenttext").previousElementSibling.style.textAlign = "center";
199      document.getElementById("assignmenttext").previousElementSibling.style.marginTop = "0";
200      document.getElementById("assignmenttext").previousElementSibling.style.paddingTop = "0";
201      document.getElementById("menubtn").style.top = "40px";
202    }
203  } else {
204    if (pageType == "default" || pageType == "video" || pageType == "challenge" || pageType == "tut_xrcise" || pageType == "tut_xrcise_fixed" || pageType == "tools") {
205      (function(){
206        let provLeaderboard=document.createElement('div');
207        if (provider == "google") {
208          provLeaderboard.id='div-gpt-ad-1422003450156-2';
209        }
210        if (mainLeaderboard) {
211          mainLeaderboard.appendChild(provLeaderboard);
212          if (provider == "google") { googletag.cmd.push(function () { googletag.display('div-gpt-ad-1422003450156-2'); });}
213        }
214      })();
215      (function(){
216        if (provider == "sparteo") {
217          // TESTING: limited to one page. Delete these two lines to enable every yt_container page.
218          if (location.pathname.indexOf("/html/html_comments.asp") == -1) { return; }
219          const ytContainer = document.getElementById("yt_container");
220          if (ytContainer && ytContainer.dataset.vsly) {
221            let dedVid = document.createElement('div');
222            dedVid.className = "vsly-player";
223            dedVid.id = ytContainer.dataset.vsly;
224            dedVid.dataset.template = "PVftMJpdG3wEX"
225            dedVid.style = "background:#ddd;font-size:0;position:relative;overflow:hidden;width:100%;padding-top:56.25%;";
226            if (stickyPos) {
227              stickyPos.appendChild(dedVid);
228            }
229          }
230        }
231      })();
232
233      (function(){
234        let provMidContent=document.createElement('div');
235        if (provider == "google") {
236          provMidContent.id='div-gpt-ad-1493883843099-0';
237          provMidContent.style='display: inline-block;';
238        }
239        if (midContent) {
240          midContent.appendChild(provMidContent); 
241          (function () {
242            let removeAdContainer = document.createElement('p');
243            removeAdContainer.className = 'remove-ads-container';
244            let removeAdLink = document.createElement('a');
245            removeAdLink.className = 'remove-ads ga-featured ga-remove-ads';
246            removeAdLink.href = 'https://order.w3schools.com/plans';
247            removeAdLink.target = '_blank';
248            removeAdLink.rel = 'noopener';
249            removeAdLink.textContent = 'REMOVE ADS';
250            removeAdContainer.appendChild(removeAdLink);
251            midContent.appendChild(removeAdContainer);
252          })();       
253        }
254      })();
255      (function(){
256        let provStickySky=document.createElement('div');
257        if (provider == "google") {
258          provStickySky.id='div-gpt-ad-1472547360578-0';
259        }
260        if (stickySkyscraper && stickySkyscraper.style.display != "none") {
261          stickySkyscraper.children[0].appendChild(provStickySky);
262        } else {
263          stickySkyscraper.remove();
264          if (typeof fix_stickyad === "function") { 
265            window.removeEventListener("scroll", fix_stickyad);
266            window.removeEventListener("resize", fix_stickyad);
267          }
268        }
269      })();
270    } else if (pageType == "tryit" || pageType == "xrcise" || pageType == "exercise" || pageType == "tryitdb" ) {
271      if (provider=="google") {
272        if (pageType == "xrcise") { document.getElementById("exercise_main_leaderboard").style.setProperty('display', 'block', 'important'); }
273        if (pageType == "tryit" || pageType == "exercise") { document.getElementById("tr
273yitLeaderboard").style.setProperty('display', 'block', 'important'); }
274      }
275      let mainWidth = "0";
276      (function(){
277        let provLeaderboard=document.createElement('div');
278        if (provider == "google" && pageType == "tryit") {
279          mainWidth = Number(w3_getStyleValue(document.getElementsByTagName("body")[0], "width").replace("px", ""));
280          if (mainWidth > 1008) {
281            let provDBSky=document.createElement('div');
282            tryitLeaderboard.style.height="0";
283            provDBSky.id='div-gpt-ad-1472547360578-0';
284            provDBSky.style = "width: 240px; height: 100%; background-color: #FFF; right: 10px; float:right; padding: 4px; box-sizing: border-box;";
285            if (document.getElementById("container")) { document.getElementById("container").after(provDBSky); }
286          } else {
287            provLeaderboard.id='div-gpt-ad-1428407818244-0';
288            tryitLeaderboard.style.height="90px";
289            if (tryitLeaderboard) { tryitLeaderboard.appendChild(provLeaderboard); }
290          }      
291        } else {
292          provLeaderboard.id='div-gpt-ad-1428407818244-0';
293          if (tryitLeaderboard) { tryitLeaderboard.appendChild(provLeaderboard); }
294        }
295      })();
296      if (pageType == "tryitdb") {
297        (function(){
298          let provDBSky=document.createElement('div');
299          if (provider == "google") {
300            provDBSky.id='div-gpt-ad-1472547360578-0';
301          }
302          if (sqlstickyadcontainer) { sqlstickyadcontainer.appendChild(provDBSky); }
303        })();
304      }
305      if (provider == "google") {
306        if (pageType == "tryit" && mainWidth > 1008) {
307          googletag.cmd.push(function () { googletag.display('div-gpt-ad-1472547360578-0'); });
308        } else {
309          googletag.cmd.push(function () { googletag.display('div-gpt-ad-1428407818244-0'); });
310        }
311      } 
312      if (pageType == "xrcise") {
313        (function () {
314          const xrciseForm = document.querySelector("#xrcise-container form");
315          if (!xrciseForm) { return; }
316          const placeRemoveAdsLine = function () {
317            if (xrciseForm.querySelector(".remove-ads-container")) { return true; }
318            let adHost = null;
319            for (let i = 0; i < xrciseForm.children.length; i++) {
320              const child = xrciseForm.children[i];
321              if (child.querySelector && child.querySelector('[id^="id-"], [id^="div-gpt-ad"], [id^="google_ads_iframe"]')) {
322                adHost = child;
323                break;
324              }
325            }
326            if (!adHost) { return false; }
327            let removeAdContainer = document.createElement('p');
328            removeAdContainer.className = 'remove-ads-container';
329            removeAdContainer.style.marginBottom = '5px';
330            let removeAdLink = document.createElement('a');
331            removeAdLink.className = 'remove-ads ga-exercise ga-remove-ads';
332            removeAdLink.href = 'https://order.w3schools.com/plans';
333            removeAdLink.target = '_blank';
334            removeAdLink.rel = 'noopener';
335            removeAdLink.textContent = 'REMOVE ADS';
336            removeAdLink.style.setProperty('color', '#fff', 'important');
337            removeAdContainer.appendChild(removeAdLink);
338            xrciseForm.insertBefore(removeAdContainer, adHost);
339            return true;
340          };
341          if (placeRemoveAdsLine()) { return; }
342          const adWatcher = new MutationObserver(function () {
343            if (placeRemoveAdsLine()) { adWatcher.disconnect(); }
344          });
345          adWatcher.observe(xrciseForm, { childList: true, subtree: true });
346          window.setTimeout(function () { adWatcher.disconnect(); }, 20000);
347        })();
348      }
349    }
350    docReady(function() {
351      let checkReadyState = setInterval(function () {
352        if (document.readyState === "interactive" || document.readyState === "complete") {
353          clearInterval(checkReadyState);
354          // Ensure FastCMP (__tcfapi) is loaded and CMP is ready before running uic_prov_sec
355          let checkFastCmp = setInterval(function () {
356            if (typeof window.__tcfapi !== "function") {
357              return;
358            }
359            window.__tcfapi('ping', 2, function (res, success) {
360              if (!success || !res) {
361                return;
362              }
363              if (res.cmpLoaded && res.cmpStatus !== 'stub') {
364                clearInterval(checkFastCmp);
365                uic_prov_sec();
366              }
367            });
368          }, 300); // check every 300ms
369        }
370      }, 300); // check every 300ms
371    });
372
373  }
374}
375
376const uic_prov_run = () => {
377  if (!_uic_u_ok()) {
378    const sqlstickyadcontainer = document.getElementById("sqlstickyadcontainer");
379    if (pageType == "tryit" || pageType == "exercise" || pageType == "tryitdb" ) {
380      if (provider == "google") {
381        googletag.cmd.push(function () { googletag.display('div-gpt-ad-1428407818244-0'); });
382        googletag.pubads().refresh();
383      }
384      if (sqlstickyadcontainer) {
385        if (provider == "google") {
386          googletag.cmd.push(function () { googletag.display('div-gpt-ad-1472547360578-0'); });
387          googletag.pubads().refresh();
388        }
389      }
390    }
391  }
392}

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.