// @flow 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'; type Props = { location: { pathname: string }, type: string, small: boolean, }; function Ads(props: Props) { const { location: { pathname }, type = 'sidebar', small, } = props; useEffect(() => { if (type === 'video') { try { const d = document; const s = 'script'; const n = 'playbuzz-stream'; let js; let fjs = d.getElementsByTagName(s)[0]; js = d.createElement(s); js.className = n; js.src = 'https://stream.playbuzz.com/player/62d1eb10-e362-4873-99ed-c64a4052b43b'; // $FlowFixMe fjs.parentNode.insertBefore(js, fjs); } catch (e) {} } }, [type]); useEffect(() => { if (!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,