More ads test

This commit is contained in:
Jai A
2024-11-03 20:35:04 -07:00
parent 7d614f7ac5
commit db145cd8ad
2 changed files with 118 additions and 177 deletions

View File

@@ -1,140 +1,111 @@
<!doctype html> <!doctype html>
<html> <html>
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Modrinth App Ad</title> <title>Modrinth App Ad</title>
<script src="https://cadmus.script.ac/d14pdm1b7fi5kh/script.js"></script> <script src="https://cadmus.script.ac/d14pdm1b7fi5kh/script.js"></script>
<script <script
src="https://dn0qt3r0xannq.cloudfront.net/modrinth-7JfmkEIXEp/modrinth-longform/prebid-load.js" src="https://dn0qt3r0xannq.cloudfront.net/modrinth-7JfmkEIXEp/modrinth-longform/prebid-load.js"
async async
></script> ></script>
<link rel="preload" href="https://www.googletagservices.com/tag/js/gpt.js" as="script" /> <link rel="preload" href="https://www.googletagservices.com/tag/js/gpt.js" as="script" />
<style> <style>
* { * {
margin: 0; margin: 0;
padding: 0; padding: 0;
overflow: hidden; overflow: hidden;
cursor: pointer; cursor: pointer;
}
.ads-container {
width: 100vw;
height: 100vh;
overflow: hidden;
position: relative;
}
#plus-link {
width: 100vw;
height: 100vh;
position: absolute;
top: 0;
left: 0;
z-index: 0;
}
#modrinth-rail-1 {
border-radius: 1rem;
position: absolute;
left: 0;
top: 0;
z-index: 2;
}
</style>
</head>
<body>
<div class="ads-container">
<div id="plus-link"></div>
<div id="modrinth-rail-1"></div>
</div>
<script>
function getCookie(name) {
function escape(s) {
return s.replace(/([.*+?\^$(){}|\[\]\/\\])/g, "\\$1");
}
const match = document.cookie.match(RegExp("(?:^|;\\s*)" + escape(name) + "=([^;]*)"));
return match ? match[1] : null;
}
function initAds(personalized) {
window.tude = window.tude || { cmd: [] };
window.Raven = window.Raven || { cmd: [] };
window.Raven.cmd.push(({ config }) => {
config.setCustom({
param1: "app",
});
});
tude.cmd.push(function () {
tude.refreshAdsViaDivMappings([
{
divId: "modrinth-rail-1",
baseDivId: "pb-slot-square-2",
targeting: {
location: "app",
},
},
]);
tude.setPrivacySettings({
personalizedAds: personalized ?? true,
});
});
}
try {
if (window.__TAURI_INTERNALS__) {
window.__TAURI_INTERNALS__
.invoke("plugin:ads|get_ads_personalization", {})
.then(initAds)
.catch(() => initAds(true));
} else {
initAds(true);
}
} catch (err) {
initAds(true);
console.error(err);
}
window.addEventListener(
"message",
(event) => {
if (event.data.modrinthAdClick && window.__TAURI_INTERNALS__) {
window.__TAURI_INTERNALS__.invoke("plugin:ads|record_ads_click", {});
} }
if (event.data.modrinthOpenUrl && window.__TAURI_INTERNALS__) { .ads-container {
window.__TAURI_INTERNALS__.invoke("plugin:ads|open_link", { width: 100vw;
path: event.data.modrinthOpenUrl, height: 100vh;
origin: event.origin, overflow: hidden;
position: relative;
}
#plus-link {
width: 100vw;
height: 100vh;
position: absolute;
top: 0;
left: 0;
z-index: 0;
}
#modrinth-rail-1 {
border-radius: 1rem;
position: absolute;
left: 0;
top: 0;
z-index: 2;
}
</style>
</head>
<body>
<div class="ads-container">
<div id="plus-link"></div>
<div id="modrinth-rail-1"></div>
</div>
<script>
window.tude = window.tude || { cmd: [] };
window.Raven = window.Raven || { cmd: [] };
window.Raven.cmd.push(({ config }) => {
config.setCustom({
param1: "app",
}); });
}
},
false,
);
window.addEventListener("mousewheel", (event) => {
if (window.__TAURI_INTERNALS__) {
window.__TAURI_INTERNALS__.invoke("plugin:ads|scroll_ads_window", {
scroll: event.deltaY,
}); });
}
});
document.addEventListener("contextmenu", (event) => event.preventDefault()); tude.cmd.push(function () {
tude.refreshAdsViaDivMappings([
{
divId: "modrinth-rail-1",
baseDivId: "pb-slot-square-2",
targeting: {
location: "app",
},
},
]);
});
const plusLink = document.getElementById("plus-link"); window.addEventListener(
plusLink.addEventListener("click", function () { "message",
window.__TAURI_INTERNALS__.invoke("plugin:ads|record_ads_click", {}); (event) => {
window.__TAURI_INTERNALS__.invoke("plugin:ads|open_link", { if (event.data.modrinthAdClick && window.__TAURI_INTERNALS__) {
path: "https://modrinth.com/plus", window.__TAURI_INTERNALS__.invoke("plugin:ads|record_ads_click", {});
origin: "https://modrinth.com", }
});
}); if (event.data.modrinthOpenUrl && window.__TAURI_INTERNALS__) {
</script> window.__TAURI_INTERNALS__.invoke("plugin:ads|open_link", {
</body> path: event.data.modrinthOpenUrl,
origin: event.origin,
});
}
},
false,
);
window.addEventListener("mousewheel", (event) => {
if (window.__TAURI_INTERNALS__) {
window.__TAURI_INTERNALS__.invoke("plugin:ads|scroll_ads_window", {
scroll: event.deltaY,
});
}
});
document.addEventListener("contextmenu", (event) => event.preventDefault());
const plusLink = document.getElementById("plus-link");
plusLink.addEventListener("click", function () {
window.__TAURI_INTERNALS__.invoke("plugin:ads|record_ads_click", {});
window.__TAURI_INTERNALS__.invoke("plugin:ads|open_link", {
path: "https://modrinth.com/plus",
origin: "https://modrinth.com",
});
});
</script>
</body>
</html> </html>

