From 11931d4037dfcb83847d725dafc2b564d1279c55 Mon Sep 17 00:00:00 2001 From: zeppi Date: Sat, 30 Jan 2021 22:47:06 -0500 Subject: [PATCH] provide ad blacklisting --- ui/component/recommendedContent/view.jsx | 2 +- web/component/ads/index.js | 5 ++++- web/component/ads/view.jsx | 10 +++++++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/ui/component/recommendedContent/view.jsx b/ui/component/recommendedContent/view.jsx index 495a1aad3..817036212 100644 --- a/ui/component/recommendedContent/view.jsx +++ b/ui/component/recommendedContent/view.jsx @@ -61,7 +61,7 @@ export default function RecommendedContent(props: Props) { injectedItem={ SHOW_ADS && IS_WEB ? ( SIMPLE_SITE ? ( - + ) : ( !isAuthenticated && ) diff --git a/web/component/ads/index.js b/web/component/ads/index.js index b7acdd5d1..6724d4bd0 100644 --- a/web/component/ads/index.js +++ b/web/component/ads/index.js @@ -1,8 +1,11 @@ import { connect } from 'react-redux'; import { selectTheme } from 'redux/selectors/settings'; +import { makeSelectClaimForUri, makeSelectClaimIsNsfw } from 'lbry-redux'; import Ads from './view'; -const select = state => ({ +const select = (state, props) => ({ theme: selectTheme(state), + claim: makeSelectClaimForUri(props.uri)(state), + isMature: makeSelectClaimIsNsfw(props.uri)(state), }); export default connect(select)(Ads); diff --git a/web/component/ads/view.jsx b/web/component/ads/view.jsx index 7502becad..a983f6ec4 100644 --- a/web/component/ads/view.jsx +++ b/web/component/ads/view.jsx @@ -7,6 +7,7 @@ import { withRouter } from 'react-router'; import I18nMessage from 'component/i18nMessage'; import Button from 'component/button'; import classnames from 'classnames'; +import { ADS_CHANNEL_BLACKLIST } from 'homepages'; const ADS_URL = '//assets.revcontent.com/master/delivery.js'; const IS_MOBILE = typeof window.orientation !== 'undefined'; @@ -25,6 +26,8 @@ type Props = { type: string, small: boolean, theme: string, + claim: GenericClaim, + isMature: boolean, }; function Ads(props: Props) { @@ -33,9 +36,14 @@ function Ads(props: Props) { type = 'sidebar', small, theme, + claim, + isMature, } = props; let googleInit; + const channelId = claim && claim.signing_channel && claim.signing_channel.claim_id; + + const isBlocked = isMature || (ADS_CHANNEL_BLACKLIST && ADS_CHANNEL_BLACKLIST.includes(channelId)); useEffect(() => { if (SHOW_ADS && type === 'video') { let script; @@ -162,7 +170,7 @@ function Ads(props: Props) { ); - if (!SHOW_ADS) { + if (!SHOW_ADS || (type === 'google' && isBlocked)) { return false; } if (type === 'video') {