provide ad blacklisting

This commit is contained in:
zeppi 2021-01-30 22:47:06 -05:00 committed by jessopb
parent 64874c773b
commit 11931d4037
3 changed files with 14 additions and 3 deletions

View file

@ -61,7 +61,7 @@ export default function RecommendedContent(props: Props) {
injectedItem={ injectedItem={
SHOW_ADS && IS_WEB ? ( SHOW_ADS && IS_WEB ? (
SIMPLE_SITE ? ( SIMPLE_SITE ? (
<Ads small type={'google'} /> <Ads small type={'google'} uri={uri} />
) : ( ) : (
!isAuthenticated && <Ads small type={'video'} /> !isAuthenticated && <Ads small type={'video'} />
) )

View file

@ -1,8 +1,11 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { selectTheme } from 'redux/selectors/settings'; import { selectTheme } from 'redux/selectors/settings';
import { makeSelectClaimForUri, makeSelectClaimIsNsfw } from 'lbry-redux';
import Ads from './view'; import Ads from './view';
const select = state => ({ const select = (state, props) => ({
theme: selectTheme(state), theme: selectTheme(state),
claim: makeSelectClaimForUri(props.uri)(state),
isMature: makeSelectClaimIsNsfw(props.uri)(state),
}); });
export default connect(select)(Ads); export default connect(select)(Ads);

View file

@ -7,6 +7,7 @@ import { withRouter } from 'react-router';
import I18nMessage from 'component/i18nMessage'; import I18nMessage from 'component/i18nMessage';
import Button from 'component/button'; import Button from 'component/button';
import classnames from 'classnames'; import classnames from 'classnames';
import { ADS_CHANNEL_BLACKLIST } from 'homepages';
const ADS_URL = '//assets.revcontent.com/master/delivery.js'; const ADS_URL = '//assets.revcontent.com/master/delivery.js';
const IS_MOBILE = typeof window.orientation !== 'undefined'; const IS_MOBILE = typeof window.orientation !== 'undefined';
@ -25,6 +26,8 @@ type Props = {
type: string, type: string,
small: boolean, small: boolean,
theme: string, theme: string,
claim: GenericClaim,
isMature: boolean,
}; };
function Ads(props: Props) { function Ads(props: Props) {
@ -33,9 +36,14 @@ function Ads(props: Props) {
type = 'sidebar', type = 'sidebar',
small, small,
theme, theme,
claim,
isMature,
} = props; } = props;
let googleInit; 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(() => { useEffect(() => {
if (SHOW_ADS && type === 'video') { if (SHOW_ADS && type === 'video') {
let script; let script;
@ -162,7 +170,7 @@ function Ads(props: Props) {
</div> </div>
); );
if (!SHOW_ADS) { if (!SHOW_ADS || (type === 'google' && isBlocked)) {
return false; return false;
} }
if (type === 'video') { if (type === 'video') {