PageSourceSearch

https://media.proprofs.com/includes/context-init.js

js proprofs.com collected 2026-09-24 07:02:02 UTC 18,077 bytes, 460 lines download raw bytes

1// Version 1.1.1
2
3(function () {
4  'use strict';
5
6var GTM_MAP = {
7  'proprofstraining.com':'GTM-W7F98Q3',
8  'webinarninja.com':'GTM-WMSLZWF',
9  'my.webinarninja.com':'GTM-WMSLZWF',  
10  'proprofs.com':'GTM-D2VF',
11  'proprofssurvey.com':'GTM-WR8WQ6F',
12  'qualaroo.com':'GTM-PQ6G9H',
13  'proprofskb.com':'GTM-M4697RM',
14  'dev.proprofskb.com':'GTM-M4697RM',
15  'proprofsdesk.com':'GTM-M5F4F7L',
16  'dev.proprofsdesk.com':'GTM-M5F4F7L',
17  'proprofschat.com':'GTM-WXNRRZ3',
18  'picreel.com':'GTM-TXLKV5V',
19  'bigcontacts.com':'GTM-WKFJ9HN',
20  'proprofsproject.com':'GTM-KTGLHR5',
21  'peoplegoal.com':'GTM-WTLTZ63',
22  'marriage.com':'GTM-KXDCGSR',
23  'dev.marriage.com':'GTM-KXDCGSR',
24  'proprofsgames.com':'GTM-WFRW2HF',
25  'dev.proprofsgames.com':'GTM-WFRW2HF',
26};
27
28var PRIVACY_MAP = {
29  'marriage.com': 'https://www.marriage.com/policies/privacy/'
30};
31
32var _hostname = window.location.hostname.replace(/^www\./, '');
33
34var MEDIAVINE_DOMAINS = ['proprofsgames.com', 'dev.proprofsgames.com', 'marriage.com','dev.marriage.com'];
35var _isMediavine = MEDIAVINE_DOMAINS.indexOf(_hostname) !== -1;
36
37
38  var GEO_ENDPOINT    = 'https://privacy-context.sameer-2c0.workers.dev/';
39  var GTM_ID = GTM_MAP[_hostname] || null;
40  var COOKIE_POLICY_URL = PRIVACY_MAP[_hostname] || 'https://www.proprofs.com/policies/privacy/';
41  var COOKIE_NAME     = 'pp_consent';
42  var COOKIE_DAYS     = 365;
43
44  function getCookie(name) {
45    var match = document.cookie.match(new RegExp('(?:^|; )' + name + '=([^;]*)'));
46    try { return match ? JSON.parse(decodeURIComponent(match[1])) : null; }
47    catch (e) { return null; }
48  }
49
50  function setCookie(name, value, days) {
51    var expires = new Date(Date.now() + days * 864e5).toUTCString();
52    document.cookie = name + '=' + encodeURIComponent(JSON.stringify(value))
53      + '; expires=' + expires
54      + '; path=/'
55      + '; SameSite=Lax';
56  }
57
58function loadGTM() {
59  if (window.__ppGTMLoaded) return;
60  if (!GTM_ID) {
61    console.warn('pp-consent: No GTM ID configured for', _hostname);
62    return;
63  }
64  window.__ppGTMLoaded = true;
65  window.dataLayer = window.dataLayer || [];
66  window.dataLayer.push({ 'gtm.start': new Date().getTime(), event: 'gtm.js' });
67  var s = document.createElement('script');
68  s.async = true;
69  s.src = 'https://www.googletagmanager.com/gtm.js?id=' + GTM_ID;
70  document.head.appendChild(s);
71}
72
73  /* CSS  */
74  function injectCSS() {
75    if (document.getElementById('pp-consent-css')) return;
76    var css = document.createElement('style');
77    css.id = 'pp-consent-css';
78    css.textContent = [
79      /* Bar */
80      '#pp-cookie-bar{display:none;position:fixed;bottom:0;left:0;right:0;z-index:99999;',
81      'background:#fff;border-top:1px solid rgba(0,0,0,.10);',
82      'box-shadow:0 -4px 24px rgba(0,0,0,.07);padding:16px 40px 18px;',
83      'flex-direction:column;gap:6px;',
84      'font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif;',
85      'animation:ppRise 0.4s cubic-bezier(.16,1,.3,1);}',
86      '@keyframes ppRise{from{transform:translateY(100%);opacity:0}to{transform:translateY(0);opacity:1}}',
87      '#pp-cookie-bar .pp-row{display:flex;align-items:center;justify-content:space-between;gap:24px;flex-wrap:wrap;}',
88      '#pp-cookie-bar .pp-text{font-size:13.5px;color:#1c1c1c;line-height:1.65;flex:1;min-width:260px;}',
89      '#pp-cookie-bar .pp-text strong{font-weight:600;font-size:14px;display:block;margin-bottom:2px;}',
90      '#pp-cookie-bar .pp-text a{color:#3b5998;text-decoration:none;font-weight:500;}',
91      '#pp-cookie-bar .pp-text a:hover{text-decoration:underline;}',
92      '#pp-cookie-bar .pp-manage-link{font-size:13px;color:#3b5998;background:none;border:none;',
93      'cursor:pointer;font-family:inherit;font-weight:500;text-decoration:underline;padding:0;}',
94      '#pp-cookie-bar .pp-manage-link:hover{color:#2d4373;}',
95      '#pp-cookie-bar .pp-actions{display:flex;align-items:center;gap:10px;flex-shrink:0;flex-wrap:wrap;}',
96      '#pp-cookie-bar .pp-sep{width:1px;height:20px;background:rgba(0,0,0,.12);flex-shrink:0;}',
97      '#pp-cookie-bar .pp-reject{font-size:13px;font-weight:500;padding:9px 20px;background:transparent;',
98      'color:#555;border:1px solid rgba(0,0,0,.20);border-radius:100px;cursor:pointer;font-family:inherit;',
99      'transition:border-color .15s,color .15s;white-space:nowrap;}',
100      '#pp-cookie-bar .pp-reject:hover{border-color:rgba(0,0,0,.40);color:#111;}',
101      '#pp-cookie-bar .pp-accept{font-size:13px;font-weight:700;padding:9px 24px;background:#1870d5;',
102      'color:#fff;border:none;border-radius:100px;cursor:pointer;font-family:inherit;',
103      'transition:background .15s;white-space:nowrap;box-shadow:0 2px 8px rgba(26,115,232,.25);}',
104      '#pp-cookie-bar .pp-accept:hover{background:#1260b8;}',
105      '#pp-cookie-bar .pp-note{font-size:11px;color:#aaa;text-align:right;margin-top:1px;}',
106      'body.pp-bar-open{padding-bottom:110px;}',
107
108      /* Modal */
109      '#pp-cookie-modal{display:none;position:fixed;inset:0;z-index:100000;',
110      'background:rgba(0,0,0,.45);align-items:center;justify-content:center;padding:20px;',
111      'font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif;}',
112      '#pp-cookie-modal.pp-open{display:flex;}',
113      '#pp-cookie-modal .pp-modal-box{background:#fff;border-radius:12px;',
114      'box-shadow:0 20px 60px rgba(0,0,0,.18);width:100%;max-width:520px;padding:28px;',
115      'animation:ppModalIn .22s cubic-bezier(.16,1,.3,1);}',
116      '@keyframes ppModalIn{from{opacity:0;transform:scale(.96) translateY(8px)}to{opacity:1;transform:scale(1) translateY(0)}}',
117      '#pp-cookie-modal .pp-modal-header{display:flex;justify-content:space-between;',
118      'align-items:flex-start;margin-bottom:16px;}',
119      '#pp-cookie-modal .pp-modal-header h3{font-size:17px;font-weight:600;color:#1c1c1c;margin:0;}',
120      '#pp-cookie-modal .pp-modal-close{background:none;border:1px solid rgba(0,0,0,.15);',
121      'border-radius:6px;cursor:pointer;font-size:14px;color:#999;',
122      'width:28px;height:28px;display:flex;align-items:center;justify-content:center;',
123      'padding:0;flex-shrink:0;transition:color .15s,border-color .15s;}',
124      '#pp-cookie-modal .pp-modal-close:hover{color:#333;border-color:rgba(0,0,0,.3);}',
125      '#pp-cookie-modal .pp-modal-intro{font-size:13px;font-weight:300;color:#666;line-height:1.65;',
126      'margin-bottom:20px;padding-bottom:16px;border-bottom:1px solid rgba(0,0,0,.07);}',
127      '#pp-cookie-modal .pp-modal-intro a{color:#3b5998;text-decoration:none;font-weight:500;}',
128      '#pp-cookie-modal .pp-modal-intro a:hover{text-decoration:underline;}',
129      '#pp-cookie-modal .pp-category{display:flex;justify-content:space-between;align-items:center;',
130      'padding:14px 0;border-bottom:1px solid rgba(0,0,0,.07);}',
131      '#pp-cookie-modal .pp-category:last-of-type{border-bottom:none;}',
132      '#pp-cookie-modal .pp-cat-info p{font-size:14px;font-weight:600;color:#1c1c1c;margin:0 0 2px;',
133      'display:flex;align-items:center;flex-wrap:wrap;gap:4px;}',
134      '#pp-cookie-modal .pp-cat-info span{font-size:12px;font-weight:300;color:#777;',
135      'line-height:1.6;display:block;margin-top:3px;}',
136      '.pp-always-on{font-size:11px;font-weight:500;color:#3b5998;margin-left:4px;letter-spacing:.01em;}',
137      '#pp-cookie-modal .pp-modal-footer{margin-top:22px;display:flex;gap:8px;justify-content:flex-end;}',
138      '#pp-cookie-modal .pp-btn-cancel{font-size:13px;padding:8px 16px;background:transparent;color:#666;',
139      'border:1px solid rgba(0,0,0,.18);border-radius:100px;cursor:pointer;font-family:inherit;}',
140      '#pp-cookie-modal .pp-btn-cancel:hover{border-color:rgba(0,0,0,.35);color:#222;}',
141      '#pp-cookie-modal .pp-btn-save{font-size:13px;font-weight:700;padding:8px 20px;',
142      'background:#1870d5;color:#fff;border:none;border-radius:100px;cursor:pointer;',
143      'font-family:inherit;transition:background .15s;}',
144      '#pp-cookie-modal .pp-btn-save:hover{background:#1260b8;}',
145
146      /* Toggle */
147      '.pp-toggle{position:relative;width:44px;height:24px;flex-shrink:0;}',
148      '.pp-toggle input{opacity:0;width:0;height:0;position:absolute;}',
149      '.pp-toggle-track{position:absolute;inset:0;background:#fff;border:2px solid #ccc;',
150      'border-radius:100px;cursor:pointer;transition:background .2s,border-color .2s;}',
151      '.pp-toggle-track:hover{border-color:#999;}',
152      '.pp-toggle input:checked+.pp-toggle-track{background:#1870d5;border-color:#1870d5;}',
153      '.pp-toggle input:disabled+.pp-toggle-track{background:#e8e8e8;border-color:#ddd;cursor:not-allowed;}',
154      '.pp-toggle-track::after{content:"";position:absolute;width:16px;height:16px;border-radius:50%;',
155      'background:#ccc;top:2px;left:2px;transition:transform .2s,background .2s;',
156      'box-shadow:0 1px 3px rgba(0,0,0,.15);}',
157      '.pp-toggle input:checked+.pp-toggle-track::after{background:#fff;transform:translateX(20px);}',
158      '.pp-toggle input:disabled+.pp-toggle-track::after{background:#bbb;transform:translateX(20px);}'
159    ].join('');
160    document.head.appendChild(css);
161  }
162
163  /* HTML INJECTION  */
164  function injectHTML() {
165    if (document.getElementById('pp-cookie-bar')) return;
166
167    /* Bar */
168    var bar = document.createElement('div');
169    bar.id = 'pp-cookie-bar';
170    bar.setAttribute('role', 'region');
171    bar.setAttribute('aria-label', 'Cookie consent');
172    bar.innerHTML =
173      '<div class="pp-row">' +
174        '<div class="pp-text">' +
175          '<strong>We use cookies</strong>' +
176          'We use cookies to keep our website running, understand how it is used, and improve our services. ' +
177          '<button class="pp-manage-link" onclick="ppConsent.openModal()">Manage your preferences</button>' +
178          ' or see our <a href="' + COOKIE_POLICY_URL + '" target="_blank">privacy policy</a>.' +
179        '</div>' +
180        '<div class="pp-actions">' +
181          '<div class="pp-sep"></div>' +
182          '<button class="pp-reject" onclick="ppConsent.reject()">Reject non-essential</button>' +
183          '<button class="pp-accept" onclick="ppConsent.accept()">Accept all</button>' +
184        '</div>' +
185      '</div>' +
186      '<div class="pp-note">This notice will remain until you make a selection.</div>';
187    document.body.appendChild(bar);
188
189    /* Modal */
190    var modal = document.createElement('div');
191    modal.id = 'pp-cookie-modal';
192    modal.setAttribute('role', 'dialog');
193    modal.setAttribute('aria-modal', 'true');
194    modal.setAttribute('aria-labelledby', 'pp-modal-title');
195    modal.innerHTML =
196  '<div class="pp-modal-box">' +
197    '<div class="pp-modal-header">' +
198      '<h3 id="pp-modal-title">Cookie Preference Center</h3>' +
199      '<button class="pp-modal-close" onclick="ppConsent.closeModal()" aria-label="Close">&#x2715;</button>' +
200    '</div>' +
201    '<p class="pp-modal-intro">' +
202      'We use cookies to ensure our website functions correctly and to better understand how it is used. ' +
203      'You can choose which categories of cookies to allow below. Your preferences can be updated at any ' +
204      'time using the Cookie Preferences link in our footer. ' +
205      '<a href="' + COOKIE_POLICY_URL + '" target="_blank">Learn more</a>.' +
206    '</p>' +
207    '<div class="pp-category">' +
208      '<div class="pp-cat-info">' +
209        '<p>Strictly Necessary Cookies <span class="pp-always-on">(always active)</span></p>' +
210        '<span>Essential for the website to function and cannot be switched off. ' +
211        'They support secure login, navigation, and access to protected areas.</span>' +
212      '</div>' +
213      '<label class="pp-toggle" title="Always on — cannot be disabled">' +
214        '<input type="checkbox" checked disabled>' +
215        '<span class="pp-toggle-track"></span>' +
216      '</label>' +
217    '</div>' +
218    '<div class="pp-category">' +
219      '<div class="pp-cat-info">' +
220        '<p>Non-Essential Cookies</p>' +
221        '<span>These cookies help us understand how visitors use our website, improve its performance ' +
222        'and user experience, and measure the effectiveness of our marketing efforts.</span>' +
223      '</div>' +
224      '<label class="pp-toggle">' +
225        '<input type="checkbox" id="pp-tog-nonessential">' +
226        '<span class="pp-toggle-track"></span>' +
227      '</label>' +
228    '</div>' +
229    '<div class="pp-modal-footer">' +
230      '<button class="pp-btn-cancel" onclick="ppConsent.closeModal()">Cancel</button>' +
231      '<button class="pp-btn-save" onclick="ppConsent.savePrefs()">Save preferences</button>' +
232    '</div>' +
233  '</div>';
234
235    modal.addEventListener('click', function (e) {
236      if (e.target === modal) ppConsent.closeModal();
237    });
238    document.body.appendChild(modal);
239  }
240
241  function showBar() {
242    var bar = document.getElementById('pp-cookie-bar');
243    if (!bar) return;
244    bar.style.display = 'flex';
245    document.body.classList.add('pp-bar-open');
246  }
247
248  function hideBar() {
249    var bar = document.getElementById('pp-cookie-bar');
250    if (!bar) return;
251    bar.style.transition = 'opacity .25s, transform .25s';
252    bar.style.opacity = '0';
253    bar.style.transform = 'translateY(8px)';
254    setTimeout(function () {
255      bar.style.display = 'none';
256      bar.style.opacity = '';
257      bar.style.transform = '';
258      bar.style.transition = '';
259    }, 260);
260    document.body.classList.remove('pp-bar-open');
261  }
262
263  function saveConsent(nonEssential) {
264    setCookie(COOKIE_NAME, {
265      nonEssential: nonEssential,
266      ts: Date.now()
267    }, COOKIE_DAYS);
268  }
269
270  window.ppConsent = {
271
272    accept: function () {
273      saveConsent(true);
274      loadGTM();
275      hideBar();
276    },
277
278    reject: function () {
279      saveConsent(false);
280      hideBar();
281    },
282
283    openModal: function () {
284      var saved = getCookie(COOKIE_NAME);
285      var tog = document.getElementById('pp-tog-nonessential');
286    
287      if (tog) {
288        if (saved) {
289          tog.checked = !!saved.nonEssential;
290        } else {
291          tog.checked = !!window.__ppGTMLoaded;
292        }
293      }
294    
295      var modal = document.getElementById('pp-cookie-modal');
296      if (modal) modal.classList.add('pp-open');
297    },
298
299    closeModal: function () {
300      var modal = document.getElementById('pp-cookie-modal');
301      if (modal) modal.classList.remove('pp-open');
302    },
303
304    savePrefs: function () {
305      var tog = document.getElementById('pp-tog-nonessential');
306      var nonEssential = tog ? tog.checked : false;
307      saveConsent(nonEssential);
308      if (nonEssential) loadGTM();
309      ppConsent.closeModal();
310      hideBar();
311    }
312  };
313
314  /* Mediavine domains only */
315  function waitForTCFConsent(callback) {
316    if (typeof window.__tcfapi !== 'function') {
317      console.log('__tcfapi not available yet');
318  
319      setTimeout(function () {
320        waitForTCFConsent(callback);
321      }, 200);
322  
323      return;
324    }
325  
326    window.__tcfapi('ping', 2, function (pingReturn) {
327     
328  
329      if (!pingReturn || !pingReturn.cmpLoaded) {
330        console.log('CMP not loaded yet');
331  
332        setTimeout(function () {
333          waitForTCFConsent(callback);
334        }, 200);
335  
336        return;
337      }
338  
339  
340      window.__tcfapi(
341        'addEventListener',
342        2,
343        function (tcData, success) {
344          console.log('TCF CALLBACK FIRED');
345          console.log('success:', success);
346          console.log('tcData:', tcData);
347  
348          if (!success || !tcData) {
349            return;
350          }
351  
352          if (
353            tcData.eventStatus === 'tcloaded' ||
354            tcData.eventStatus === 'useractioncomplete'
355          ) {
356            callback(tcData);
357          }
358        }
359      );
360    });
361  }
362
363  function init(requiresPriorConsent) {
364    var saved = getCookie(COOKIE_NAME);
365
366    if (requiresPriorConsent) {
367      injectCSS();
368      injectHTML();
369    
370      if (!saved) {
371        showBar();
372      } else if (saved.nonEssential) {
373        if (navigator.globalPrivacyControl === true) {
374          saveConsent(false);
375        } else {
376          loadGTM();
377        }
378      }
379    
380    } else {
381      injectCSS();
382      injectHTML();
383      if (!saved || saved.nonEssential !== false) {
384        loadGTM();
385      }
386    }
387  }
388/*
389  function run() {
390    if (_isMediavine) {
391      waitForTCFConsent(function(tcData) {
392        var hasConsent = tcData.gdprApplies === false ||
393          (tcData.purpose && tcData.purpose.consents && tcData.purpose.consents['1']);
394        if (hasConsent) {
395          loadGTM();
396        }
397      });
398      return;
399    }
400    fetch(GEO_ENDPOINT, { credentials: 'omit', cache: 'no-store' })
401      .then(function (r) { return r.json(); })
402      .then(function (data) {
403        init(data.requiresPriorConsent === true);
404      })
405      .catch(function () {
406        init(true);
407      });
408  }
409  */
410
411  function run() {
412    if (_isMediavine) {
413      loadGTM();
414      return;
415      fetch(GEO_ENDPOINT, { credentials: 'omit', cache: 'no-store' })
416        .then(function (r) { return r.json(); })
417        .then(function (data) {
418  
419          if (data.country === 'US') {
420            loadGTM();
421          } else {
422            waitForTCFConsent(function(tcData) {
423              var hasConsent = tcData.gdprApplies === false ||
424                (tcData.purpose && tcData.purpose.consents && tcData.purpose.consents['1']);
425              if (hasConsent) {
426                loadGTM();
427              }
428            });
429          }
430  
431        })
432        .catch(function () {
433          waitForTCFConsent(function(tcData) {
434            var hasConsent = tcData.gdprApplies === false ||
435              (tcData.purpose && tcData.purpose.consents && tcData.purpose.consents['1']);
436            if (hasConsent) {
437              loadGTM();
438            }
439          });
440        });
441  
442      return;
443    }
444  
445    fetch(GEO_ENDPOINT, { credentials: 'omit', cache: 'no-store' })
446      .then(function (r) { return r.json(); })
447      .then(function (data) {
448        init(data.requiresPriorConsent === true);
449      })
450      .catch(function () {
451        init(true);
452      });
453  }
454
455  if (document.readyState === 'loading') {
456    document.addEventListener('DOMContentLoaded', run);
457  } else {
458    run();
459  }
460})();

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.