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

@@ -50,57 +50,27 @@
<div id="modrinth-rail-1"></div>
</div>
<script>
function getCookie(name) {
function escape(s) {
return s.replace(/([.*+?\^$(){}|\[\]\/\\])/g, "\\$1");
}
window.tude = window.tude || { cmd: [] };
const match = document.cookie.match(RegExp("(?:^|;\\s*)" + escape(name) + "=([^;]*)"));
return match ? match[1] : null;
}
window.Raven = window.Raven || { cmd: [] };
function initAds(personalized) {
window.tude = window.tude || { cmd: [] };
window.Raven = window.Raven || { cmd: [] };
window.Raven.cmd.push(({ config }) => {
config.setCustom({
param1: "app",
});
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.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) => {