forked from Slope-Game/Slope-Game.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
adin.js
128 lines (117 loc) · 5.77 KB
/
adin.js
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
var r = document.createElement("script");
r.setAttribute("src", "//api.adinplay.com/libs/aiptag/pub/TTS/slope-game.github.io/tag.min.js"), r.setAttribute("type", "text/javascript"), r.setAttribute("crossOrigin", "anonymous", "async"), r.onload = function (){
//<div id="overlay"></div>
let stylediv = document.createElement('style');
stylediv.innerHTML = `#overlay {
position: fixed; /* Sit on top of the page content */
width: 100%; /* Full width (cover the whole page) */
height: 100%; /* Full height (cover the whole page) */
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgb(12, 72, 108);
z-index: 1000; /* Specify a stack order in case you're using a different order for other elements */
cursor: pointer; /* Add a pointer on hover */
}
#overlay .btnPlay{
margin: 0;
position: absolute;
top: 50%;
left: 50%;
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
padding: 10px 22px;
border-radius: 5px;
border: 3px solid white;
background: linear-gradient(0deg, #dddddd, #ffffff);
color: #222;
text-transform: uppercase;
text-shadow: 0 0 1px #fff;
font-family: Helvetica, Arial, sans-serif;
font-weight: bold;
font-size: 18px;
cursor: pointer;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
width: 150px;}
`;
document.querySelector("head").appendChild(stylediv);
let adsdiv = document.createElement('div');
// adsdiv.id = "overlay";
adsdiv.id = "preroll";
document.querySelector("body").appendChild(adsdiv);
let headTag = document.getElementsByTagName('head')[0];
let scriptAds = `<script>
window.aiptag = window.aiptag || {cmd: []};
aiptag.cmd.display = aiptag.cmd.display || [];
aiptag.cmd.player = aiptag.cmd.player || [];
function showPreroll(){
document.querySelector('#overlay').style.display = "none";
if (typeof aiptag.adplayer !== 'undefined') {
aiptag.cmd.player.push(function() { aiptag.adplayer.startPreRoll(); });
} else {
//Adlib didnt load this could be due to an adblocker, timeout etc.
//Please add your script here that starts the content, this usually is the same script as added in AIP_COMPLETE.
alert("Ad Could not be loaded, load your content here");
}
}
</script>`;
// document.querySelector("body").appendChild(scriptAds);
headTag.innerHTML += (scriptAds);
let overlay = document.createElement('div');
overlay.id = "overlay";
overlay.innerHTML = `<button class="btnPlay">Play</button>`;
document.querySelector("body").appendChild(overlay);
let gameBtn = document.querySelector('.btnPlay');
gameBtn.addEventListener("click", function(event){
event.preventDefault();
document.querySelector('#overlay').style.display = "none";
//CMP tool settings
aiptag.cmp = {
show: true,
position: "centered", //centered, bottom
button: true,
buttonText: "Privacy settings",
buttonPosition: "bottom-left" //bottom-left, bottom-right, top-left, top-right
}
aiptag.cmd.player.push(function() {
aiptag.adplayer = new aipPlayer({
AIP_REWARDEDNOTGRANTED: function (state) {
//This event is fired when a rewarded ad is:
//timed out, empty, unsupported or closed by the user.
//don't grand the reward here
alert("Rewarded ad state: " + state); //state can be: timeout, empty, unsupported or closed.
},
AIP_REWARDEDGRANTED: function () {
// This event is called whenever a reward is granted for a rewarded ad
if (event && "isTrusted" in event && event.isTrusted) {
alert("Reward Granted");
} else {
alert("Something went wrong don't grant the reward");
}
},
AD_WIDTH: 960,
AD_HEIGHT: 540,
AD_DISPLAY: 'default', //default, fullscreen, center, fill
LOADING_TEXT: 'loading advertisement',
PREROLL_ELEM: function(){return document.getElementById('preroll')},
AIP_COMPLETE: function (state) {
/*******************
***** WARNING *****
*******************
Please do not remove the PREROLL_ELEM
from the page, it will be hidden automaticly.
*/
alert("Preroll Ad Completed: " + state);
}
});
});
if (typeof aiptag.adplayer !== 'undefined') {
aiptag.cmd.player.push(function() { aiptag.adplayer.startPreRoll(); });
} else {
//Adlib didnt load this could be due to an adblocker, timeout etc.
//Please add your script here that starts the content, this usually is the same script as added in AIP_COMPLETE.
alert("Ad Could not be loaded, load your content here");
}
});
},document.head.appendChild(r);