// @flow import { DOMAIN, SHOW_ADS } from 'config'; import * as PAGES from 'constants/pages'; import React, { useEffect } from 'react'; import { withRouter } from 'react-router'; import I18nMessage from 'component/i18nMessage'; import Button from 'component/button'; import classnames from 'classnames'; const ADS_URL = '//assets.revcontent.com/master/delivery.js'; const IS_MOBILE = typeof window.orientation !== 'undefined'; const G_AD_ID = 'ca-pub-7102138296475003'; // const G_AD_ONE_LAYOUT = '-gv+p-3a-8r+sd'; // const G_AD_ONE_SLOT = '6052061397'; const G_AD_TWO_LAYOUT = '-hl-o+3s-6c+33'; // dark mode, related const G_AD_TWO_SLOT = '1498002046'; type Props = { location: { pathname: string }, type: string, small: boolean, }; function Ads(props: Props) { const { location: { pathname }, type = 'sidebar', small, } = props; let googleInit; useEffect(() => { if (SHOW_ADS && type === 'video') { let script; try { const d = document; const s = 'script'; const n = 'playbuzz-stream'; let fjs = d.getElementsByTagName(s)[0]; script = d.createElement(s); script.className = n; script.src = 'https://stream.playbuzz.com/player/62d1eb10-e362-4873-99ed-c64a4052b43b'; // $FlowFixMe fjs.parentNode.insertBefore(script, fjs); } catch (e) {} } }, [type]); useEffect(() => { if (SHOW_ADS && !IS_MOBILE && type === 'sidebar') { const script = document.createElement('script'); script.src = ADS_URL; script.async = true; // $FlowFixMe document.body.appendChild(script); return () => { // $FlowFixMe document.body.removeChild(script); // if user navigates too rapidly,