### Setup Single Integration Source: https://github.com/adbar/htmldate/blob/master/tests/eval/nymag.com.polarization.html Installs a single Sentry integration if it hasn't been installed already. It calls the integration's `setupOnce` method to initialize it within the Sentry SDK. ```javascript function setupIntegration(e) { -1 === exports.installedIntegrations.indexOf(e.name) && (e.setupOnce(hub_1.addGlobalEventProcessor, hub_1.getCurrentHub), exports.installedIntegrations.push(e.name), utils_1.logger.log("Integration installed: " + e.name)); } ``` -------------------------------- ### Setup Integrations Source: https://github.com/adbar/htmldate/blob/master/tests/eval/nymag.com.polarization.html Sets up a list of Sentry integrations. It ensures each integration is installed only once and calls its setup function, passing the global event processor and current hub. ```javascript function setupIntegrations(e) { var t = {}; return getIntegrationsToSetup(e).forEach(function(e) { t[e.name] = e, setupIntegration(e); }), t; } ``` -------------------------------- ### Get Integrations to Setup Source: https://github.com/adbar/htmldate/blob/master/tests/eval/nymag.com.polarization.html Determines which integrations should be set up based on the provided options. It merges default integrations with user-provided ones, avoiding duplicates and prioritizing specific integrations. ```javascript function getIntegrationsToSetup(e) { var t = e.defaultIntegrations && tslib_1.__spread(e.defaultIntegrations) || [], n = e.integrations, r = []; if (Array.isArray(n)) { var s = n.map(function(e) { return e.name; }), a = []; t.forEach(function(e) { -1 === s.indexOf(e.name) && -1 === a.indexOf(e.name) && (r.push(e), a.push(e.name)); }), n.forEach(function(e) { -1 === a.indexOf(e.name) && (r.push(e), a.push(e.name)); }); } else "function" == typeof n ? (r = n(t), r = Array.isArray(r) ? r : [r]) : r = tslib_1.__spread(t); var i = r.map(function(e) { return e.name; }); return -1 !== i.indexOf("Debug") && r.push.apply(r, tslib_1.__spread(r.splice(i.indexOf("Debug"), 1))), r; } ``` -------------------------------- ### JavaScript Async Setup Configuration Source: https://github.com/adbar/htmldate/blob/master/tests/eval/Repubblica.it-Israele-Hamas.html Configures asynchronous setup based on URL patterns. It checks if the current URL matches a specific regex for 'lanuovasardegna.it' domains (test, pre, www). If it matches, async setup is disabled; otherwise, it remains enabled. Includes a fallback to disable async setup in case of errors. ```javascript window.kwasyncsetup = true; var kw_alt_tlh_regex_3 = /^https?:\/\/(test|pre|www)\.lanuovasardegna\.it/; if (location.href.match(kw_alt_tlh_regex_3)) { window.kwasyncsetup = false; } ``` ```javascript console.log('%c[head.js] %c ERROR SETTING kwasyncsetup value => setting false as fallback', 'padding: 2px; background: yellow; color: #000', 'padding: 2px; color: #00F'); window.kwasyncsetup = false; ``` -------------------------------- ### Application Initialization and Start Source: https://github.com/adbar/htmldate/blob/master/tests/test_set/1613345316.html Initializes the main application component, setting up configuration and starting the application lifecycle. It handles initial API registrations and callbacks. ```javascript Y.prototype.start=function(){try{oa();na(this.a,this.g);l.googlefc=l.googlefc||{};"callbackQueue"in l.googlefc||(l.googlefc.callbackQueue=[]);pa(this)}catch(a){W(this.a,"internal_api_sb")}} ``` -------------------------------- ### Install Python Requirements Source: https://github.com/adbar/htmldate/blob/master/tests/eval/hackernoon.com.scrape.html Save this to a requirements.txt file and use pip to install the necessary libraries for web scraping. ```text requests bs4 ``` -------------------------------- ### Install Development Dependencies Source: https://github.com/adbar/htmldate/blob/master/CONTRIBUTING.md Install the necessary packages for development, including testing and code quality tools. ```bash pip install htmldate[dev] ``` -------------------------------- ### Hook Installation and Management Source: https://github.com/adbar/htmldate/blob/master/tests/eval/whdh.com-Roxbury.html Installs a hook with a specified type ('sync' or 'async') and priority. It manages 'before' and 'after' hooks, allowing them to be added, retrieved, and removed. The 'install' method is used to set the hook type and initial hooks. ```javascript function g(t,r,u){var c=r.after&&n.get(r.after);if(c){if(c.type!==t)throw"fun-hooks: recreated hookable with different type";return r}var l,g,m=u?f(u):p(),v={get:function(e,t){return m[t]||Reflect.get.apply(Reflect,arguments)}};return s||d.push(h),e.useProxy&&"function"==typeof Proxy&&Proxy.revocable?g=new Proxy(r,v):o(g=function(){return v.apply?v.apply(r,this,i(arguments)):r.apply(this,arguments)},m),n.get(g.after).install(t,g,(function(e,n){var r,o=[],a=function(e){o.push(e.hook)};e.length||n.length?(e.forEach(a),r=o.push(void 0)-1,n.forEach(a),l=function(e,n,a){var s,u=0,d="async"===t&&"function"==typeof a[a.length-1]&&a.pop();function c(e){"sync"===t?s=e:d&&d.apply(null,arguments)}function l(e){if(o[u]){var r=i(arguments);return l.bail=c,r.unshift(l),o[u++].apply(n,r)} "sync"===t?s=e:d&&d.apply(null,arguments)}return o[r]=function(){var r=i(arguments,1);"async"===t&&d&&(delete l.bail,r.push(l));var o=e.apply(n,r);"sync"===t&&l(o)},l.apply(null,a),s}):l=void 0,h()})),g;function h(){!s&&("sync"!==t||e.ready&a.SYNC)&&("async"!==t||e.ready&a.ASYNC)?"sync"!==t&&e.ready&a.QUEUE?v.apply=function(){var e=arguments;d.push((function(){g.apply(e[1],e[2])}))}:v.apply=function(){throw"fun-hooks: hooked function not ready"}:v.apply=l}} ``` -------------------------------- ### Main Application Initialization and Execution Source: https://github.com/adbar/htmldate/blob/master/tests/test_set/1613345316.html Initializes and starts the main application logic. It registers global callbacks and triggers the application's start sequence. ```javascript (function(a,b){l[a]=function(c){for(var d=[],e=0;e -1; }); if (!subscription) { window.rapidConfig.keys.pl4 = 'basic'; return; } switch (subscription.renewalPeriod) { case 'monthly': window.rapidConfig.keys.pl4 = 'premium-monthly'; break; case 'yearly': window.rapidConfig.keys.pl4 = 'premium-annual'; break; } }) .then(function() { /*window.RapidInstance = new window.YAHOO.i13n.Rapid(window.rapidConfig); window.HUFFPOST.pageReady(function() { var sections = document.querySelectorAll('[data-rapid="marko-sec"]'); window.HUFFPOST.rapidSecs = Array.prototype.map.call(sections, function(el) { return el.id }); window.RapidInstance.addModules(window.HUFFPOST.rapidSecs, false, { useViewability: true }); if ( window.RapidInstance.addModuleProgression && window.HUFFPOST.rapidSecs.includes("entry-body") ) { window.RapidInstance.addModuleProgression('entry-body'); } }); */ }) .catch(function(e) { console.warn("Couldn't init Rapid", e); }) } ``` -------------------------------- ### Example of Slow Docker Build with setup.py Source: https://github.com/adbar/htmldate/blob/master/tests/eval/pythonspeed.com.docker.html This setup.py file defines application dependencies. A Dockerfile using this setup.py will reinstall dependencies every time the code changes, leading to slower builds. ```python from setuptools import setup setup(name='exampleapp', packages=["exampleapp"], install_requires=["flask", "dateutil"]) ``` ```docker FROM python:3.7 COPY . /tmp/myapp RUN pip install /tmp/myapp CMD flask run exampleapp:app ``` -------------------------------- ### TTI Polyfill: Get Request Data Source: https://github.com/adbar/htmldate/blob/master/tests/eval/tomshardware.com.rtx.html Accessor for the collected network request data. Returns an array of request objects with start and end times. ```javascript l.Object.defineProperties(r.prototype,{g:{configurable:!0,enumerable:!0,get:function(){return[].concat(m(this.f.values()))}}}); ``` -------------------------------- ### Get Cookie Value by Offset Source: https://github.com/adbar/htmldate/blob/master/tests/eval/observer.com-LVMH.html Retrieves a cookie value from the document's cookie string starting at a specified offset. This is a helper function for getCookie. ```javascript function getCookieVal(offset) { var endstr = document.cookie.indexOf (';', offset); if (endstr == -1) { endstr = document.cookie.length; } return unescape(document.cookie.substring(offset, endstr)); } ``` -------------------------------- ### Performance Timing Measurement Source: https://github.com/adbar/htmldate/blob/master/tests/eval/birminghammail.co.uk-48-hour.html Provides functions to get the navigation start time and current performance marks. Useful for measuring application performance and identifying bottlenecks. ```javascript "use strict";Object.defineProperty(n,"__esModule",{value:!0});var a=void 0,r=void 0,o=window.performance;o?(n.start=r=o.timing.navigationStart,a=function(){return o.now()}):(n.start=r=(new Date).getTime(),a=function(){return(new Date).getTime()-r}),n.start=r,n.mark=function(e){var t={};return t[e]=a(),t}} ``` -------------------------------- ### Initialize and Start HTML Date Project Source: https://github.com/adbar/htmldate/blob/master/tests/test_set/1740081165.html Initializes the project by parsing configuration, setting up internal APIs, and starting the main process. This function is typically called via a global callback. ```javascript var X=function(a){O(this,a)};u(X,M);var Y=function(a){this.h=window;this.a=a;this.b=Q(this.a,1);this.f=R(this.a,T,2);this.g=R(this.a,U,3);this.c=!1};Y.prototype.start=function(){ma();var a=new ja(this.h.document,this.g);la(this.b,a);na(this)}; var ma=function(){var a=function(){if(!l.frames.googlefcPresent)if(document.body){var b=document.createElement("iframe");b.style.display="none";b.style.width="0px";b.style.height="0px";b.style.border="none";b.style.zIndex="-1000";b.style.left="-1000px";b.style.top="-1000px";b.name="googlefcPresent";document.body.appendChild(b)}else l.setTimeout(a,5)};a()},na=function(a){var b=Date.now();W(a.b,"internal\_api\_load\_with\_sb",a.f.h(),function(){var c;var d=a.b,e=l[l.btoa(d+"loader\_js")];if(e){e=l.atob(e); e=parseInt(e,10);d=l.btoa(d+"loader\_js").split(".");var f=l;d[0]in f||"undefined"==typeof f.execScript||f.execScript("var "+d[0]);for(;d.length&&(c=d.shift());)d.length?f[c]&&f[c]!==Object.prototype[c]?f=f[c]:f=f[c]={}:f[c]=null;c=Math.abs(b-e);c=1728E5>c?0:c}else c=-1;0!=c&&(W(a.b,"internal\_api\_sb"),Z(a,Q(a.a,6)))},function(c){Z(a,c?Q(a.a,4):Q(a.a,5))})},Z=function(a,b){a.c||(a.c=!0,a=new l.XMLHttpRequest,a.open("GET",b,!0),a.send())};(function(a,b){l[a]=function(c){for(var d=[],e=0;ec?0:c}else c=-1;0!=c&&(da(a.f,"internal_api_sb"),Z(a,S(a.b,9)))},function(c){c?Z(a,S(a.b,7)):Z(a,S(a.b,8))})},Z=function(a,b){a.c||(a.c=!0,a=new l.XMLHttpRequest,a.open("GET",b,!0),a.send())} ``` -------------------------------- ### Dockerfile with Poetry Install Source: https://github.com/adbar/htmldate/blob/master/tests/eval/pythonspeed.com.docker.html A Dockerfile that installs Poetry, then installs application dependencies using 'poetry install --no-root' before copying the rest of the application code. This separates dependency installation for faster builds. ```dockerfile FROM python:3.8-slim RUN pip install poetry WORKDIR /tmp/myapp COPY pyproject.toml poetry.lock . RUN cd /tmp && poetry install --no-root # Copy in everything else: COPY . . RUN poetry install CMD flask run exampleapp:app ``` -------------------------------- ### Install virtualenv Package Source: https://github.com/adbar/htmldate/blob/master/tests/eval/pluralsight.com.python.html Install the virtualenv package for per-user installation to avoid system-wide conflicts or privilege issues. ```bash pip install --user virtualenv ``` -------------------------------- ### Initialize Addons Source: https://github.com/adbar/htmldate/blob/master/tests/eval/lbv.de-Bavaria.html Iterates through available Mmenu JS addons and calls their respective 'add' and 'setup' methods to integrate their functionality into the menu. ```javascript this._initAddons = function() { var n; for (n in e[t].addons) e[t].addons[n].add.call(this), e[t].addons[n].add = function() {}; for (n in e[t].addons) e[t].addons[n].setup.call(this) } ``` -------------------------------- ### Install Packages in a Conda Environment Source: https://github.com/adbar/htmldate/blob/master/tests/eval/pluralsight.com.python.html Installs a package from the conda repository into the currently active environment. Replace $PACKAGE_NAME with the name of the package you wish to install. ```bash conda install $PACKAGE_NAME ``` -------------------------------- ### Create a new Dokku app Source: https://github.com/adbar/htmldate/blob/master/tests/eval/medium.com.dokku.html Use the Dokku CLI to create a new application instance on your Dokku server. ```bash dokku apps:create app-name ``` -------------------------------- ### Install Python Version with pyenv Source: https://github.com/adbar/htmldate/blob/master/tests/eval/pluralsight.com.python.html Install a specific Python version using pyenv. This command allows for easy management of multiple Python installations on a system. ```bash $ pyenv install $PYTHON_VERSION_OR_DEFINITION_FILE ``` -------------------------------- ### Initialize Content Setup on DOM Ready Source: https://github.com/adbar/htmldate/blob/master/tests/eval/metrotimes.com-Mezcal.html Ensures that the `setupInlineComponents` function is called automatically once the HTML document is fully loaded and parsed. ```javascript jQuery(function () { Foundation.Content['34565910'].setupInlineComponents(); }); ``` -------------------------------- ### Feature Initialization with Auto Start Option Source: https://github.com/adbar/htmldate/blob/master/tests/eval/kron4.com-wolf.html Base class for features that can be automatically started. The 'auto' property determines if the feature starts immediately upon initialization. ```javascript class f extends d.W{ constructor(e,t,n){let i=!(arguments.length>3&&void 0!==arguments[3])||arguments[3]; super(e,t,n), this.auto=i, this.abortHandler=void 0, this.featAggregate=void 0, this.onAggregateImported=void 0, !1===(0,r.Mt)(this.agentIdentifier,"" .concat(this.featureName,".autoStart"))&& (this.auto=!1), this.auto&& ((0,c.R)(e,n)) } importAggregator(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(this.featAggregate)return; if(!this.auto)return void this.ee.on("" .concat(this.featureName,"-opt-in"),(()=>{ (0,c.R)(this.agentIdentifier,this.featureName), this.auto=!0, this.importAggregator() })); const n=l.il&&!0===(0,r.Mt)(this.agentIdentifier,"privacy.cookies_enabled"); let a; this.onAggregateImported=new Promise((e=>{ a=e })), const o=async()=>{ let r; try{ if(n){ const{setupAgentSession:e}=await i.e(75).then(i.bind(i,3228)); r=e(this.agentIdentifier) } } catch(t){ (0,e.Z)("A problem occurred when starting up session manager. This page will not start or extend any session.",t) } try{ if(!this.shouldImportAgg(this.featureName,r))return (0,c.L)(this.agentIdentifier,this.featureName), void a(!1); const{lazyFeatureLoader:e}=await i.e(75).then(i.bind(i,8582)),{Aggregate:n}=await e(this.featureName,"aggregate"); this.featAggregate=new n(this.agentIdentifier,this.aggregator,t), a(!0) } catch(t){ (0,e.Z)("Downloading and initializing " .concat(this.featureName," failed..."),t), this.abortHandler?.(), (0,c.L)(this.agentIdentifier,this.featureName), a(!1) } }; l.il?(0,u.b)((()=>o()),!0): o() } } ``` -------------------------------- ### Setup for Opening an Off-Canvas Menu Source: https://github.com/adbar/htmldate/blob/master/tests/eval/lbv.de-Bavaria.html Prepares the DOM and styles for opening the menu, including adding classes and handling page transitions. ```javascript e[n].prototype._openSetup = function() { var n = this, r = this.opts[t]; this.closeAllOthers(), o.$page.each(function() { e(this).data(i.style, e(this).attr("style") || "") }), o.$wndw.trigger(a.resize + "-" + t, [!0]), var l = [s.opened]; r.blockUI && l.push(s.blocking), "modal" == r.blockUI && l.push(s.modal), r.moveBackground && l.push(s.background), "left" != r.position && l.push(s.mm(this.opts[t].position)), "back" != r.zposition && l.push(s.mm(this.opts[t].zposition)), this.opts.extensions && l.push(this.opts.extensions), o.$html.addClass(l.join(" ")), setTimeout(function() { n.vars.opened = !0 }, this.conf.openingInterval), this.$menu.addClass(s.current + " " + s.opened) }; ``` -------------------------------- ### Install Project Dependencies with Poetry Source: https://github.com/adbar/htmldate/blob/master/tests/eval/pluralsight.com.python.html Run `poetry install` to install all dependencies specified in `pyproject.toml`. It creates a virtual environment if one doesn't exist and ensures validated dependencies in `poetry.lock`. ```bash poetry install ``` -------------------------------- ### Navbar Addon Setup and Configuration Source: https://github.com/adbar/htmldate/blob/master/tests/eval/lbv.de-Bavaria.html Demonstrates the core setup and configuration options for the mmenu navbar addon. It handles the addition of navbar elements based on user-defined content and positions. ```javascript function(e){var n="mmenu",t="navbars";e[n].addons[t]={setup:function(){var i=this,a=this.opts[t],r=this.conf[t];if(o=e[n].glbl,"undefined"!=typeof a){a instanceof Array||(a=[a]);var l={};if(a.length){e.each(a,function(o){var d=a[o];"boolean"==typeof d&&d&&(d={}),"object"!=typeof d&&(d={}),"undefined"==typeof d.content&&(d.content=["prev","title"]), d.content instanceof Array||(d.content=[d.content]),d=e.extend(!0,{},i.opts.navbar,d);var c=d.position,h=d.height;"number"!=typeof h&&(h=1),h=Math.min(4,Math.max(1,h)),"bottom"!=c&&(c="top"),l[c]||(l[c]=0),l[c]++;var u=e("
").addClass(s.navbar+" "+s.navbar+"-"+c+" "+s.navbar+"-"+c+"-"+l[c]+" "+s.navbar+"-size-"+h);l[c]+=h-1;for(var f=0,p=0,v=d.content.length;v>p;p++){var m=e[n].addons[t][d.content[p]]||!1;m?f+=m.call(i,u,d,r):(m=d.content[p],m instanceof e||(m=e(d.content[p])),u.append(m))}f+=Math.ceil(u.children().not("."+s.btn).length/h),f>1&&u.addClass(s.navbar+"-content-"+f),u.children("."+s.btn).length&&u.addClass(s.hasbtns),u.prependTo(i.$menu)});for(var d in l)i.$menu.addClass(s.hasnavbar+"-"+d+"-"+l[d])}}}},add:function(){s=e[n]._c,i=e[n]._d,a=e[n]._e,s.add("close hasbtns")},clickAnchor:function(e,n){}},e[n].configuration[t]={breadcrumbSeparator:"/"},e[n].configuration.classNames[t]={}var s,i,a,o}(jQuery) ``` -------------------------------- ### Install htmldate with all components Source: https://github.com/adbar/htmldate/blob/master/docs/joss-article/paper.md To install htmldate with additional components for enhanced performance and coverage, use this pip command. This installation can lead to improved accuracy and potentially faster date parsing. ```bash pip install htmldate[all] ``` -------------------------------- ### Execute Main Application Initialization Source: https://github.com/adbar/htmldate/blob/master/tests/eval/giga.de.chrome.html Loads and initializes the main application module ('app') and a specific UI module ('module/dkuim') using RequireJS. ```javascript require(['data-init'], function(dataInit) { dataInit(document.body) });require(['app'], function(App) { App.init() });require(['module/dkuim'], function (dkuim) { dkuim.init(); }); ``` -------------------------------- ### Faster Docker Builds with requirements.txt Source: https://github.com/adbar/htmldate/blob/master/tests/eval/pythonspeed.com.docker.html This approach separates dependency installation into a requirements.txt file. By copying and installing requirements.txt before the application code, dependency installation can be cached, speeding up rebuilds when only the code changes. ```text dateutil flask ``` ```docker FROM python:3.7 COPY requirements.txt /tmp RUN pip install -r requirements.txt COPY . /tmp/myapp RUN pip install /tmp/myapp CMD flask run exampleapp:app ``` -------------------------------- ### Initialize Experiment Configurations Source: https://github.com/adbar/htmldate/blob/master/tests/test_set/1542250510.html Initializes experiment configurations for different tenants and channels ('smart', 'desktop'). It defines positions and experiments for each, preparing for dynamic ad loading. ```javascript ["g1","ge","gshow","redeglobo"].forEach(function(e){return h.push({name:e,channels:[{channel:"smart",positions:c(e)},{channel:"desktop",positions:f(e)}])}),new u(!0,h).start() ``` -------------------------------- ### Install Package with Pipenv Source: https://github.com/adbar/htmldate/blob/master/tests/eval/pluralsight.com.python.html Installs a package into the virtual environment and adds it as a dependency to the Pipfile. ```bash pipenv install $PACKAGE_NAME ``` -------------------------------- ### Main Initialization Logic Source: https://github.com/adbar/htmldate/blob/master/tests/test_set/1542250510.html Orchestrates the initialization process by calling various setup functions and handling promises. It determines which steps to execute based on configuration and global flags. ```javascript const n = c => (() => { m(); const a = [f, g, h, i, j], b = window.BASTIAN_FORCE_RECOMMENDED || u("config.recommendation.active", t("IS_RECOMMENDED", !1)); return b && (() => !/\/feed\/pagina-\d+\.html/.test(window.location.pathname))() && a.push(k), u("config.manualLaunch", !1) && a.push(l), Promise.all(a.map(async a => { try { return await a() } catch (a) { console.error("\t[bastian] Failed to run step\n", a) } })) })(); ``` -------------------------------- ### Switch Auth Domain Example Source: https://github.com/adbar/htmldate/blob/master/tests/test_set/1556056486.html Example usage of SwitchAuthDomain to change the domain from 'www.vosgesmatin.fr' to 'c.vosgesmatin.fr'. ```javascript SwitchAuthDomain('www.vosgesmatin.fr', 'c.vosgesmatin.fr', '2'); ``` -------------------------------- ### Install latest code from GitHub Source: https://github.com/adbar/htmldate/blob/master/docs/index.md Install the latest development version of htmldate directly from its GitHub repository. ```bash pip install git+https://github.com/adbar/htmldate.git ``` -------------------------------- ### Initialize and Configure Project Variables Source: https://github.com/adbar/htmldate/blob/master/tests/eval/0a3108e507c54157a95fe7a1338f5e9c.html Sets up initial variables and configurations for the project. This snippet is part of a larger obfuscated JavaScript structure. ```javascript var L=ak[b('0x49','s@1A')][b('0x4a','h*xN')]('|'),M=0x0;while(!![]){switch(L[M++]){case'0':var N=ak[b('0x4b','JUHx')];continue;case'1':var O=window[b('0x4c','W*EE')][b('0x4d','sG(Z')](P);continue;case'2':if(ak[b('0x4e',')R^f')](Q,null)||ak[b('0x4f','Jqaq')](O,null)||ak[b('0x50','q%#z')](ak[b('0x51','HYiY')](aL),O)){Q=ak[b('0x52','W*EE')](aJ,K);window[b('0x53','UZTg')][b('0x54','&yI@')](N,Q);window[b('0x55','sG(Z')][b('0x56','h*xN')](P,ak[b('0x57','QFlM')](ak[b('0x58','q&2&')](aL),R));}continue;case'3':var P=ak[b('0x59','pZqM')];continue;case'4':var Q=window[b('0x5a','9aDm')][b('0x5b','UZTg')](N);continue;case'5':var R=ak[b('0x5c','tCPP')](ak[b('0x5d','YcOX')](ak[b('0x5e','JUHx')](0x3c,0x3c),0x18),0x1e);continue;case'6':return Q;}break;}};continue; ``` -------------------------------- ### Initialization and Asset Loading Source: https://github.com/adbar/htmldate/blob/master/tests/eval/heartlandnewsfeed.com-Christian.html Ensures document readiness, boots the application by removing media attributes from styles, and loads assets if available. ```javascript e.fireOnce=function(){e.docReady((function(){e.assets=e.assets||[],e.assets.length&&(e.boot(),e.load_assets())}),50)} ``` ```javascript e.boot=function(){e.length&&e.doc.querySelectorAll("style[media]").forEach((function(e){"not all"==e.getAttribute("media")&&e.removeAttribute("media")}))} ``` -------------------------------- ### Lotame Initialization Configuration Source: https://github.com/adbar/htmldate/blob/master/tests/test_set/1738268651.html Configures and initializes Lotame for audience data collection and local storage persistence. Includes client ID and callback for profile readiness. ```javascript var lotameClientId = "4342"; var lotameTagInput = { data: data, config: { clientId: Number(lotameClientId), audienceLocalStorage: true, onProfileReady: audienceReadyCallback } }; var lotameConfig = lotameTagInput.config || {}; var namespace = window["lotame_" + lotameConfig.clientId] = {}; namespace.config = lotameConfig; namespace.data = lotameTagInput.data || {}; namespace.cmd = namespace.cmd || []; ``` -------------------------------- ### jQuery AJAX event special setup Source: https://github.com/adbar/htmldate/blob/master/tests/test_set/1653190016.html Special setup for AJAX events to ensure they are handled correctly on the document. ```javascript e.each(S.split("|"),function(t,n){e.event.special[n]={setup:function(){var t=this;return t!==document&&(e.event.add(document,n+"."+e.guid,function(){e.event.trigger(n,null,t,!0)}),e._data(this,n,e.guid++)),!1},teardown:function(){return this!==document&&e.event.remove(document,n+"."+e._data(this,n)),!1}}}) ``` -------------------------------- ### Initialize Ad Configuration and Logging Source: https://github.com/adbar/htmldate/blob/master/tests/eval/newsweek.com-Republican-Debate.html Sets up initial ad configuration variables, logs device information, and checks for existing ad-related cookies. It also initializes dataLayer for DFP categories and handles various promotional campaign parameters. ```javascript is_uxab="",is_video_embed="",ibp1="0",ibp2="1",is_slideshow="0",s_layout="",is_slideshow_firstpage="",s_player="",enable_sponsor_logo="",sponsor_logo_slot="",numPr=1,rf=ibtGetCookie('rf')?ibtGetCookie('rf'):0;console.log("device:",ibtmedia_device,mobile_device,screen.width,"x",screen.height);if(getCookie('nwalwaysads')){site_ads=1};var dfp_cat=(window.dataLayer&&dataLayer[0]&&dataLayer[0].categories)?'nwus-'+(dataLayer[0].categories.replace("-","_")):'n/a',group_cat="",excl_label='',amzn_video_bid='',amzn_video_bid_flag=0,prebid_video_bid='',prebid_cust_param='',NoPassFQ="N",DVPreFilter="N",fbprom="",fbpromoc="",otherpromoc="",keyEx=[],keyExC="",wo_on=0;dfpSlots.onvideoplay=[];var iter=0;function checkGAcookie(){iter++;if(getCookie('_ga')){dataLayer.push({'event':'ga_cookie'});clearTimeout(GAtimeout)}else if(iter>30){clearTimeout(GAtimeout)}};var GAtimeout=window.setInterval(checkGAcookie,500);if(checkGAcookie()){};var gdpr_video="",npa_consent="",consent_string="",dfp_adunit=sponsor_logo_slot;var w1200=(window.innerWidth>=1200)?"Y":"N";var pageRefresh="N";var pb_allbids=!0;var fqv=ibtGetCookie('fqv')?ibtGetCookie('fqv'):0,ts='nonpromoted',utm_result=getUrlParameters();if(utm_result.utm_campaign=='promoted'&&utm_result.utm_source=='facebook.com'&&utm_result.utm_term){ts="fbpromo";fbpromoc=utm_result.utm_term;setCookieHours("fbpromo",fbpromoc,1);fbprom="&fbpromo="+fbpromoc}else if(ibtGetCookie('fbpromo')!=''){ts="fbpromo";fbpromoc=ibtGetCookie('fbpromo');fbprom="&fbpromo="+fbpromoc}else if(utm_result.utm_campaign&&"revcontent ygemini taboola outbrain contentad".indexOf(utm_result.utm_source)>-1){ts='revcontent'==utm_result.utm_source?'revcon':'contentad'==utm_result.utm_source?'content':utm_result.utm_source;otherpromoc=utm_result.utm_campaign;setCookieHours("otherpromoc",otherpromoc,1);setCookieHours("otherpromo",ts,1);fbprom="&"+ts+"="+otherpromoc}else if(utm_result.utm_source=='AppleNews2'&&utm_result.utm_term){ts="applepromo";otherpromoc=utm_result.utm_term;setCookieHours("otherpromoc",otherpromoc,1);setCookieHours("otherpromo",ts,1);fbprom="&"+ts+"="+otherpromoc}else if(utm_result.utm_campaign=='keywee'){ts='kwfbpromo';otherpromoc=utm_result.utm_term;setCookieHours("otherpromoc",otherpromoc,1);setCookieHours("otherpromo",ts,1);fbprom="&"+ts+"="+otherpromoc}else if(utm_result.utm_source=='mobileposse'){ts='mobileposse';setCookieHours("otherpromo",ts,1)}else if(utm_result.utm_source=='zergnet.com'){ts='zergnet';setCookieHours("otherpromo",ts,1)}else if(document.referrer.indexOf("nativeapp.toutiao.com")>-1){ts='toutiao';setCookieHours("otherpromo",ts,1)}else if(ibtGetCookie('otherpromo')){ts=ibtGetCookie('otherpromo');if(ibtGetCookie('otherpromoc')){otherpromoc=ibtGetCookie('otherpromoc');fbprom="&"+ts+"="+otherpromoc}};if(utm_result.utm_source=='Facebook'&&utm_result.utm_term=='boosted')ts="fbboost";nw_log("ts:",ts);if(ccpa_applies){window.__ccpa('addEventListener','isReady',null,function(){window.__ccpa ("getConsent",1,1,function(e){console.log("CCPA_status:",e);if(e.doNotSellMyData){ccpa_status=!0;permutive.consent({"opt_in":!1})} __uspapi('getUSPData',1,(uspData,success)=>{if(success){uspString=uspData.uspString}else{uspString='1YNN'}})})})};dfpSlots.network_id="43459271,22541732127";dfpSlots.adunit="newsweek";dfpSlots.vid_adunit="vid.newsweek";if(/vs_adtest=/.test(location.href)){dfpSlots.adunit='test.newsweek/test-web/'+utm_result.vs_adtest;dfpSlots.vid_adunit='test.newsweek/test-videoweb/'+utm_result.vs_adtest};dfpSlots.headercmd=[],dfpSlots.sizes={},dfpSlots.slots=[],dfpSlots.lazyslots=[],dfpSlots.lazyslotpos=[],dfpSlots.dsp_adunit='/'+dfpSlots.network_id+'/'+dfpSlots.adunit+'/';var nonPersonalizedAds=1; ```