// @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'; // $FlowFixMe import { NO_ADS_CHANNEL_IDS } from 'homepages'; const NO_ADS_TEXT_KEYWORDS = [ 'juifs', 'holocaust', 'orona', 'vaccin', 'pcr', 'covid', 'pfizer', 'propogand', 'conspira', 'pandem', 'moutons', 'negroes', 'sars-cov', 'vacuna', 'blancs', 'whites', 'silvano trotta', 'covid-19', ]; 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, claim: Claim, isMature: boolean, }; function Ads(props: Props) { const { location: { pathname }, type = 'sidebar', small, theme, claim, isMature, } = props; let googleInit; const channelId = claim && claim.signing_channel && claim.signing_channel.claim_id; let claimString: string = ''; if (claim) claimString = claim.name; if (claim && claim.value) { if (claim.value.tags) { claimString = claimString + claim.value.tags.join(','); } if (claim.value.description) { claimString = claimString + claim.value.description; } if (claim.value.title) { claimString = claimString + claim.value.title; } } claimString = claimString.toLowerCase(); const checkStringForAdsense = (text, words) => { for (let i = 0; i < words.length; i++) { if (text.includes(words[i])) { return true; } } return false; }; const isBlocked = isMature || (NO_ADS_CHANNEL_IDS && NO_ADS_CHANNEL_IDS.includes(channelId)) || checkStringForAdsense(claimString, NO_ADS_TEXT_KEYWORDS); 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,