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
9cdc8610
Commit
9cdc8610
authored
Jun 20, 2023
by
isstuev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix adbutler
parent
f83d0670
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
23 deletions
+30
-23
global.d.ts
global.d.ts
+5
-0
ad.ts
lib/csp/policies/ad.ts
+1
-2
AdbutlerBanner.tsx
ui/shared/ad/AdbutlerBanner.tsx
+23
-5
adbutlerScript.ts
ui/shared/ad/adbutlerScript.ts
+1
-16
No files found.
global.d.ts
View file @
9cdc8610
...
...
@@ -13,5 +13,10 @@ declare global {
ga
?:
{
getAll
:
()
=>
Array
<
{
get
:
(
prop
:
string
)
=>
string
}
>
;
};
AdButler
:
{
ads
:
Array
<
unknown
>
;
register
:
(...
args
:
unknown
)
=>
void
;
};
abkw
:
string
;
}
}
lib/csp/policies/ad.ts
View file @
9cdc8610
...
...
@@ -3,7 +3,7 @@ import sha256 from 'crypto-js/sha256';
import
type
CspDev
from
'
csp-dev
'
;
import
isSelfHosted
from
'
lib/isSelfHosted
'
;
import
{
connectAdbutler
,
placeAd
,
placeAdSPA
}
from
'
ui/shared/ad/adbutlerScript
'
;
import
{
connectAdbutler
,
placeAd
}
from
'
ui/shared/ad/adbutlerScript
'
;
export
function
ad
():
CspDev
.
DirectiveDescriptor
{
if
(
!
isSelfHosted
())
{
...
...
@@ -25,7 +25,6 @@ export function ad(): CspDev.DirectiveDescriptor {
'
servedbyadbutler.com
'
,
`'sha256-
${
Base64
.
stringify
(
sha256
(
connectAdbutler
))
}
'`
,
`'sha256-
${
Base64
.
stringify
(
sha256
(
placeAd
))
}
'`
,
`'sha256-
${
Base64
.
stringify
(
sha256
(
placeAdSPA
))
}
'`
,
'
*.slise.xyz
'
,
],
'
img-src
'
:
[
...
...
ui/shared/ad/AdbutlerBanner.tsx
View file @
9cdc8610
/* eslint-disable max-len */
import
{
Flex
,
chakra
}
from
'
@chakra-ui/react
'
;
import
{
useRouter
}
from
'
next/navigation
'
;
import
Script
from
'
next/script
'
;
import
React
from
'
react
'
;
import
appConfig
from
'
configs/app/config
'
;
import
useIsMobile
from
'
lib/hooks/useIsMobile
'
;
import
isBrowser
from
'
lib/isBrowser
'
;
import
{
connectAdbutler
,
placeAd
,
placeAdSPA
}
from
'
ui/shared/ad/adbutlerScript
'
;
import
{
connectAdbutler
,
placeAd
,
ADBUTLER_ACCOUNT
}
from
'
ui/shared/ad/adbutlerScript
'
;
const
AdbutlerBanner
=
({
className
}:
{
className
?:
string
})
=>
{
const
router
=
useRouter
();
const
isMobile
=
useIsMobile
();
React
.
useEffect
(()
=>
{
if
(
isBrowser
())
{
eval
(
placeAdSPA
);
if
(
isBrowser
()
&&
window
.
AdButler
)
{
const
abkw
=
window
.
abkw
||
''
;
if
(
!
window
.
AdButler
.
ads
)
{
window
.
AdButler
.
ads
=
[];
}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore:
let
plc
=
window
[
`plc
${
appConfig
.
ad
.
adButlerConfigMobile
?.
id
}
`] || 0;
const config = isMobile ? appConfig.ad.adButlerConfigMobile : appConfig.ad.adButlerConfigDesktop;
const banner = document.getElementById('ad-banner');
if (banner) {
banner.innerHTML = '<' + 'div id="placement_' + config?.id + '_' + plc + '"></' + 'div>';
}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore:
window.AdButler.ads.push({ handler: function(opt) {
window.AdButler.register(ADBUTLER_ACCOUNT, config?.id, [ config?.width, config?.height ], `
placement_$
{
config
?.
id
}
_
` + opt.place, opt);
}, opt: { place: plc++, keywords: abkw, domain: 'servedbyadbutler.com', click: 'CLICK_MACRO_PLACEHOLDER' } });
}
},
[
router
]);
}, [ router
, isMobile
]);
return (
<Flex className={ className } id="adBanner" h={{ base: '100px', lg: '90px' }}>
...
...
ui/shared/ad/adbutlerScript.ts
View file @
9cdc8610
/* eslint-disable max-len */
import
appConfig
from
'
configs/app/config
'
;
const
ADBUTLER_ACCOUNT
=
182226
;
export
const
ADBUTLER_ACCOUNT
=
182226
;
export
const
connectAdbutler
=
`if (!window.AdButler){(function(){var s = document.createElement("script"); s.async = true; s.type = "text/javascript";s.src = 'https://servedbyadbutler.com/app.js';var n = document.getElementsByTagName("script")[0]; n.parentNode.insertBefore(s, n);}());}`
;
...
...
@@ -19,18 +19,3 @@ var AdButler = AdButler || {}; AdButler.ads = AdButler.ads || [];
AdButler
.
ads
.
push
({
handler
:
function
(
opt
){
AdButler
.
register
(
$
{
ADBUTLER_ACCOUNT
},
$
{
appConfig
.
ad
.
adButlerConfigDesktop
?.
id
},
[
$
{
appConfig
.
ad
.
adButlerConfigDesktop
?.
width
},
$
{
appConfig
.
ad
.
adButlerConfigDesktop
?.
height
}],
'
placement_${ appConfig.ad.adButlerConfigDesktop?.id }_
'
+
opt
.
place
,
opt
);
},
opt
:
{
place
:
plc$
{
appConfig
.
ad
.
adButlerConfigDesktop
?.
id
}
++
,
keywords
:
abkw
,
domain
:
'
servedbyadbutler.com
'
,
click
:
'
CLICK_MACRO_PLACEHOLDER
'
}});
}
`;
export const placeAdSPA = `
if
(
!
window
.
AdButler
.
ads
)
{
window
.
AdButler
.
ads
=
[];}
var
abkw
=
window
.
abkw
||
''
;
const
isMobile
=
window
.
matchMedia
(
"
only screen and (max-width: 1000px)
"
).
matches
;
if
(
isMobile
)
{
var
plc$
{
appConfig
.
ad
.
adButlerConfigMobile
?.
id
}
=
window
.
plc$
{
appConfig
.
ad
.
adButlerConfigMobile
?.
id
}
||
0
;
document
.
getElementById
(
'
ad-banner
'
).
innerHTML
=
'
<
'
+
'
div id="placement_${ appConfig.ad.adButlerConfigMobile?.id }_
'
+
plc$
{
appConfig
.
ad
.
adButlerConfigMobile
?.
id
}
+
'
"></
'
+
'
div>
'
;
window
.
AdButler
.
ads
.
push
({
handler
:
function
(
opt
){
AdButler
.
register
(
$
{
ADBUTLER_ACCOUNT
},
$
{
appConfig
.
ad
.
adButlerConfigMobile
?.
id
},
[
$
{
appConfig
.
ad
.
adButlerConfigMobile
?.
width
},
$
{
appConfig
.
ad
.
adButlerConfigMobile
?.
height
}],
'
placement_${ appConfig.ad.adButlerConfigMobile?.id }_
'
+
opt
.
place
,
opt
);
},
opt
:
{
place
:
plc$
{
appConfig
.
ad
.
adButlerConfigMobile
?.
id
}
++
,
keywords
:
abkw
,
domain
:
'
servedbyadbutler.com
'
,
click
:
'
CLICK_MACRO_PLACEHOLDER
'
}});
}
else
{
var
plc$
{
appConfig
.
ad
.
adButlerConfigDesktop
?.
id
}
=
window
.
plc$
{
appConfig
.
ad
.
adButlerConfigDesktop
?.
id
}
||
0
;
document
.
getElementById
(
'
ad-banner
'
).
innerHTML
=
'
<
'
+
'
div id="placement_${ appConfig.ad.adButlerConfigDesktop?.id }_
'
+
plc$
{
appConfig
.
ad
.
adButlerConfigDesktop
?.
id
}
+
'
"></
'
+
'
div>
'
;
window
.
AdButler
.
ads
.
push
({
handler
:
function
(
opt
){
window
.
AdButler
.
register
(
$
{
ADBUTLER_ACCOUNT
},
$
{
appConfig
.
ad
.
adButlerConfigDesktop
?.
id
},
[
$
{
appConfig
.
ad
.
adButlerConfigDesktop
?.
width
},
$
{
appConfig
.
ad
.
adButlerConfigDesktop
?.
height
}],
'
placement_${ appConfig.ad.adButlerConfigDesktop?.id }_
'
+
opt
.
place
,
opt
);
},
opt
:
{
place
:
plc$
{
appConfig
.
ad
.
adButlerConfigDesktop
?.
id
}
++
,
keywords
:
abkw
,
domain
:
'
servedbyadbutler.com
'
,
click
:
'
CLICK_MACRO_PLACEHOLDER
'
}});
}
`;
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