Enabler.isServingInLiveEnvironment() ? Enabler.addEventListener(studio.events.StudioEvent.HOSTPAGE_SCROLL, this.g, !1) : window.addEventListener("message", this.g, !1);
A more generic solution would be like what @michelangelo pointed you to, with the caveat that most ads are served within an iframe, so you can’t get the scroll position so easily. First, I don’t think you can hook into the
window.onscroll event since that will be looking at the wrong window. You may instead need to use a timer, which isn’t so pretty. To get the scroll position, I’d instead do something like a
window.parent.parent.parent.scrollY to ensure you get the scroll of the top of the page. You’d also need to find your own offset.