Add popunder ads based on file size
This commit is contained in:
@@ -113,7 +113,20 @@
|
||||
</script>
|
||||
{{ end }}
|
||||
|
||||
{{ if eq .Other.AdUnderType 1}}
|
||||
{{ if eq .Other.AdPopupType 1 }}
|
||||
<script data-cfasync="false" type="text/javascript" async src="//depirsmandk5.com/t/9/fret/meow4/1846775/brt.js"></script>
|
||||
{{ else if eq .Other.AdPopupType 2 }}
|
||||
<script>
|
||||
window.addEventListener("load", () => {
|
||||
(function(s,u,z,p){
|
||||
s.src=u,s.setAttribute('data-zone',z),p.appendChild(s);
|
||||
})(
|
||||
document.createElement('script'),
|
||||
'https://iclickcdn.com/tag.min.js',
|
||||
3750089,
|
||||
document.body||document.documentElement,
|
||||
)
|
||||
})
|
||||
</script>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
@@ -143,13 +143,13 @@
|
||||
{{ if and .Other.FileAdsEnabled .Other.UserAdsEnabled }}
|
||||
{{ template "banner_ads" . }}
|
||||
{{ else if not .Other.UserAdsEnabled }}
|
||||
<div style="text-align: center; line-height: 1.3em; font-size: 13px;">
|
||||
Thank you for supporting pixeldrain!
|
||||
</div>
|
||||
<div style="text-align: center; line-height: 1.3em; font-size: 13px;">
|
||||
Thank you for supporting pixeldrain!
|
||||
</div>
|
||||
{{ else if not .Other.FileAdsEnabled }}
|
||||
<div style="text-align: center; line-height: 1.3em; font-size: 13px;">
|
||||
The uploader of this file disabled advertisements. You can do the same for <a href="/#pro">only €2 per month</a>!
|
||||
</div>
|
||||
<div style="text-align: center; line-height: 1.3em; font-size: 13px;">
|
||||
The uploader of this file disabled advertisements. You can do the same for <a href="/#pro">only €2 per month</a>!
|
||||
</div>
|
||||
{{ end }}
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -30,7 +30,7 @@ type viewerData struct {
|
||||
ViewToken string
|
||||
AdBannerType int
|
||||
AdFloaterType int
|
||||
AdUnderType int
|
||||
AdPopupType int
|
||||
FileAdsEnabled bool
|
||||
UserAdsEnabled bool
|
||||
Embedded bool
|
||||
@@ -38,6 +38,10 @@ type viewerData struct {
|
||||
}
|
||||
|
||||
func (vd *viewerData) adType(files []pixelapi.ListFile) {
|
||||
if len(files) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
var avgSize int64
|
||||
for _, v := range files {
|
||||
avgSize += v.Size
|
||||
@@ -67,31 +71,31 @@ func (vd *viewerData) adType(files []pixelapi.ListFile) {
|
||||
adMavenFloat = 3
|
||||
|
||||
// Popunders
|
||||
clickAduPopunder = 1
|
||||
clickAduPopup = 1
|
||||
propellerPopup = 2
|
||||
)
|
||||
|
||||
// Intn returns a number up to n, but never n itself. So to get a random 0
|
||||
// or 1 we need to give it n=2. We can use this function to make other
|
||||
// splits like 1/3 1/4, etc
|
||||
switch i := rand.Intn(3); i {
|
||||
case 0: // 33%
|
||||
switch i := rand.Intn(4); i {
|
||||
case 0: // 25%
|
||||
vd.AdBannerType = clickAduBanner
|
||||
case 1: // 33%
|
||||
case 1: // 25%
|
||||
vd.AdBannerType = brave
|
||||
case 2: // 33%
|
||||
case 2, 3: // 50%
|
||||
vd.AdBannerType = aAds
|
||||
default:
|
||||
panic(fmt.Errorf("random number generator returned unrecognised number: %d", i))
|
||||
}
|
||||
|
||||
// If the file is larger than 10 MB we enable popups
|
||||
// If the file is larger than 10 MB we enable floating popups
|
||||
if avgSize > 10e6 {
|
||||
vd.AdFloaterType = propellerFloat
|
||||
}
|
||||
|
||||
// If the file is larger than 250 MB we enable popunders
|
||||
if avgSize > 250e6 {
|
||||
vd.AdUnderType = clickAduPopunder
|
||||
vd.AdPopupType = clickAduPopup
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -181,6 +181,7 @@ func New(
|
||||
|
||||
// Admin settings
|
||||
{GET, "admin" /* */, wc.serveTemplate("admin", handlerOpts{Auth: true})},
|
||||
{GET, "admin/status" /* */, wc.serveTemplate("admin", handlerOpts{Auth: true})},
|
||||
{GET, "admin/abuse_reporters" /**/, wc.serveTemplate("admin", handlerOpts{Auth: true})},
|
||||
{GET, "admin/abuse_reports" /* */, wc.serveTemplate("admin", handlerOpts{Auth: true})},
|
||||
{GET, "admin/ip_bans" /* */, wc.serveTemplate("admin", handlerOpts{Auth: true})},
|
||||
|
Reference in New Issue
Block a user