0% found this document useful (0 votes)
3K views2 pages

F

The document is a JavaScript code snippet that implements a verification client for the OMID (Open Measurement Interface Definition) protocol. It includes functions for sending messages, handling events, and managing session observers related to ad verification. The code is structured to work in various global contexts and includes error handling and utility functions.

Uploaded by

Sam Mac
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3K views2 pages

F

The document is a JavaScript code snippet that implements a verification client for the OMID (Open Measurement Interface Definition) protocol. It includes functions for sending messages, handling events, and managing session observers related to ad verification. The code is structured to work in various global contexts and includes error handling and utility functions.

Uploaded by

Sam Mac
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

(function(){/*

Copyright The Closure Library Authors.


SPDX-License-Identifier: Apache-2.0
*/
'use strict';var g=this||self;/*

SPDX-License-Identifier: Apache-2.0
*/
function h(a){h[" "](a);return a}h[" "]=function(){};function l(a){let
b=g,c=0;for(;b&&40>c++;){var f=!1;try{var d;if(d=!!b&&null!=b.location.href)b:
{try{h(b.foo);d=!0;break b}catch(e){}d=!1}f=d}catch(e){f=!1}if(f&&a(b))break;a:
{try{const e=b.parent;if(e&&e!=b){b=e;break a}}catch(e){}b=null}}};function m()
{return new n(a=>a(void 0))}function p(a,b){if(!a.h)if(b instanceof
n)b.then(c=>{p(a,c)});else{a.h=!0;a.i=b;for(b=0;b<a.g.length;+
+b)q(a,a.g[b]);a.g=[]}}function q(a,b){a.h?b(a.i):a.g.push(b)}class
n{constructor(a){this.h=!1;this.g=[];a(b=>{p(this,b)})}then(a){return new
n(b=>{q(this,c=>{b(a(c))})})}};function r(a){if(!a)throw Error("functionToExecute
must not be truthy.");};function t(){return/\d+\.\d+\.\d+(-.*)?/.test("1.3.3-
google_20200427")}function u(){const a=["1","3","3"],b=["1","0","3"];for(let
c=0;3>c;c++){const f=parseInt(a[c],10),d=parseInt(b[c],10);if(f>d)break;else
if(f<d)return!1}return!0};function v(a){return!!a&&void 0!
==a.omid_message_guid&&void 0!==a.omid_message_method&&void 0!
==a.omid_message_version&&"string"===typeof a.omid_message_guid&&"string"===typeof
a.omid_message_method&&"string"===typeof a.omid_message_version&&(void
0===a.omid_message_args||void 0!==a.omid_message_args)}function w(a){return new
x(a.omid_message_guid,a.omid_message_method,a.omid_message_version,a.omid_message_a
rgs)}
function y(a){const
b={omid_message_guid:a.h,omid_message_method:a.method,omid_message_version:a.versio
n};void 0!==a.g&&(b.omid_message_args=a.g);return b}class x{constructor(a,b,c,f)
{this.h=a;this.method=b;this.version=c;this.g=f}};class z{constructor(a)
{this.h=a}};function A(a,b){return a&&(a[b]||(a[b]={}))};function B()
{return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,a=>{let
b=16*Math.random()|0;return"y"===a?(b&3|8).toString(16):b.toString(16)})};function
C(...a){D(()=>{throw Error("Could not complete the test successfully - ",...a);},
()=>console.error(...a))}function D(a,b){"undefined"!==typeof jasmine&&jasmine?
a():"undefined"!==typeof console&&console&&console.error&&b()};const
E=eval("this");var F=function(){if("undefined"!==typeof
omidGlobal&&omidGlobal)return omidGlobal;if("undefined"!==typeof
global&&global)return global;if("undefined"!==typeof window&&window)return
window;if("undefined"!==typeof E&&E)return E;throw Error("Could not determine
global object context.");}();function G(a){try{return a.frames?!!
a.frames.omid_v1_present:!1}catch(b){return!1}};class H extends z{constructor(a)
{super(a);this.handleExportedMessage=H.prototype.i.bind(this)}sendMessage(a,b=this.
h){if(!b)throw Error("Message destination must be defined at construction time or
when sending the message.");b.handleExportedMessage(y(a),this)}i(a,b)
{v(a)&&this.g&&this.g(w(a),b)}};function I(a){return null!=a&&"undefined"!==typeof
a.top&&null!=a.top}function J(a){if(a===F)return!1;try{if("undefined"===typeof
a.location.hostname)return!0}catch(b){return!0}return!1};class K extends
z{constructor(a,b=F){super(b);a.addEventListener("message",c=>{if("object"===typeof
c.data){var
f=c.data;v(f)&&c.source&&this.g&&this.g(w(f),c.source)}})}sendMessage(a,b=this.h)
{if(!b)throw Error("Message destination must be defined at construction time or
when sending the message.");b.postMessage(y(a),"*")}};const
L=["omid","v1_VerificationServiceCommunication"],M=["omidVerificationProperties","s
erviceWindow"];function N(a,b){return b.reduce((c,f)=>c&&c[f],a)};function
O(a,b,c,...f){if(a.g){var d=B();c&&(a.h[d]=c);c=t()&&u()?
f:JSON.stringify(f);a.g.sendMessage(new x(d,`VerificationService.${b}`,"1.3.3-
google_20200427",c))}}
class P{constructor(a){if(!a){var b;"undefined"===typeof b&&"undefined"!==typeof
window&&window&&(b=window);b=I(b)?b:F;a=[];var c=N(b,M);c&&a.push(c);a.push(I(b)?
b.top:F);a:{for(const e of a){b:{a=b;c=e;var f=G;if(!J(c))try{const k=N(c,L);if(k)
{var d=new H(k);break b}}catch(k){}d=f(c)?new K(a,c):null}if(a=d)break
a}a=null}}if(this.g=a)this.g.g=this.j.bind(this);else
if(d=(d=F.omid3p)&&"function"===typeof
d.registerSessionObserver&&"function"===typeof d.addEventListener?
d:null)this.omid3p=d;this.h=
{};this.i=(d=F.omidVerificationProperties)?d.injectionId:void
0}registerSessionObserver(a,b){r(a);this.omid3p?
this.omid3p.registerSessionObserver(a,b,this.i):O(this,"addSessionListener",a,b,thi
s.i)}addEventListener(a,b){if(!a)throw Error("Value for eventType is undefined,
null or blank.");if("string"!==typeof a&&!(a instanceof String))throw Error("Value
for eventType is not a string.");if(""===a.trim())throw Error("Value for eventType
is empty string.");r(b);this.omid3p?this.omid3p.addEventListener(a,
b):O(this,"addEventListener",b,a)}j(a){const
b=a.method,c=a.h;a=a.g;if("response"===b&&this.h[c]){var f=t()&&u()?a?a:
[]:a&&"string"===typeof a?JSON.parse(a):
[];this.h[c].apply(this,f)}"error"===b&&window.console&&C(a)}}
(function(a,b,c="undefined"===typeof omidExports?null:omidExports)
{c&&(a=a.split("."),a.slice(0,a.length-1).reduce(A,c)[a[a.length-1]]=b)})
("OmidVerificationClient",P);function Q(){let
a=null;l(b=>(b=b.mraid)&&b.IS_GMA_SDK?(a=b,!0):!1);return a}function R(){return new
n(a=>{g.document.readyState&&"complete"===g.document.readyState?
a():g.addEventListener("load",a)})}function S(){return new n(a=>{const
b=Q();b&&("loading"===b.getState()?b.addEventListener("ready",()=>{a(b)}):a(b))})}
function T(){return new n(a=>{R().then(()=>{S().then(b=>{const
c=(f,d)=>{0<d.width&&0<d.height&&(a(),b.removeEventListener("exposureChange",c))};b
.addEventListener("exposureChange",c)})})})}
function U(a){a.j?(a.h=new n(b=>{const c=new
n(d=>{a.i.registerSessionObserver(e=>{"sessionStart"==e.type&&(e=e.data,d("app"==e.
context.environment),e.context.omidNativeInfo&&(a.g.sdk=e.context.omidNativeInfo.pa
rtnerName))})}),f=new
n(d=>{a.i.addEventListener("geometryChange",e=>{e=e.data;const
k=e.adView.reasons;k&&-1!=k.indexOf("hidden")||(e=e.adView,
(e=e.onScreenContainerGeometry||
e.onScreenGeometry)&&e.width&&e.height&&d())})});c.then(d=>{d?
(f.then(()=>{a.g.src=1;b(a.g)}),T().then(()=>{a.g.src=
2;b(a.g)})):b()})}),a.h.then(()=>{a.j=!1})):a.h=m()}class V{constructor(){var
a=this.i=new P;this.l=!(!a.g&&!
a.omid3p);this.h=null;this.j=this.l;this.g={}}};window.omrhp=function(a){var b=new
V;b.h||U(b);b.h.then(a)};}).call(this);

You might also like