;theta = {}; theta.hituri = 'https://thetamarketplace.com/hit/androinread/host/false'; theta.passbackuri = 'https://thetamarketplace.com/passback/androinread'; theta.inreadid = 982153; theta.sellerid = '3', theta.selector = '.in-read-ad'; theta.method='StickyOne'; theta.slug = 'androinread'; theta.platform = 'adform'; theta.selectorIndex = undefined; theta.stickyElements = 'undefined'; theta.mobilePosition = 'top'; theta.css='.in-read-ad{display: block !important;} #adform-outstream-smartinsert{max-width: 730px !important;}'; theta.keepclose = true; theta.stayoncomplete = undefined; theta.mobileWidth = undefined; theta.containerWidth = undefined; theta.containerHeight = undefined; theta.zindex = undefined; theta.querystring = 'null'; theta.hbpassback = 'null'; theta.passback = 'null' console.log('<===THETAMARKETPLACE INREAD===>') fetch(theta.hituri.replace('/host', '/' + window.location.host), { method: 'GET', }) /* var ADS_URL = 'https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js'; function checkAdsBlocked(callback) { var xhr = new XMLHttpRequest(); xhr.onreadystatechange = function () { if (xhr.readyState == XMLHttpRequest.DONE) { callback(xhr.status === 0 || xhr.responseURL !== ADS_URL); } }; xhr.open('HEAD', ADS_URL, true); xhr.send(null); } checkAdsBlocked(function(adsBlocked) { fetch(theta.hituri.replace('/host', '/' + window.location.host).replace('/false', '/' + adsBlocked), { method: 'GET', }) return adsBlocked }); */ theta.adform = theta.adform || {} theta.inread = theta.inread || { pmpid: theta.inreadid, containerWidth: theta.containerWidth !== undefined ? theta.containerWidth : 730, containerHeight: theta.containerHeight !== undefined ? theta.containerHeight : 547, zindex: theta.zindex !== undefined ? theta.zindex : 99 } theta.d = window.parent.document theta.bottomSticky = [ '.sticky-mobile', '.onesignal-bell-launcher-button', '.back-top', '#ocm-ois', '#gotoTop', '.sas-container' ] theta.scrolling = false theta.factor = 0.5 theta.mobilefactor = 0.75 theta.bottomOffset = 40 //Utils theta.mobileCheck = function () { let check = false; ((a) => { if ( /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test( a ) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test( a.substr(0, 4) ) ) check = true })(navigator.userAgent || navigator.vendor || window.opera) return check } theta.isElementInViewport = function (rect) { if (rect.top + rect.height / 2 < 0) { console.log('out') return -1 } if (rect.top + rect.height / 2 > (window.parent.innerHeight || document.documentElement.clientHeight)) { console.log('out') return 1 } console.log('in') return 0 } theta.getPos = function (el) { for ( let lx = 0, ly = 0; el != null; lx += el.offsetLeft, ly += el.offsetTop, el = el.offsetParent ); return { x: lx, y: ly } } theta.isOverlapping = (rect1, rect2) => { let overlap = false if (rect1 && rect2) { overlap = !( rect1.right < rect2.left || rect1.left > rect2.right || rect1.bottom < rect2.top || rect1.top > rect2.bottom ) return overlap } console.warn('Please provide valid HTMLElement object') return overlap } theta.getBottomOffset = function () { theta.bottomOffset = 40 if (theta.mobileCheck()) { theta.bottomOffset = 0 } let maxch = 0 let els = document.body.querySelectorAll(theta.bottomSticky) const rect1 = theta.containerrect === undefined ? theta.inread.container.getBoundingClientRect() : theta.containerrect for (let i = 0; i < els.length; i++) { const rect2 = els[i] instanceof Element ? els[i].getBoundingClientRect() : false if (theta.isOverlapping(rect1, rect2)) { theta.containerrect = theta.containerrect === undefined ? theta.inread.container.getBoundingClientRect() : theta.containerrect if (els[i].clientHeight > maxch) maxch = els[i].clientHeight } } theta.bottomOffset += maxch + 20 } theta.prepareStyle = function () { if (theta.style !== undefined) { theta.style.remove() } theta.style = document.createElement('style') theta.style.type = 'text/css' theta.keyFrames = `\ @-webkit-keyframes to-bottom-right {\ 100% {\ right: -80px; \ bottom: calc(${theta.bottomOffset}px - 80px); \ transform: scale(${theta.factor},${theta.factor}); \ }\ }\ @-webkit-keyframes to-bottom-left {\ 100% {\ left: -120px; \ bottom: calc(${theta.bottomOffset}px - 80px); \ transform: scale(${theta.factor},${theta.factor}); \ }\ }` theta.style.innerHTML = theta.keyFrames.replace(/A_DYNAMIC_VALUE/g, '180deg') + theta.css.replace(/A_DYNAMIC_VALUE/g, '180deg') document.getElementsByTagName('head')[0].appendChild(theta.style) } //Scroll Handlers theta.oneScroll = function () { let { rect, b, c, m, w, iw, ih, mw, mh } = theta.preparePositioning() if (c != 0) { theta.inread.containerWidth = theta.inread.container.style.width let style = `position: fixed; left: 50%; top: 50%; width: 1px !important; height: 1px !important;` theta.inread.container.setAttribute('style', style) theta.inread.iframe.setAttribute('style', style) if (theta.stickyElement) theta.stickyElement.el.setAttribute('style', style) if (theta.keepclose === true) { theta.inread.close.style.display = 'block' } theta.inread.buffer.setAttribute('style', `height: ${theta.inread.containerHeight}px;`) } else { theta.originalPosition(m) } } theta.one = function() { theta.inread.containerWidth = theta.inread.container.style.width let style = `position: fixed; left: 50%; top: 50%; width: 1px !important; height: 1px !important;` theta.inread.container.setAttribute('style', style) theta.inread.iframe.setAttribute('style', style) if (theta.stickyElement) theta.stickyElement.el.setAttribute('style', style) if (theta.keepclose === true) { theta.inread.close.style.display = 'block' } theta.inread.buffer.setAttribute('style', `height: ${theta.inread.containerHeight}px;`) } theta.simpleScroll = function () { let { rect, b, c, m, w, iw, ih, mw, mh } = theta.preparePositioning() if (c != 0) { theta.getBottomOffset() if (m) { theta.mobilePositioning(mw, mh) } else { let style = '' switch (theta.stickydirection) { case 'Right': style = `position: fixed; right: 0; bottom: ${theta.bottomOffset}px !important; width: ${iw}px !important; height: ${ih}px !important; z-index: 20 !important;` break case 'Left': style = `position: fixed; left: 0; bottom: ${theta.bottomOffset}px !important; width: ${iw}px !important; height: ${ih}px !important; z-index: 20 !important;` break } if (c == 1) { theta.inread.container.setAttribute('style', style) } else { theta.inread.container.setAttribute('style', style) } theta.inread.iframe.setAttribute('style', style) } if (theta.keepclose === true) { theta.inread.close.style.display = 'block' } theta.inread.buffer.setAttribute('style', `height: ${theta.inread.containerHeight}px;`) } else { theta.originalPosition(m) theta.inread.buffer.setAttribute('style', 'height: 0;') } } theta.scroll = function () { let { rect, b, c, m, w, iw, ih, mw, mh } = theta.preparePositioning() if (c != 0) { theta.getBottomOffset() theta.prepareStyle() if (m) { theta.mobilePositioning(mw, mh) } else { let style = `position: fixed; margin: 0 auto; left: 0 !important; right: 0 !important; bottom: 0px !important; width: ${iw}px !important; height: ${ih}px !important;` switch (theta.stickydirection) { case 'Right': var overstyle = `position: fixed; right: calc(50% - ${w}px); bottom: -10%; width: ${theta.inread.containerWidth}px !important; z-index: 20; -webkit-animation: to-bottom-right 0.75s 0.0s forwards;` var understyle = `position: fixed; right: calc(50% - ${w}px); bottom: 50%; width: ${theta.inread.containerWidth}px !important; z-index: 20; -webkit-animation: to-bottom-right 0.75s 0.0s forwards;` break case 'Left': var overstyle = `position: fixed; left: ${w}px; bottom: -10%; width: ${theta.inread.containerWidth}px !important; z-index: 20; -webkit-animation: to-bottom-left 0.75s 0.0s forwards;` var understyle = `position: fixed; left: ${w}px; bottom: 50%; width: ${theta.inread.containerWidth}px !important; z-index: 20; -webkit-animation: to-bottom-left 0.75s 0.0s forwards;` break } if (c == 1) { theta.inread.container.setAttribute('style', overstyle) } else { theta.inread.container.setAttribute('style', understyle) } theta.inread.iframe.setAttribute('style', style) } if (theta.keepclose === true) { theta.inread.close.style.display = 'block' } theta.inread.buffer.setAttribute('style', `height: ${theta.inread.containerHeight}px;`) } else { theta.originalPosition(m) } } //Positioning theta.preparePositioning = function () { let rect = { bottom: 0, height: 0, left: 0, right: 0, top: 0, width: 0, x: 0, y: 0 } rect = theta.inread.sibling.getBoundingClientRect() if (theta.inread.container.style.position.length === 0) { // theta.inread.containerWidth = theta.inread.container.clientWidth theta.inread.containerHeight = theta.inread.container.clientHeight } let w = theta.inread.containerWidth * theta.factor let b = { height: rect.height, width: rect.width, top: rect.top + theta.inread.containerHeight / 2 + theta.inread.sibling.clientHeight, left: rect.left } let c = theta.isElementInViewport(b) let m = theta.mobileCheck() let iw = 270 //theta.factor * theta.inread.containerWidth let ih = 202 //theta.factor * theta.inread.containerHeight let mw = theta.mobilefactor * theta.inread.containerWidth let mh = theta.mobilefactor * theta.inread.containerHeight return { rect, b, c, m, w, iw, ih, mw, mh } } theta.mobilePositioning = function (w, h) { if (theta.keepclose === true) { theta.inread.close.style.display = 'block' } let style = `position: fixed; bottom: ${theta.bottomOffset}px; left: 50%; transform: translate(-50%, 0); width: ${w}px !important; height: ${h}px !important; z-index: 20;` if (theta.mobilePosition !== undefined && theta.mobilePosition === 'top') { style = `position: fixed; top: 50px; left: 50%; transform: translate(-50%, 0); width: ${w}px !important; height: ${h}px !important; z-index: 20;` } theta.inread.container.setAttribute('style', style) theta.inread.iframe.setAttribute('style', style) // theta.inread.container.setAttribute( // 'style', // `position: fixed; top: 10%; left: 50%; transform: translate(-50%, -10%); width: ${w}px !important; height: ${h}px !important; z-index: 20;` // ) // theta.inread.iframe.setAttribute( // 'style', // `position: fixed; top: 10%; left: 50%; transform: translate(-50%, -10%); width: ${w}px !important; height: ${h}px !important; z-index: 20;` // ) // theta.inread.adsby.style.top = '55px' // theta.inread.close.style.top = '55px' // theta.inread.controlbar.style.bottom = '45px' } theta.originalPosition = function (m) { if (theta.keepclose === false) { theta.inread.close.style.display = 'none' } if (theta.stickyElement) theta.stickyElement.el.setAttribute( 'style', `clear: both; position:relative;` ) if (m) { theta.inread.container.setAttribute('style', 'position: relative;') theta.inread.iframe.setAttribute('style', 'position: relative;') theta.inread.adsby.style.top = '7px' theta.inread.close.style.top = '7px' theta.inread.controlbar.style.bottom = '0px' } else { theta.inread.container.setAttribute( 'style', `clear: both; position: relative; z-index:${theta.inread.zindex}; width: 100% !important; margin: 0 auto;` ) theta.inread.iframe.setAttribute( 'style', `clear: both; position: relative; width: 100% !important;` ) } theta.inread.buffer.setAttribute('style', `height: 0;`) } //Adform loaders theta.adform.prepare = function () { theta.inread.container = theta.inread.container || theta.d.getElementById('adform-outstream-smartinsert') if (theta.inread.container !== null) { theta.inread.container.style.bottom = 0 theta.inread.container.style.right = 0 theta.inread.container.style.margin = '0 auto' theta.inread.container.parentElement.style.zIndex = '3' theta.inread.iframe = theta.inread.iframe || theta.inread.container.getElementsByTagName('iframe')[0] if (theta.inread.iframe !== null) { theta.inread.video = theta.inread.video || theta.d .getElementById('adform-outstream-smartinsert') .getElementsByTagName('iframe')[0] .contentWindow.document.getElementsByTagName('video')[0] theta.inread.video.onerror = function (err) { console.log(err) } theta.inread.pl = theta.inread.pl || theta.inread.iframe.contentWindow.document.getElementById('vast-wrapper_html5_api') } } theta.inread.sibling = document.createElement('div') theta.inread.sibling.setAttribute('id', 'thetasib') if (theta.stickyElement) { theta.stickyElement.el.parentNode.insertBefore(theta.inread.sibling, theta.stickyElement.el) } else { theta.inread.container.parentNode.insertBefore(theta.inread.sibling, theta.inread.container) } theta.inread.buffer = document.createElement('div') theta.inread.buffer.setAttribute('id', 'thetabuffer') if (theta.stickyElement) { theta.stickyElement.el.parentNode.insertBefore(theta.inread.buffer, theta.stickyElement.el) } else { theta.inread.container.parentNode.insertBefore(theta.inread.buffer, theta.inread.container) } } theta.adform.finalize = () => { theta.iframe = theta.inread.container.querySelectorAll('iframe')[0] if (typeof theta.iframe !== "undefined" && theta.iframe.contentWindow.document.getElementById('thetaadsby') === null && theta.iframe.contentWindow.document.getElementById('banner') !== null && theta.iframe.contentWindow.document.getElementById('vast-skip') !== null) { theta.inread.adsby = theta.d.createElement('div') theta.inread.adsby.setAttribute('id', 'thetaadsby') theta.inread.adsby.setAttribute( 'style', 'display: block; \ position: absolute; \ z-index: 20; \ cursor: pointer; \ top: 7px; \ left: 5px; \ color: #fff; \ font-size: 11px; \ text-decoration: none; \ border-radius: 5px' ) let img = theta.d.createElement('img') img.src = 'https://assets.thetamedia.gr/inread/ads-by-theta@2x.png' if (theta.mobileCheck()) { img.setAttribute('width', '60') } else { img.setAttribute('width', '125') } theta.inread.adsby.appendChild(img) theta.inread.iframe.contentWindow.document .getElementById('banner') .appendChild(theta.inread.adsby) theta.inread.player = theta.inread.iframe.contentWindow.document.getElementById('vast-wrapper') theta.inread.player.style.backgroundColor = 'transparent' img = theta.d.createElement('img') img.src = 'https://assets.thetamedia.gr/inread/close-theta@2x.png' img.setAttribute('width', '16') theta.inread.close = theta.inread.iframe.contentWindow.document.getElementById('vast-skip') // theta.inread.close.appendChild(img) if (theta.keepclose === false) { theta.inread.close.style.display = 'none' } theta.inread.clearInterval = window.parent.setInterval(function () { if (theta.inread.container.getElementsByTagName('iframe')[0] === undefined) { theta.inread.container.remove() window.parent.clearInterval(theta.inread.clearInterval); window.parent.clearInterval(theta.inread.scrollInterval); window.clearInterval(theta.inread.clearInterval); window.clearInterval(theta.inread.scrollInterval); } }, 500); } } theta.adform.passback = function () { if (theta.passback !== 'null' && typeof theta.passback !== 'object') { theta.passback = JSON.parse(theta.passback); (function (window, document, undefined) { theta.d.getElementById('adform-outstream-smartinsert').remove() if (theta.passback.type === 'url') { if (theta.passback.platform === 'adform') { theta.inread.pmpid = theta.passback.pmpid theta.adform.load() } else { var script_tag = document.createElement('script') script_tag.src = theta.passback.url script_tag.async = true script_tag.defer = true theta.ins.appendChild(script_tag) } } else if (theta.passback.type === 'file') { var script_tag = document.createElement('script') if (theta.passback.uri !== undefined) script_tag.src = theta.passback.uri else script_tag.src = theta.passbackuri script_tag.async = true script_tag.defer = true theta.ins.appendChild(script_tag) } })(window, document) } } theta.adform.load = function () { ; (function (window, document, Adform) { window._adform = window._adform || [] window.ADFSlot = function () { return { paragraphs: window.document.getElementById('theta-selector') } } window._adform.push([ theta.inread.pmpid + '.pmp.empty', function () { theta.adform.passback() } ]) window._adform.push([ theta.inread.pmpid + '.ad.ready', function () { theta.adform.prepare() theta[theta.method]() // let observerOptions = { // threshold: [0.3] // } // var observer = new IntersectionObserver(observerCallback, observerOptions); // function observerCallback(entries, observer) { // entries.forEach(entry => { // if (entry.isIntersecting && theta.inread.container.clientHeight > 0) { // theta.originalPosition() // } else if(!entry.isIntersecting) { // theta.one() // } // }); // }; // observer.observe(theta.d.getElementById('thetasib')) theta.adform.finalize() } ]) })(window.parent, document, (Adform = window.Adform || {})) theta.inread.scriptcontainer = document.createElement('div') theta.inread.scriptcontainer.setAttribute('id', 'adform-outstream') theta.inread.scriptcontainer.setAttribute('style', 'height:auto;overflow:hidden;') theta.ins.appendChild(theta.inread.scriptcontainer) let src = '//s1.adform.net/banners/scripts/video/outstream/inview.js' if (theta.querystring !== "null") { src += `?${theta.querystring}` } theta.inviewtag = document.createElement('script') theta.inviewtag.src = src let pmpid = theta.inread.pmpid theta.inviewtag.setAttribute('data-pmp-id', pmpid) theta.inviewtag.setAttribute('data-query-append', `schain=1.0,1!thetamarketplace.com,${theta.sellerid},1`) theta.inviewtag.setAttribute( 'data-close-oncomplete', typeof theta.stayoncomplete !== 'undefined' ? 'false' : 'true' ) theta.inviewtag.setAttribute('data-skip-button-label', ' ') theta.inviewtag.setAttribute('language', 'javascript') theta.inread.scriptcontainer.appendChild(theta.inviewtag) } //Methods theta.none = function () { } theta.simplesticky = () => { if (theta.inread.iframe !== null) { window.addEventListener('scroll', () => { theta.scrolling = true }) theta.inread.scrollInterval = setInterval(() => { theta.adform.finalize() if (theta.scrolling) { theta.scrolling = false if(theta.mobileCheck()) { theta.oneScroll() } else { theta.simpleScroll() } } }, 300) } } theta.onesticky = () => { if (theta.inread.iframe !== null) { window.parent.addEventListener('scroll', () => { theta.scrolling = true }) theta.inread.scrollInterval = setInterval(() => { theta.adform.finalize() if (theta.scrolling) { theta.scrolling = false theta.oneScroll() } }, 300) } } theta.makesticky = () => { if (theta.inread.iframe !== null) { window.addEventListener('scroll', () => { theta.scrolling = true }) theta.inread.scrollInterval = setInterval(() => { if (theta.scrolling) { theta.scrolling = false theta.scroll() } }, 300) } }; (() => { if (theta.mobileCheck() && theta.mobileWidth !== undefined) { theta.inread.containerWidth = theta.mobileWidth } if (document.getElementById(`theta-selector`) === null) { if (theta.mobileCheck()) { theta.bottomOffset = 0 } theta.prepareStyle() theta.ins = theta.d.querySelectorAll(theta.selector) if (theta.passbackuri.includes('meteoinread')) { let t = theta.d.querySelectorAll('#outerTable')[1]; theta.ins = t.querySelectorAll('tbody > tr > td > div') } if (theta.ins.length > 0) { if (theta.stickyElements !== 'undefined') { let elements = theta.stickyElements let el = theta.d.querySelectorAll(theta.stickyElements)[0] theta.stickyElement = { el: el, width: el.style.width, height: el.style.height } }; if (theta.method.includes('-')) { [theta.method, theta.stickydirection] = theta.method.split('-') } let index = typeof theta.selectorIndex === "undefined" ? 1 : theta.selectorIndex theta.ins = theta.ins.length === 1 || theta.selector.includes('#') ? theta.ins[0] : theta.ins[index] var thetains = theta.ins theta.el = theta.d.createElement('div') theta.el.setAttribute('id', 'theta-selector') theta.ins.appendChild(theta.el) theta.ins.style.display = "inherit" theta.selector = '#theta-selector' theta.body = theta.d.getElementsByTagName('body')[0] if (theta.platform === 'adform') { theta.adform.load() } } } })()