Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
frontend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
frontend
Commits
bc91786d
Commit
bc91786d
authored
Apr 02, 2024
by
isstuev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adblock detect improvement
parent
3fd7f42b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
2 deletions
+26
-2
useAdblockDetect.tsx
lib/hooks/useAdblockDetect.tsx
+22
-2
ad.ts
nextjs/csp/policies/ad.ts
+4
-0
No files found.
lib/hooks/useAdblockDetect.tsx
View file @
bc91786d
import
{
useEffect
}
from
'
react
'
;
import
{
useEffect
}
from
'
react
'
;
import
type
{
AdBannerProviders
}
from
'
types/client/adProviders
'
;
import
config
from
'
configs/app
'
;
import
{
useAppContext
}
from
'
lib/contexts/app
'
;
import
{
useAppContext
}
from
'
lib/contexts/app
'
;
import
*
as
cookies
from
'
lib/cookies
'
;
import
*
as
cookies
from
'
lib/cookies
'
;
import
isBrowser
from
'
lib/isBrowser
'
;
import
isBrowser
from
'
lib/isBrowser
'
;
const
DEFAULT_URL
=
'
https://request-global.czilladx.com
'
;
// in general, detect should work with any ad-provider url (that is alive)
// but we see some false-positive results in certain browsers
const
TEST_URLS
:
Record
<
AdBannerProviders
,
string
>
=
{
slise
:
'
https://v1.slise.xyz/serve
'
,
coinzilla
:
'
https://request-global.czilladx.com
'
,
adbutler
:
'
https://servedbyadbutler.com/app.js
'
,
hype
:
'
https://api.hypelab.com/v1/scripts/hp-sdk.js
'
,
// I don't have an url for getit to test
getit
:
DEFAULT_URL
,
none
:
DEFAULT_URL
,
};
const
feature
=
config
.
features
.
adsBanner
;
export
default
function
useAdblockDetect
()
{
export
default
function
useAdblockDetect
()
{
const
hasAdblockCookie
=
cookies
.
get
(
cookies
.
NAMES
.
ADBLOCK_DETECTED
,
useAppContext
().
cookies
);
const
hasAdblockCookie
=
cookies
.
get
(
cookies
.
NAMES
.
ADBLOCK_DETECTED
,
useAppContext
().
cookies
);
const
provider
=
feature
.
isEnabled
&&
feature
.
provider
;
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
isBrowser
()
&&
!
hasAdblockCookie
)
{
if
(
isBrowser
()
&&
!
hasAdblockCookie
&&
provider
)
{
const
url
=
'
https://request-global.czilladx.com
'
;
const
url
=
TEST_URLS
[
provider
]
||
DEFAULT_URL
;
fetch
(
url
,
{
fetch
(
url
,
{
method
:
'
HEAD
'
,
method
:
'
HEAD
'
,
mode
:
'
no-cors
'
,
mode
:
'
no-cors
'
,
...
...
nextjs/csp/policies/ad.ts
View file @
bc91786d
...
@@ -13,12 +13,16 @@ export function ad(): CspDev.DirectiveDescriptor {
...
@@ -13,12 +13,16 @@ export function ad(): CspDev.DirectiveDescriptor {
'
*.coinzilla.com
'
,
'
*.coinzilla.com
'
,
'
https://request-global.czilladx.com
'
,
'
https://request-global.czilladx.com
'
,
// adbutler
'
servedbyadbutler.com
'
,
// slise
// slise
'
*.slise.xyz
'
,
'
*.slise.xyz
'
,
// hype
// hype
'
api.hypelab.com
'
,
'
api.hypelab.com
'
,
'
*.ixncdn.com
'
,
'
*.ixncdn.com
'
,
'
*.cloudfront.net
'
,
//getit
//getit
'
v1.getittech.io
'
,
'
v1.getittech.io
'
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment