mirror of
https://github.com/koreanbots/core.git
synced 2025-12-16 14:30:22 +00:00
refactor: detact adblock (#509)
* refactor: detact adblock * perf: implement mobile detection
This commit is contained in:
parent
516f72ad08
commit
cf0bc9dc08
@ -53,6 +53,7 @@
|
|||||||
"react": "17.0.2",
|
"react": "17.0.2",
|
||||||
"react-adsense": "0.1.0",
|
"react-adsense": "0.1.0",
|
||||||
"react-dom": "17.0.2",
|
"react-dom": "17.0.2",
|
||||||
|
"react-ga": "^3.3.1",
|
||||||
"react-hotkeys": "2.0.0",
|
"react-hotkeys": "2.0.0",
|
||||||
"react-responsive-modal": "6.1.0",
|
"react-responsive-modal": "6.1.0",
|
||||||
"react-select": "4.3.1",
|
"react-select": "4.3.1",
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import { DefaultSeo } from 'next-seo'
|
|||||||
import { GlobalHotKeys } from 'react-hotkeys'
|
import { GlobalHotKeys } from 'react-hotkeys'
|
||||||
import NProgress from 'nprogress'
|
import NProgress from 'nprogress'
|
||||||
import Package from '../package.json'
|
import Package from '../package.json'
|
||||||
|
import ReactGA from 'react-ga'
|
||||||
|
|
||||||
import Logger from '@utils/Logger'
|
import Logger from '@utils/Logger'
|
||||||
import { handlePWA, parseCookie, parseDockerhubTag, systemTheme } from '@utils/Tools'
|
import { handlePWA, parseCookie, parseDockerhubTag, systemTheme } from '@utils/Tools'
|
||||||
@ -29,6 +30,9 @@ Router.events.on('routeChangeStart', NProgress.start)
|
|||||||
Router.events.on('routeChangeComplete', NProgress.done)
|
Router.events.on('routeChangeComplete', NProgress.done)
|
||||||
Router.events.on('routeChangeError', NProgress.done)
|
Router.events.on('routeChangeError', NProgress.done)
|
||||||
|
|
||||||
|
// Google Analytics
|
||||||
|
ReactGA.initialize('UA-165454387-1')
|
||||||
|
|
||||||
const KoreanbotsApp = ({ Component, pageProps, err, cookie }: KoreanbotsProps): JSX.Element => {
|
const KoreanbotsApp = ({ Component, pageProps, err, cookie }: KoreanbotsProps): JSX.Element => {
|
||||||
const [ shortcutModal, setShortcutModal ] = useState(false)
|
const [ shortcutModal, setShortcutModal ] = useState(false)
|
||||||
const [ theme, setTheme ] = useState<Theme>('system')
|
const [ theme, setTheme ] = useState<Theme>('system')
|
||||||
@ -51,6 +55,10 @@ const KoreanbotsApp = ({ Component, pageProps, err, cookie }: KoreanbotsProps):
|
|||||||
}
|
}
|
||||||
else setTheme(localStorage.theme)
|
else setTheme(localStorage.theme)
|
||||||
setStandalone(handlePWA())
|
setStandalone(handlePWA())
|
||||||
|
|
||||||
|
const script = document.querySelector('script[src*=googlesyndication]')
|
||||||
|
|
||||||
|
if (script) script.addEventListener('error', () => {ReactGA.ga('send', 'event', 'adblock', 'adblock_' + (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile|WPDesktop/i) ? 'mobile' : 'pc'))})
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
return <div className={theme}>
|
return <div className={theme}>
|
||||||
|
|||||||
@ -7913,6 +7913,11 @@ react-fast-compare@^2.0.1:
|
|||||||
resolved "https://registry.yarnpkg.com/react-fast-compare/-/react-fast-compare-2.0.4.tgz#e84b4d455b0fec113e0402c329352715196f81f9"
|
resolved "https://registry.yarnpkg.com/react-fast-compare/-/react-fast-compare-2.0.4.tgz#e84b4d455b0fec113e0402c329352715196f81f9"
|
||||||
integrity sha512-suNP+J1VU1MWFKcyt7RtjiSWUjvidmQSlqu+eHslq+342xCbGTYmC0mEhPCOHxlW0CywylOC1u2DFAT+bv4dBw==
|
integrity sha512-suNP+J1VU1MWFKcyt7RtjiSWUjvidmQSlqu+eHslq+342xCbGTYmC0mEhPCOHxlW0CywylOC1u2DFAT+bv4dBw==
|
||||||
|
|
||||||
|
react-ga@^3.3.1:
|
||||||
|
version "3.3.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/react-ga/-/react-ga-3.3.1.tgz#d8e1f4e05ec55ed6ff944dcb14b99011dfaf9504"
|
||||||
|
integrity sha512-4Vc0W5EvXAXUN/wWyxvsAKDLLgtJ3oLmhYYssx+YzphJpejtOst6cbIHCIyF50Fdxuf5DDKqRYny24yJ2y7GFQ==
|
||||||
|
|
||||||
react-hotkeys@2.0.0:
|
react-hotkeys@2.0.0:
|
||||||
version "2.0.0"
|
version "2.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/react-hotkeys/-/react-hotkeys-2.0.0.tgz#a7719c7340cbba888b0e9184f806a9ec0ac2c53f"
|
resolved "https://registry.yarnpkg.com/react-hotkeys/-/react-hotkeys-2.0.0.tgz#a7719c7340cbba888b0e9184f806a9ec0ac2c53f"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user