@ -1,28 +1,28 @@
'use strict'
; ( function ( win ) {
var exports = { }
const exports = { }
; ( function ( exports ) {
var utils = {
const utils = {
/ * *
* Normalize URL
* @ param { String } url
* /
normalizeUrl : function ( url ) {
normalizeUrl ( url ) {
return this . hashUrl ( url ) || null
} ,
/ * *
* Get referrer .
* /
getReferrer : function ( ) {
getReferrer ( ) {
return this . normalizeUrl ( document . referrer )
} ,
/ * *
* Get current page URL .
* /
getPageUrl : function ( ) {
getPageUrl ( ) {
return this . normalizeUrl ( window . location . href )
} ,
@ -30,8 +30,8 @@
* Generated hashed URL .
* @ param { String } url
* /
hashUrl : function ( url ) {
var a , result
hashUrl ( url ) {
let a , result
if ( ! url || url . indexOf ( 'http' ) !== 0 ) {
return null
@ -61,10 +61,10 @@
* Generate random hash .
* @ param { String } str
* /
hashCode : function ( str ) {
var hash = 0 ,
kar ,
i
hashCode ( str ) {
let hash = 0
let kar
let i
if ( str . length === 0 ) {
return hash
@ -83,7 +83,7 @@
* Apply array function to non - array .
* @ param { Object } a
* /
realArray : function ( a ) {
realArray ( a ) {
return Array . prototype . slice . apply ( a )
} ,
@ -92,7 +92,7 @@
* @ param { Object } doc
* @ param { Function } callback
* /
onDocLoaded : function ( doc , callback ) {
onDocLoaded ( doc , callback ) {
if ( doc . readyState === 'loading' ) {
doc . addEventListener ( 'DOMContentLoaded' , callback )
} else {
@ -106,8 +106,8 @@
* Check for href Window object .
* @ param { Object } win
* /
isFriendlyWindow : function ( win ) {
var href
isFriendlyWindow ( win ) {
let href
try {
href = win . location . href
} catch ( e ) {
@ -120,7 +120,7 @@
* Get default view from element .
* @ param { Object } el
* /
elementWindow : function ( el ) {
elementWindow ( el ) {
return el . ownerDocument . defaultView
} ,
@ -128,7 +128,7 @@
* Get viewport size .
* @ param { Object } win
* /
viewport : function ( win ) {
viewport ( win ) {
return { width : win . innerWidth , height : win . innerHeight }
} ,
@ -136,12 +136,12 @@
* Parse query string parameters .
* @ param { String } qs
* /
parseQS : function ( qs ) {
parseQS ( qs ) {
if ( qs . indexOf ( 'http' ) === 0 ) {
qs = qs . split ( '?' ) [ 1 ]
}
var i , kvs , key , val
var dict = { }
let i , kvs , key , val
const dict = { }
qs = qs . split ( '&' )
for ( i = 0 ; i < qs . length ; i ++ ) {
kvs = qs [ i ] . split ( '=' )
@ -162,7 +162,7 @@
* @ param { String } event
* @ param { String } responseMessage
* /
sendToBackground : function ( message , event , responseMessage ) {
sendToBackground ( message , event , responseMessage ) {
chrome . runtime . sendMessage ( message , ( message ) => {
if ( message && typeof message . tracking _enabled !== 'undefined' ) {
if ( message . tracking _enabled ) {
@ -180,7 +180,7 @@
* @ param { Function } elseCallback
* @ todo validate if utilCallback or utilElseCallback are being used .
* /
askIfTrackingEnabled : function ( callback , elseCallback ) {
askIfTrackingEnabled ( callback , elseCallback ) {
utilCallback = callback
utilElseCallback = elseCallback
@ -189,7 +189,7 @@
'' ,
'tracking_enabled_response'
)
}
} ,
}
utils . SCRIPT _IN _FRIENDLY _IFRAME =
@ -207,7 +207,7 @@
isHP : window . location . pathname === '/' ,
referrer : utils . getReferrer ( ) ,
rand : Math . floor ( Math . random ( ) * 10e12 ) ,
startTime : new Date ( ) . getTime ( )
startTime : new Date ( ) . getTime ( ) ,
}
}
@ -218,8 +218,8 @@
* @ param { Array } opt _assets
* @ param { Array } opt _pageTags
* /
log : function ( event , opt _assets , opt _pageTags ) {
var opt _video _assets
log ( event , opt _assets , opt _pageTags ) {
let opt _video _assets
if ( event === 'video' || event === 'invalid-video' ) {
opt _video _assets = opt _assets || [ ]
opt _assets = [ ]
@ -227,9 +227,9 @@
opt _video _assets = [ ]
opt _assets = opt _assets || [ ]
}
var result = {
const result = {
doc : this . pageMeta ,
event : event ,
event ,
video _assets : opt _video _assets ,
assets : opt _assets ,
version : '3' ,
@ -238,11 +238,11 @@
timestamp : new Date ( ) . getTime ( ) ,
pageVis : document . visibilityState ,
pageFoc : document . hasFocus ( ) ,
pageTags : opt _pageTags || [ ]
pageTags : opt _pageTags || [ ] ,
}
this . msgNum ++
return result
}
} ,
}
utils . LogGenerator = LogGenerator
@ -252,7 +252,7 @@
exports . utils = utils
} ) ( exports )
; ( function ( exports ) {
var SizeMatcher = {
const SizeMatcher = {
VALID _AD _SIZES : [
[ 300 , 50 ] ,
[ 320 , 50 ] ,
@ -272,7 +272,7 @@
[ 970 , 250 ] ,
[ 970 , 400 ] ,
[ 970 , 415 ] ,
[ 1280 , 100 ]
[ 1280 , 100 ] ,
] ,
PX _SIZE _TOL : 10 ,
@ -282,7 +282,7 @@
* @ param { Int } width
* @ param { Int } height
* /
getMatchedAdSize : function ( width , height ) {
getMatchedAdSize ( width , height ) {
if ( ! this . set ) {
this . set = this . _makeSizeSet ( )
}
@ -294,7 +294,7 @@
* Check element size .
* @ param { HTMLElement } el
* /
elementIsAdShaped : function ( el ) {
elementIsAdShaped ( el ) {
return ! ! this . getMatchedAdSizeForElement ( el )
} ,
@ -303,22 +303,22 @@
* @ param { HTMLElement } el
* @ todo better description
* /
getMatchedAdSizeForElement : function ( el ) {
var rect = el . getBoundingClientRect ( )
getMatchedAdSizeForElement ( el ) {
const rect = el . getBoundingClientRect ( )
return this . getMatchedAdSize ( rect . width , rect . height )
} ,
/ * *
* Generate ad sizes .
* /
_makeSizeSet : function ( ) {
var set = { }
var i
var xfuz
var yfuz
var size
var width
var height
_makeSizeSet ( ) {
const set = { }
let i
let xfuz
let yfuz
let size
let width
let height
for ( i = 0 ; i < this . VALID _AD _SIZES . length ; i ++ ) {
for ( xfuz = - this . PX _SIZE _TOL ; xfuz <= this . PX _SIZE _TOL ; xfuz ++ ) {
@ -331,10 +331,10 @@
}
}
return set
}
} ,
}
var Throttler = {
const Throttler = {
MAX _SEARCHES _PER _WINDOW : 10 ,
MAX _SEARCHES _PER _ELEMENT : 2 ,
@ -357,7 +357,7 @@
*
* @ todo add description
* /
throttle : function ( el , max ) {
throttle ( el , max ) {
if ( typeof el . searches === 'number' && el . searches >= max ) {
return true
}
@ -370,7 +370,7 @@
*
* @ todo add description
* /
throttleElement : function ( el ) {
throttleElement ( el ) {
return this . throttle ( el , this . MAX _SEARCHES _PER _ELEMENT )
} ,
@ -380,7 +380,7 @@
*
* @ todo add description
* /
throttleWin : functio n( win ) {
throttleWi n( win ) {
return this . throttle ( win , this . MAX _SEARCHES _PER _WINDOW )
} ,
@ -390,9 +390,9 @@
*
* @ todo add description
* /
getCount : function ( el ) {
getCount ( el ) {
return el . searches || 0
}
} ,
}
/ * *
@ -408,11 +408,11 @@
* Add search function .
* /
TopSearcher . prototype . search = function ( ) {
var candidates = exports . utils . realArray (
const candidates = exports . utils . realArray (
this . doc . querySelectorAll ( 'img, object, embed' )
) ,
html5Ad ,
ads = [ ]
)
let html5Ad
let ads = [ ]
ads = ads . concat (
candidates . filter ( function ( el ) {
@ -444,11 +444,11 @@
* @ todo add description
* /
TopSearcher . prototype . _mainGetHTMLAd = function ( ) {
var styles = this . doc . querySelectorAll (
const styles = this . doc . querySelectorAll (
'div > style, div > link[rel="stylesheet"]'
) ,
i ,
div
)
let i
let div
for ( i = 0 ; i < styles . length ; i ++ ) {
div = styles [ i ] . parentNode
if (
@ -465,7 +465,7 @@
* @ todo add description
* /
TopSearcher . prototype . _jumpedOut = function ( el ) {
var siblings , ifrs
let siblings , ifrs
siblings = exports . utils . realArray ( el . parentNode . children )
ifrs = siblings . filter ( function ( el ) {
return (
@ -516,7 +516,7 @@
* @ todo add description
* /
IframeSearcher . prototype . search = function ( ) {
var ad
let ad
if ( this . shouldSearchWindow ) {
ad = this . _search ( )
@ -535,11 +535,11 @@
* @ todo add description
* /
IframeSearcher . prototype . _search = function ( ) {
var _this = this ,
stdCandidates ,
html5Candidates ,
stdEl ,
html5El
const _this = this
let stdCandidates
let html5Candidates
let stdEl
let html5El
stdCandidates = this . body . querySelectorAll ( 'img, object, embed' )
@ -612,8 +612,8 @@
* @ todo add description
* /
IframeSearcher . prototype . _elementIsAtLeastAsBigAsWindow = function ( el ) {
var rect = el . getBoundingClientRect ( ) ,
tol = 0.95
const rect = el . getBoundingClientRect ( )
const tol = 0.95
return (
rect . width >= tol * this . winWidth && rect . height >= tol * this . winHeight
@ -631,9 +631,9 @@
* @ todo add description
* /
IframeSearcher . prototype . _containsLargeIframes = function ( ) {
var iframes = this . doc . querySelectorAll ( 'iframe' )
var rect
var i
const iframes = this . doc . querySelectorAll ( 'iframe' )
let rect
let i
for ( i = 0 ; i < iframes . length ; i ++ ) {
rect = iframes [ i ] . getBoundingClientRect ( )
if (
@ -650,7 +650,7 @@
* @ todo add description
* /
IframeSearcher . prototype . _getAdSizeMeta = function ( ) {
var adSizeMeta = this . doc . querySelectorAll ( 'meta[name="ad.size"]' )
const adSizeMeta = this . doc . querySelectorAll ( 'meta[name="ad.size"]' )
if ( adSizeMeta . length > 0 ) {
return adSizeMeta [ 0 ] . content
} else {
@ -666,7 +666,7 @@
* @ todo add description
* /
function getFirst ( arr , testFn ) {
var i , el
let i , el
for ( i = 0 ; i < arr . length ; i ++ ) {
el = arr [ i ]
if ( testFn ( el ) ) {
@ -692,9 +692,9 @@
* @ param { Object } win
* /
function getFriendlyIframes ( win ) {
var iframes = win . document . querySelectorAll ( 'iframe' )
let iframes = win . document . querySelectorAll ( 'iframe' )
iframes = exports . utils . realArray ( iframes )
var friendlyIframes = iframes . filter ( function ( ifr ) {
const friendlyIframes = iframes . filter ( function ( ifr ) {
return exports . utils . isFriendlyWindow ( ifr . contentWindow )
} )
return friendlyIframes
@ -705,11 +705,11 @@
* @ param { * } win
* /
function findAds ( win ) {
var i ,
iframes ,
searcher ,
ad ,
ads = [ ]
let i
let iframes
let searcher
let ad
let ads = [ ]
if ( win === win . top ) {
searcher = new TopSearcher ( win )
@ -732,16 +732,16 @@
exports . adfinder = {
getMatchedAdSize : SizeMatcher . getMatchedAdSize . bind ( SizeMatcher ) ,
findAds : findAds
findAds ,
}
} ) ( exports )
; ( function ( exports ) {
var parser = {
const parser = {
TAGS _WITH _SRC _ATTR : {
IMG : true ,
SCRIPT : true ,
IFRAME : true ,
EMBED : true
EMBED : true ,
} ,
MAX _ATTR _LEN : 100 ,
@ -753,8 +753,8 @@
*
* @ todo add description
* /
getUrl : function ( el , params ) {
var url
getUrl ( el , params ) {
let url
if ( this . TAGS _WITH _SRC _ATTR . hasOwnProperty ( el . tagName ) ) {
url = el . src
@ -777,14 +777,14 @@
*
* @ todo add description
* /
getParams : function ( el ) {
getParams ( el ) {
if ( el . tagName !== 'OBJECT' ) {
return null
}
var i , child
var params = { }
var children = el . children
let i , child
const params = { }
const children = el . children
for ( i = 0 ; i < children . length ; i ++ ) {
child = children [ i ]
if ( child . tagName === 'PARAM' && child . name ) {
@ -798,15 +798,15 @@
* Get element position .
* @ param { HTMLElement } el
* /
getPosition : func tion( el ) {
var rect = el . getBoundingClientRect ( )
var win = exports . utils . elementWindow ( el )
getPosi tion( el ) {
const rect = el . getBoundingClientRect ( )
const win = exports . utils . elementWindow ( el )
return {
width : Math . round ( rect . width ) ,
height : Math . round ( rect . height ) ,
left : Math . round ( rect . left + win . pageXOffset ) ,
top : Math . round ( rect . top + win . pageYOffset )
top : Math . round ( rect . top + win . pageYOffset ) ,
}
} ,
@ -818,9 +818,9 @@
*
* @ todo add description
* /
getFlashvars : function ( el , params , url ) {
var flashvars
var urlQS = url && url . split ( '?' ) [ 1 ]
getFlashvars ( el , params , url ) {
let flashvars
const urlQS = url && url . split ( '?' ) [ 1 ]
if ( el . tagName === 'EMBED' ) {
flashvars = el . getAttribute ( 'flashvars' ) || urlQS
@ -838,8 +838,8 @@
*
* @ todo add description
* /
findClickThru : function ( el , flashvars ) {
var key
findClickThru ( el , flashvars ) {
let key
if ( el . tagName === 'IMG' && el . parentElement . tagName === 'A' ) {
return el . parentElement . href
} else if ( flashvars ) {
@ -859,8 +859,8 @@
* @ param { HTMLElement } el
* @ param { String } name
* /
getAttr : function ( el , name ) {
var val = el . getAttribute ( name )
getAttr ( el , name ) {
const val = el . getAttribute ( name )
if ( val && val . slice && val . toString ) {
return val . slice ( 0 , this . MAX _ATTR _LEN ) . toString ( )
@ -877,7 +877,7 @@
*
* @ todo add description
* /
putPropIfExists : function ( obj , name , val ) {
putPropIfExists ( obj , name , val ) {
if ( val ) {
obj [ name ] = val
}
@ -891,8 +891,8 @@
*
* @ todo add description
* /
putAttrIfExists : function ( obj , el , name ) {
var val = this . getAttr ( el , name )
putAttrIfExists ( obj , el , name ) {
const val = this . getAttr ( el , name )
this . putPropIfExists ( obj , name , val )
} ,
@ -901,19 +901,19 @@
* @ param { HTMLElement } el
* @ param { Boolean } opt _findClickThru
* /
elementToJSON : function ( el , opt _findClickThru ) {
var pos = this . getPosition ( el )
var params = this . getParams ( el )
var url = this . getUrl ( el , params )
var flashvars = this . getFlashvars ( el , params , url )
var clickThru = opt _findClickThru && this . findClickThru ( el , flashvars )
var json = {
elementToJSON ( el , opt _findClickThru ) {
const pos = this . getPosition ( el )
const params = this . getParams ( el )
const url = this . getUrl ( el , params )
const flashvars = this . getFlashvars ( el , params , url )
const clickThru = opt _findClickThru && this . findClickThru ( el , flashvars )
const json = {
tagName : el . tagName ,
width : pos . width ,
height : pos . height ,
left : pos . left ,
top : pos . top ,
children : [ ]
children : [ ] ,
}
if ( params ) {
@ -930,7 +930,7 @@
this . putPropIfExists ( json , 'clickThru' , clickThru )
return json
}
} ,
}
exports . parser = { elementToJSON : parser . elementToJSON . bind ( parser ) }
@ -942,7 +942,7 @@
* Setter for ad data .
* @ param { * } adData
* /
var ContextManager = function ( adData ) {
const ContextManager = function ( adData ) {
this . adData = adData
}
@ -955,23 +955,23 @@
* @ param { HTMLElement } el
* @ param { HTMLElement } opt _curWin
* /
isValidContainer : function ( el , opt _curWin ) {
var cWidth = el . clientWidth
var cHeight = el . clientHeight
isValidContainer ( el , opt _curWin ) {
const cWidth = el . clientWidth
const cHeight = el . clientHeight
var adWidth = this . adData . width
var adHeight = this . adData . height
const adWidth = this . adData . width
const adHeight = this . adData . height
var winWidth = opt _curWin && opt _curWin . innerWidth
var winHeight = opt _curWin && opt _curWin . innerHeight
var similarWin =
const winWidth = opt _curWin && opt _curWin . innerWidth
const winHeight = opt _curWin && opt _curWin . innerHeight
const similarWin =
opt _curWin &&
this . withinTol ( adWidth , winWidth ) &&
this . withinTol ( adHeight , winHeight )
var similarSizeX = this . withinTol ( adWidth , cWidth )
var similarSizeY = this . withinTol ( adHeight , cHeight )
var adAspect = adWidth / adHeight
const similarSizeX = this . withinTol ( adWidth , cWidth )
const similarSizeY = this . withinTol ( adHeight , cHeight )
const adAspect = adWidth / adHeight
return (
similarWin ||
@ -986,8 +986,8 @@
* @ param { Int } adlen
* @ param { Int } conlen
* /
withinTol : function ( adlen , conlen ) {
var pct = ( conlen - adlen ) / adlen
withinTol ( adlen , conlen ) {
const pct = ( conlen - adlen ) / adlen
return pct <= this . CONTAINER _SIZE _TOL
} ,
@ -997,43 +997,42 @@
* @ param { * } el
* @ todo define parameter type .
* /
serializeElements : function ( el ) {
serializeElements ( el ) {
if ( ! el ) {
return
}
var i
var ifrWin
var adId = this . adData . adId
var elIsAd = false
let i
let ifrWin
const adId = this . adData . adId
let elIsAd = false
if ( adId && el [ adId ] && el [ adId ] . isAd === true ) {
elIsAd = true
}
var json = exports . parser . elementToJSON ( el , elIsAd )
var childJSON
const json = exports . parser . elementToJSON ( el , elIsAd )
let childJSON
if ( elIsAd ) {
json . adId = adId
this . adData . element = { }
var keys = Object . keys ( json )
const keys = Object . keys ( json )
for ( i = 0 ; i < keys . length ; i ++ ) {
var key = keys [ i ]
const key = keys [ i ]
if ( key !== 'children' && key !== 'contents' ) {
this . adData . element [ key ] = json [ key ]
}
}
}
var children = exports . utils
const children = exports . utils
. realArray ( el . children )
. filter ( function ( el ) {
var param = el . tagName === 'PARAM'
var inlineScript =
el . tagName === 'SCRIPT' &&
! ( el . src && el . src . indexOf ( 'http' ) >= 0 )
var noScript = el . tagName === 'NOSCRIPT'
const param = el . tagName === 'PARAM'
const inlineScript =
el . tagName === 'SCRIPT' && ! ( el . src && el . src . includes ( 'http' ) )
const noScript = el . tagName === 'NOSCRIPT'
return ! ( param || inlineScript || noScript )
} )
@ -1075,7 +1074,7 @@
* Get element containers .
* @ param { * } containerEl
* /
captureHTML : function ( containerEl ) {
captureHTML ( containerEl ) {
this . adData . context = this . serializeElements ( containerEl )
} ,
@ -1083,7 +1082,7 @@
* Get number of Nodes .
* @ param { HTMLElement } el
* /
nodeCount : function ( el ) {
nodeCount ( el ) {
return el . getElementsByTagName ( '*' ) . length + 1
} ,
@ -1094,10 +1093,10 @@
*
* @ todo add description
* /
highestContainer : function ( curWin , referenceElement ) {
var curContainer = referenceElement
var docEl = curWin . document . documentElement
var parentContainer
highestContainer ( curWin , referenceElement ) {
let curContainer = referenceElement
const docEl = curWin . document . documentElement
let parentContainer
if ( curWin !== curWin . top && this . isValidContainer ( docEl , curWin ) ) {
return docEl
@ -1111,10 +1110,10 @@
return curContainer
}
}
}
} ,
}
var tagfinder = {
const tagfinder = {
/ * *
*
* @ param { * } adData
@ -1123,10 +1122,10 @@
*
* @ todo add description
* /
setPositions : function ( adData , opt _el , opt _winPos ) {
var el = opt _el || adData . context
var winPos = opt _winPos || { left : 0 , top : 0 }
var ifrPos
setPositions ( adData , opt _el , opt _winPos ) {
const el = opt _el || adData . context
const winPos = opt _winPos || { left : 0 , top : 0 }
let ifrPos
el . left += winPos . left
el . top += winPos . top
@ -1156,9 +1155,9 @@
* @ todo add description
* /
appendTags : ( adData , referenceElement ) => {
var mgr = new ContextManager ( adData )
var curWin = exports . utils . elementWindow ( referenceElement )
var highestContainer
const mgr = new ContextManager ( adData )
let curWin = exports . utils . elementWindow ( referenceElement )
let highestContainer
while ( true ) {
highestContainer = mgr . highestContainer ( curWin , referenceElement )
@ -1180,30 +1179,30 @@
}
}
return {
referenceElement : referenceElement ,
highestContainer : highestContainer
}
referenceElement ,
highestContainer ,
}
} ,
}
exports . tagfinder = tagfinder
} ) ( exports )
; ( function ( exports ) {
var _onAdFound
var _logGen = new exports . utils . LogGenerator ( )
var _pageTags
var INIT _MS _BW _SEARCHES = 2000
var PAGE _TAG _RE = new RegExp ( 'gpt|oascentral' )
var POST _MSG _ID = '1554456894-8541-12665-19466-15909'
var AD _SERVER _RE = new RegExp ( '^(google_ads_iframe|oas_frame|atwAdFrame)' )
let _onAdFound
const _logGen = new exports . utils . LogGenerator ( )
let _pageTags
const INIT _MS _BW _SEARCHES = 2000
const PAGE _TAG _RE = new RegExp ( 'gpt|oascentral' )
const POST _MSG _ID = '1554456894-8541-12665-19466-15909'
const AD _SERVER _RE = new RegExp ( '^(google_ads_iframe|oas_frame|atwAdFrame)' )
/ * *
* Get script tags from document .
* @ param { Object } doc
* /
function getPageTags ( doc ) {
var scripts = doc . getElementsByTagName ( 'script' )
var pageTags = [ ]
let scripts = doc . getElementsByTagName ( 'script' )
const pageTags = [ ]
scripts = exports . utils . realArray ( scripts )
scripts . forEach ( function ( script ) {
if ( PAGE _TAG _RE . exec ( script . src ) ) {
@ -1222,7 +1221,7 @@
adData = JSON . stringify ( adData )
var win = window
let win = window
while ( win !== win . top ) {
win = win . parent
win . postMessage ( adData , '*' )
@ -1237,7 +1236,7 @@
* @ todo update description
* /
function appendTagsAndSendToParent ( adData , referenceElement ) {
var results = exports . tagfinder . appendTags ( adData , referenceElement )
const results = exports . tagfinder . appendTags ( adData , referenceElement )
if ( exports . utils . SCRIPT _IN _HOSTILE _IFRAME ) {
messageAllParentFrames ( adData )
} else if ( exports . utils . SCRIPT _IN _WINDOW _TOP ) {
@ -1259,7 +1258,7 @@
delete adData . height
adData . curPageUrl = exports . utils . getPageUrl ( )
_pageTags = _pageTags || getPageTags ( document )
var log = _logGen . log ( 'ad' , [ adData ] , _pageTags )
const log = _logGen . log ( 'ad' , [ adData ] , _pageTags )
if ( _onAdFound ) {
_onAdFound ( log , results . referenceElement )
@ -1286,17 +1285,17 @@
* Main function for extracting ads after loaded .
* /
function extractAds ( ) {
var ads = exports . adfinder . findAds ( window )
const ads = exports . adfinder . findAds ( window )
ads . forEach ( function ( ad ) {
var startTime = new Date ( ) . getTime ( )
var adId = startTime + '-' + Math . floor ( Math . random ( ) * 10e12 )
const startTime = new Date ( ) . getTime ( )
const adId = startTime + '-' + Math . floor ( Math . random ( ) * 10e12 )
var adData = {
const adData = {
width : Math . round ( ad . offsetWidth ) ,
height : Math . round ( ad . offsetHeight ) ,
startTime : startTime ,
adId : adId ,
html5 : ad . html5 || false
startTime ,
adId ,
html5 : ad . html5 || false ,
}
if ( ad . html5 ) {
@ -1316,7 +1315,7 @@
* @ param { Object } otherWin
* /
function isChildWin ( myWin , otherWin ) {
var parentWin = otherWin . parent
let parentWin = otherWin . parent
while ( parentWin !== otherWin ) {
if ( parentWin === myWin ) {
return true
@ -1335,10 +1334,10 @@
* @ todo update description
* /
function iframeFromWindow ( win , winToMatch ) {
var i ,
ifr ,
ifrWin ,
iframes = win . document . querySelectorAll ( 'iframe' )
let i
let ifr
let ifrWin
const iframes = win . document . querySelectorAll ( 'iframe' )
for ( i = 0 ; i < iframes . length ; i ++ ) {
ifr = iframes [ i ]
@ -1365,15 +1364,12 @@
* @ todo update description
* /
function onPostMessage ( event ) {
var adData ,
ifrWin = event . source ,
myWin = window . document . defaultView ,
ifrTag
let adData
const ifrWin = event . source
const myWin = window . document . defaultView
let ifrTag
if (
typeof event . data === 'string' &&
event . data . indexOf ( POST _MSG _ID ) != - 1
) {
if ( typeof event . data === 'string' && event . data . includes ( POST _MSG _ID ) ) {
try {
adData = JSON . parse ( event . data )
} catch ( e ) {
@ -1410,7 +1406,7 @@
* @ todo update description
* /
function onVideoMessage ( msg , sender , callback ) {
var log
let log
if ( msg . event === 'new-video-ad' ) {
msg . assets . forEach ( function ( asset ) { } )
log = _logGen . log ( 'video' , msg . assets )
@ -1448,7 +1444,7 @@
/ * *
* @ todo update description
* /
addPostMessageListener : function ( ) {
addPostMessageListener ( ) {
if ( ! exports . utils . SCRIPT _IN _FRIENDLY _IFRAME ) {
window . addEventListener ( 'message' , onPostMessage , false )
}
@ -1461,10 +1457,10 @@
*
* @ todo update description
* /
blockedRobotsMsgGen : functio n( sendFcn , origUrl ) {
if ( origUrl . indexOf ( 'google.com/_/chrome/newtab' ) === - 1 ) {
var onBlockedRobotsMessage = function ( ) {
var log
blockedRobotsMsgGe n( sendFcn , origUrl ) {
if ( ! origUrl . includes ( 'google.com/_/chrome/newtab' ) ) {
const onBlockedRobotsMessage = function ( ) {
let log
log = _logGen . log ( 'invalid-robotstxt' , [ ] )
log . doc . finalPageUrl = log . doc . url
log . doc . url = exports . utils . normalizeUrl ( origUrl )
@ -1481,18 +1477,18 @@
*
* @ param { * } onAdFound
* /
init : function ( onAdFound ) {
init ( onAdFound ) {
if ( exports . utils . SCRIPT _IN _FRIENDLY _IFRAME ) {
return false
}
_onAdFound = onAdFound
if ( exports . utils . SCRIPT _IN _WINDOW _TOP ) {
var log = _logGen . log ( 'page' )
const log = _logGen . log ( 'page' )
onAdFound ( log )
window . addEventListener ( 'beforeunload' , function ( event ) {
var log = _logGen . log ( 'unload' )
const log = _logGen . log ( 'unload' )
log . timing = window . performance . timing
onAdFound ( log )
} )
@ -1502,7 +1498,7 @@
}
exports . utils . onDocLoaded ( document , extractAdsWrapper )
}
} ,
}
} ) ( exports )
@ -1513,7 +1509,7 @@
askIfTrackingEnabled : exports . utils . askIfTrackingEnabled ,
blockedRobotsMsgGen : exports . coordinator . blockedRobotsMsgGen ,
inWindowTop : exports . utils . SCRIPT _IN _WINDOW _TOP ,
sendToBackground : exports . utils . sendToBackground
sendToBackground : exports . utils . sendToBackground ,
}
} else {
exports . coordinator . addPostMessageListener ( )