remove more google

This commit is contained in:
zeppi 2021-06-22 13:16:02 -04:00 committed by jessopb
parent 1b528ea856
commit 6d8fce6011
2 changed files with 1 additions and 145 deletions

View file

@ -46,33 +46,6 @@
}
}
// Related list ads
.ads__related--google {
border-bottom: 1px solid var(--color-border);
background-color: var(--color-card-background);
display: flex;
flex-direction: row;
flex-wrap: wrap;
width: 100%;
> div,
ins {
width: 100%;
position: relative !important;
max-width: 30rem;
min-width: 15rem;
margin: var(--spacing-s);
}
@media (max-width: $breakpoint-small) {
flex-direction: column;
> div {
width: 100%;
}
}
}
.ads__claim-text {
display: flex;
flex-direction: column;

View file

@ -1,6 +1,5 @@
// @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';
@ -8,46 +7,14 @@ 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,
};
@ -57,41 +24,8 @@ function Ads(props: Props) {
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;
@ -129,53 +63,6 @@ function Ads(props: Props) {
}
}, [type]);
useEffect(() => {
let script;
const GOOGLE_AD_ELEMENT_ID = 'googleadscriptid';
if (SHOW_ADS && type === 'google' && !isBlocked) {
const d = document;
if (!d.getElementById(GOOGLE_AD_ELEMENT_ID)) {
try {
const s = 'script';
let fjs = d.getElementsByTagName(s)[0];
script = d.createElement(s);
script.id = 'googleadscriptid';
script.src = 'https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js';
script.setAttribute('async', 'async');
script.setAttribute('data-ad-client', 'ca-pub-7102138296475003');
// $FlowFixMe
fjs.parentNode.insertBefore(script, fjs);
} catch (e) {}
}
googleInit = setTimeout(() => {
if (typeof window !== 'undefined') {
(window.adsbygoogle = window.adsbygoogle || []).push({});
}
}, 1000);
} else if (isBlocked) {
let fjs = document.getElementById(GOOGLE_AD_ELEMENT_ID);
if (fjs) fjs.remove();
}
return () => {
if (googleInit) {
clearTimeout(googleInit);
}
};
}, [type, isBlocked]);
const googleAd = (
<div className="ads__related--google">
<ins
className="adsbygoogle"
style={{ display: 'block' }}
data-ad-format="fluid"
data-ad-layout-key={theme === LIGHT_THEME ? G_AD_LIGHT_LAYOUT : G_AD_DARK_LAYOUT}
data-ad-client={G_AD_ID}
data-ad-slot={theme === LIGHT_THEME ? G_AD_LIGHT_SLOT : G_AD_DARK_SLOT}
/>
</div>
);
const adsSignInDriver = (
<I18nMessage
tokens={{
@ -221,17 +108,13 @@ function Ads(props: Props) {
</div>
);
if (!SHOW_ADS || (type === 'google' && isBlocked)) {
if (!SHOW_ADS) {
return false;
}
if (type === 'video') {
return videoAd;
}
if (type === 'google') {
return googleAd;
}
if (type === 'sidebar') {
return sidebarAd;
}