View File

@@ -50,57 +50,27 @@
<div id="modrinth-rail-1"></div> <div id="modrinth-rail-1"></div>
</div> </div>
<script> <script>
function getCookie(name) { window.tude = window.tude || { cmd: [] };
function escape(s) {
return s.replace(/([.*+?\^$(){}|\[\]\/\\])/g, "\\$1");
}
const match = document.cookie.match(RegExp("(?:^|;\\s*)" + escape(name) + "=([^;]*)")); window.Raven = window.Raven || { cmd: [] };
return match ? match[1] : null;
}
function initAds(personalized) { window.Raven.cmd.push(({ config }) => {
window.tude = window.tude || { cmd: [] }; config.setCustom({
param1: "app",
window.Raven = window.Raven || { cmd: [] };
window.Raven.cmd.push(({ config }) => {
config.setCustom({
param1: "app",
});
}); });
});
tude.cmd.push(function () { tude.cmd.push(function () {
tude.refreshAdsViaDivMappings([ tude.refreshAdsViaDivMappings([
{ {
divId: "modrinth-rail-1", divId: "modrinth-rail-1",
baseDivId: "pb-slot-square-2", baseDivId: "pb-slot-square-2",
targeting: { targeting: {
location: "app", location: "app",
},
}, },
]); },
]);
tude.setPrivacySettings({ });
personalizedAds: personalized ?? true,
});
});
}
try {
if (window.__TAURI_INTERNALS__) {
window.__TAURI_INTERNALS__
.invoke("plugin:ads|get_ads_personalization", {})
.then(initAds)
.catch(() => initAds(true));
} else {
initAds(true);
}
} catch (err) {
initAds(true);
console.error(err);
}
window.addEventListener( window.addEventListener(
"message", "message",
(event) => { (event) => {