Skip to content

Commit 524cb4b

Browse files
committed
revert: setupad
1 parent 8f4a030 commit 524cb4b

File tree

4 files changed

+13
-480
lines changed

4 files changed

+13
-480
lines changed

src/components/common/AdFeed.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useEffect, useRef } from 'react';
1+
import React, { useEffect, useRef, useState } from 'react';
22
import styled from 'styled-components';
33
import { mediaQuery } from '../../lib/styles/media';
44
import gtag from '../../lib/gtag';

src/components/common/PostCardGrid.tsx

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { mediaQuery } from '../../lib/styles/media';
66
import AdFeed from './AdFeed';
77
import { detectAnyAdblocker } from 'just-detect-adblock';
88
import useUser from '../../lib/hooks/useUser';
9-
import SetupAdFeed from './SetupAdFeed';
109

1110
export type PostCardGridProps = {
1211
posts: (PartialPost | undefined)[];
@@ -17,14 +16,8 @@ export type PostCardGridProps = {
1716

1817
function PostCardGrid({ posts, loading, forHome, forPost }: PostCardGridProps) {
1918
const [adBlocked, setAdBlocked] = useState(false);
20-
const [mode, setMode] = useState<'google' | 'setupad'>('setupad');
21-
const user = useUser();
2219

23-
useEffect(() => {
24-
if (window.innerWidth < 768) {
25-
setMode('google');
26-
}
27-
}, []);
20+
const user = useUser();
2821

2922
useEffect(() => {
3023
detectAnyAdblocker().then((detected: boolean) => {
@@ -69,11 +62,7 @@ function PostCardGrid({ posts, loading, forHome, forPost }: PostCardGridProps) {
6962
/>
7063
);
7164

72-
return mode === 'google' ? (
73-
<AdFeed key={i} index={i} forPost={forPost} />
74-
) : (
75-
<SetupAdFeed key={i} />
76-
);
65+
return <AdFeed key={i} index={i} forPost={forPost} />;
7766
})}
7867
{loading &&
7968
Array.from({ length: 8 }).map((_, i) => (

src/containers/post/HorizontalAd.tsx

Lines changed: 9 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -1,92 +1,8 @@
11
import React, { useEffect, useRef } from 'react';
22
import styled from 'styled-components';
33
import VelogResponsive from '../../components/velog/VelogResponsive';
4-
import media from '../../lib/styles/media';
5-
64
interface Props {}
75

8-
function initDesktopAd() {
9-
if (window.innerWidth < 768) return;
10-
(function () {
11-
var size = '728x90',
12-
adunit = 'velog.io_728x90_leaderboard_DFP',
13-
childNetworkId = '22738196472',
14-
xmlhttp = new XMLHttpRequest();
15-
xmlhttp.onreadystatechange = function () {
16-
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
17-
var es = document.querySelectorAll("[data-id='" + adunit + "']");
18-
var e = Array.from(es).filter(function (e) {
19-
return !e.hasAttribute('data-rendered');
20-
});
21-
if (e.length > 0) {
22-
e.forEach(function (el: any) {
23-
var iframe = el.contentWindow.document;
24-
iframe.open();
25-
iframe.write(xmlhttp.responseText);
26-
iframe.close();
27-
el.setAttribute('data-rendered', true as any);
28-
});
29-
}
30-
}
31-
};
32-
var child = childNetworkId.trim() ? ',' + childNetworkId.trim() : '';
33-
xmlhttp.open(
34-
'GET',
35-
'https://pubads.g.doubleclick.net/gampad/adx?iu=/147246189' +
36-
child +
37-
'/' +
38-
adunit +
39-
'&sz=' +
40-
encodeURI(size) +
41-
'&t=Placement_type%3Dserving&' +
42-
Date.now(),
43-
true,
44-
);
45-
xmlhttp.send();
46-
})();
47-
}
48-
49-
function initMobileAd() {
50-
(function () {
51-
if (window.innerWidth > 580) return;
52-
var size = '320x100',
53-
adunit = 'velog.io_320x100_leaderboard_DFP',
54-
childNetworkId = '22738196472',
55-
xmlhttp = new XMLHttpRequest();
56-
xmlhttp.onreadystatechange = function () {
57-
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
58-
var es = document.querySelectorAll("[data-id='" + adunit + "']");
59-
var e = Array.from(es).filter(function (e) {
60-
return !e.hasAttribute('data-rendered');
61-
});
62-
if (e.length > 0) {
63-
e.forEach(function (el: any) {
64-
var iframe = el.contentWindow.document;
65-
iframe.open();
66-
iframe.write(xmlhttp.responseText);
67-
iframe.close();
68-
el.setAttribute('data-rendered', true);
69-
});
70-
}
71-
}
72-
};
73-
var child = childNetworkId.trim() ? ',' + childNetworkId.trim() : '';
74-
xmlhttp.open(
75-
'GET',
76-
'https://pubads.g.doubleclick.net/gampad/adx?iu=/147246189' +
77-
child +
78-
'/' +
79-
adunit +
80-
'&sz=' +
81-
encodeURI(size) +
82-
'&t=Placement_type%3Dserving&' +
83-
Date.now(),
84-
true,
85-
);
86-
xmlhttp.send();
87-
})();
88-
}
89-
906
function HorizontalAd({}: Props) {
917
const ref = useRef<HTMLDivElement>(null);
928
const initializedRef = useRef(false);
@@ -97,8 +13,7 @@ function HorizontalAd({}: Props) {
9713
entries.forEach((entry) => {
9814
if (entry.isIntersecting && !initializedRef.current) {
9915
initializedRef.current = true;
100-
initDesktopAd();
101-
initMobileAd();
16+
(window.adsbygoogle = window.adsbygoogle || []).push({});
10217
console.log('initialized!');
10318
}
10419
});
@@ -118,30 +33,14 @@ function HorizontalAd({}: Props) {
11833
return (
11934
<VelogResponsive>
12035
<Wrapper ref={ref}>
121-
<Desktop>
122-
<iframe
123-
title="desktop-horizontal"
124-
data-id="velog.io_728x90_leaderboard_DFP"
125-
frameBorder="0"
126-
scrolling="no"
127-
marginHeight={0}
128-
marginWidth={0}
129-
width="1"
130-
height="1"
131-
></iframe>
132-
</Desktop>
133-
<Mobile>
134-
<iframe
135-
title="mobile-horizontal"
136-
data-id="velog.io_320x100_leaderboard_DFP"
137-
frameBorder="0"
138-
scrolling="no"
139-
marginHeight={0}
140-
marginWidth={0}
141-
width="1"
142-
height="1"
143-
></iframe>
144-
</Mobile>
36+
<ins
37+
className="adsbygoogle"
38+
style={{ display: 'block', maxHeight: 400, width: '100%' }}
39+
data-ad-client="ca-pub-5574866530496701"
40+
data-ad-slot="8809887603"
41+
data-ad-format="auto"
42+
data-full-width-responsive="true"
43+
/>
14544
</Wrapper>
14645
</VelogResponsive>
14746
);
@@ -153,24 +52,4 @@ const Wrapper = styled.div`
15352
margin-bottom: 1.5rem;
15453
`;
15554

156-
const Desktop = styled.div`
157-
display: flex;
158-
justify-content: center;
159-
iframe {
160-
width: 728px;
161-
height: 90px;
162-
}
163-
${media.small} {
164-
display: none;
165-
}
166-
`;
167-
168-
const Mobile = styled.div`
169-
display: none;
170-
justify-content: center;
171-
${media.custom(580)} {
172-
display: flex;
173-
}
174-
`;
175-
17655
export default HorizontalAd;

0 commit comments

Comments
 (0)