Commit 0b593902 authored by isstuev's avatar isstuev

Adblock detect improvement

parent 2e9728ef
...@@ -34,9 +34,13 @@ export default function useAdblockDetect() { ...@@ -34,9 +34,13 @@ export default function useAdblockDetect() {
method: 'HEAD', method: 'HEAD',
mode: 'no-cors', mode: 'no-cors',
cache: 'no-store', cache: 'no-store',
}).catch(() => { })
cookies.set(cookies.NAMES.ADBLOCK_DETECTED, 'true', { expires: 1 }); .then(() => {
}); cookies.set(cookies.NAMES.ADBLOCK_DETECTED, 'false', { expires: 1 });
})
.catch(() => {
cookies.set(cookies.NAMES.ADBLOCK_DETECTED, 'true', { expires: 1 });
});
} }
// eslint-disable-next-line react-hooks/exhaustive-deps // eslint-disable-next-line react-hooks/exhaustive-deps
}, []); }, []);
......
...@@ -17,7 +17,7 @@ const DetailsSponsoredItem = ({ isLoading }: Props) => { ...@@ -17,7 +17,7 @@ const DetailsSponsoredItem = ({ isLoading }: Props) => {
const isMobile = useIsMobile(); const isMobile = useIsMobile();
const hasAdblockCookie = cookies.get(cookies.NAMES.ADBLOCK_DETECTED); const hasAdblockCookie = cookies.get(cookies.NAMES.ADBLOCK_DETECTED);
if (!feature.isEnabled || hasAdblockCookie) { if (!feature.isEnabled || hasAdblockCookie === 'true') {
return null; return null;
} }
......
...@@ -18,7 +18,7 @@ const AdBanner = ({ className, isLoading }: { className?: string; isLoading?: bo ...@@ -18,7 +18,7 @@ const AdBanner = ({ className, isLoading }: { className?: string; isLoading?: bo
const hasAdblockCookie = cookies.get(cookies.NAMES.ADBLOCK_DETECTED, useAppContext().cookies); const hasAdblockCookie = cookies.get(cookies.NAMES.ADBLOCK_DETECTED, useAppContext().cookies);
if (!feature.isEnabled || hasAdblockCookie || !provider) { if (!feature.isEnabled || hasAdblockCookie === 'true' || !provider) {
return null; return null;
} }
......
...@@ -10,7 +10,7 @@ import CoinzillaTextAd from './CoinzillaTextAd'; ...@@ -10,7 +10,7 @@ import CoinzillaTextAd from './CoinzillaTextAd';
const TextAd = ({ className }: {className?: string}) => { const TextAd = ({ className }: {className?: string}) => {
const hasAdblockCookie = cookies.get(cookies.NAMES.ADBLOCK_DETECTED, useAppContext().cookies); const hasAdblockCookie = cookies.get(cookies.NAMES.ADBLOCK_DETECTED, useAppContext().cookies);
if (!config.features.adsText.isEnabled || hasAdblockCookie) { if (!config.features.adsText.isEnabled || hasAdblockCookie === 'true') {
return null; return null;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment