forked from sz-games/sz-games.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoptimizely.js
More file actions
67 lines (59 loc) · 2.02 KB
/
optimizely.js
File metadata and controls
67 lines (59 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
setTimeout(function () {
if (!document.querySelector('script[src="https://securepubads.g.doubleclick.net/tag/js/gpt.js"]')) {
const gptScript = document.createElement('script')
gptScript.async = true
gptScript.src = 'https://securepubads.g.doubleclick.net/tag/js/gpt.js'
document.head.appendChild(gptScript)
}
const gptInitScript = document.createElement('script')
gptInitScript.innerHTML = `
window.googletag = window.googletag || { cmd: [] };
var bannerSlot300x600;
googletag.cmd.push(function () {
bannerSlot300x600 = googletag
.defineSlot(
'/22921845643/SZ_Games_Right_Sidebar_300x600',
[
[160, 600],
[120, 600],
[250, 250],
[250, 360],
[300, 250],
[300, 300],
[300, 600],
],
'div-gpt-ad-1744674311666-0'
)
.addService(googletag.pubads());
googletag.pubads().enableSingleRequest();
googletag.enableServices();
setInterval(function () {
googletag.pubads().refresh([bannerSlot300x600]);
}, 30000);
});
`
document.head.appendChild(gptInitScript)
const sidebarElement = document.querySelector('.sidebar')
if (sidebarElement) {
const adSenseElement = sidebarElement.querySelector('.adsbygoogle')
const adSenseScript = adSenseElement?.nextElementSibling
if (adSenseElement) {
adSenseElement.remove()
}
if (adSenseScript && adSenseScript.tagName === 'SCRIPT') {
adSenseScript.remove()
}
const gptAdElement = document.createElement('div')
gptAdElement.id = 'div-gpt-ad-1744674311666-0'
gptAdElement.style.minWidth = '300px'
gptAdElement.style.minHeight = '600px'
const gptScript = document.createElement('script')
gptScript.innerHTML = `
googletag.cmd.push(function () {
googletag.display(bannerSlot300x600);
});
`
gptAdElement.appendChild(gptScript)
sidebarElement.insertBefore(gptAdElement, sidebarElement.firstChild)
}
}, 30000)