diff --git a/docs/src/modules/components/Ad.js b/docs/src/modules/components/Ad.js index 0006e4b619101e..e2532d7f1c62f1 100644 --- a/docs/src/modules/components/Ad.js +++ b/docs/src/modules/components/Ad.js @@ -25,11 +25,6 @@ const styles = theme => ({ }, }); -function getAdblockCount() { - const seen = getCookie('adblockCount'); - return seen === '' ? 0 : parseInt(seen, 10); -} - function getAdblock(classes, t) { return ( @@ -70,16 +65,22 @@ const inHouses = [ function Ad(props) { const { classes } = props; const { current: random } = React.useRef(Math.random()); - const timerAdblock = React.useRef(); const t = useSelector(state => state.options.t); + + const timerAdblock = React.useRef(); const [adblock, setAdblock] = React.useState(null); + const [carbonOut, setCarbonOut] = React.useState(null); const checkAdblock = React.useCallback((attempt = 1) => { - if ( - document.querySelector('.cf-wrapper') || - document.querySelector('#carbonads') || - document.querySelector('#in-house') - ) { + if (document.querySelector('.cf-wrapper') || document.querySelector('#carbonads')) { + if ( + document.querySelector('#carbonads a') && + document.querySelector('#carbonads a').getAttribute('href') === + 'https://material-ui-next.com/discover-more/backers' + ) { + setCarbonOut(true); + } + setAdblock(false); return; } @@ -88,8 +89,6 @@ function Ad(props) { timerAdblock.current = setTimeout(() => { checkAdblock(attempt + 1); }, 500); - } else { - document.cookie = `adblockCount=${getAdblockCount() + 1};path=/`; } if (attempt > 6) { @@ -113,33 +112,34 @@ function Ad(props) { return null; } - if (disable) { - return {getAdblock(classes, t)}; - } + let children; - if (getAdblockCount() >= 2) { - return ( - - - - ); + if (adblock) { + children = ; } - if (adblock === true) { - return {getAdblock(classes, t)}; + if (disable) { + children = getAdblock(classes, t); } - let randomAd; - - if (random < 0.6) { - randomAd = ; - } else if (random < 0.63) { - randomAd = ; - } else { - randomAd = ; + if (!children) { + if (random >= 0.6) { + children = ; + } else if (!carbonOut) { + children = ; + } else { + children = ; + } } - return {randomAd}; + return ( + + {children} + + ); } Ad.propTypes = { diff --git a/docs/src/pages.js b/docs/src/pages.js index c5d502e006dcc5..cabe95c39873df 100644 --- a/docs/src/pages.js +++ b/docs/src/pages.js @@ -232,7 +232,7 @@ const pages = [ }, ], }, - { pathname: 'https://material-ui.com/versions', displayNav: false }, + { pathname: '/versions', displayNav: false }, { pathname: '/', displayNav: false, title: false }, ];