// @flow import { DOMAIN, SHOW_ADS } from 'config'; import { LIGHT_THEME } from 'constants/themes'; 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_LIGHT_LAYOUT = '-h9-o+3s-6c+33'; // old layout const G_AD_LIGHT_LAYOUT = '-gr-p+3s-5w+2d'; // light mode, related const G_AD_LIGHT_SLOT = '1498002046'; const G_AD_DARK_LAYOUT = '-gr-p+3s-5w+2d'; // dark mode, related const G_AD_DARK_SLOT = '7266878639'; type Props = { location: { pathname: string }, type: string, small: boolean, theme: string, }; function Ads(props: Props) { const { location: { pathname }, type = 'sidebar', small, theme, } = 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,