From c4fc2993d5b8c56cf726417fa2234549178840f9 Mon Sep 17 00:00:00 2001 From: Sean Yesmunt Date: Thu, 26 Mar 2020 17:47:07 -0400 Subject: [PATCH] initial commit for inline video ads --- lbrytv/component/ads.jsx | 77 +++++++++++++++++------- ui/component/channelContent/index.js | 9 +-- ui/component/channelContent/view.jsx | 10 ++- ui/component/claimList/view.jsx | 44 ++++++++------ ui/component/claimListDiscover/view.jsx | 3 + ui/component/recommendedContent/index.js | 7 +-- ui/component/recommendedContent/view.jsx | 5 +- ui/page/discover/index.js | 2 + ui/page/discover/view.jsx | 4 ++ ui/page/search/index.js | 7 +-- ui/page/search/view.jsx | 27 ++++++--- ui/scss/component/_ads.scss | 34 +++++++++++ 12 files changed, 162 insertions(+), 67 deletions(-) diff --git a/lbrytv/component/ads.jsx b/lbrytv/component/ads.jsx index 9068d9ffa..d5e584ce3 100644 --- a/lbrytv/component/ads.jsx +++ b/lbrytv/component/ads.jsx @@ -4,28 +4,49 @@ 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 (!IS_MOBILE) { - const script = document.createElement('script'); + 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.inmodifiedUrlQuerysertBefore(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); @@ -37,27 +58,37 @@ function Ads(props: Props) { } }; } - }, []); + }, [type]); - return ( + const adsSignInDriver = ( + + ), + download_the_app: