Skip to content

Commit 2ac1248

Browse files
committed
move ads only on homepage, + now they load (removed service worker- unneed anyways bc new cdn)
1 parent d21f2b8 commit 2ac1248

File tree

3 files changed

+73
-59
lines changed

3 files changed

+73
-59
lines changed

src/app.html

Lines changed: 46 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -22,46 +22,57 @@
2222

2323

2424
<script>
25-
console.log('[APP][head] Loaded app');
26-
if ("serviceWorker" in navigator) {
27-
console.log(`[APP][head][check-sw] Service worker supported, registering...`);
28-
navigator.serviceWorker.register("%sveltekit.assets%/sw.js");
25+
// What if we didn't use a service worker at all?
26+
// console.log('[APP][head] Loaded app');
27+
// if ("serviceWorker" in navigator) {
28+
// console.log(`[APP][head][check-sw] Service worker supported, registering...`);
29+
// navigator.serviceWorker.register("%sveltekit.assets%/sw.js");
2930

30-
navigator.serviceWorker.ready.then((registration) => {
31-
if (registration.active) {
32-
registration.active.postMessage("Test message sent immediately after creation");
33-
}
31+
// navigator.serviceWorker.ready.then((registration) => {
32+
// if (registration.active) {
33+
// registration.active.postMessage("Test message sent immediately after creation");
34+
// }
35+
36+
// const version = localStorage.getItem("ccported-version");
37+
// fetch("%sveltekit.assets%/version.txt").then(async (res) => {
38+
// if (!res.ok) {
39+
// console.log(`[APP][head][check-version] Failed to fetch version.txt: ${res.status}`);
40+
// return;
41+
// }
42+
// const text = (await res.text()).trim();
43+
// console.log(`[APP][head][check-version] Fetched version.txt content: "${text}"`);
44+
// const newVersion = new Date(text);
45+
// const oldVersion = version ? new Date(version) : null;
46+
// console.log(`[APP][head][check-version] Fetched version: ${newVersion}, old version: ${oldVersion}`);
47+
// if (!oldVersion || newVersion > oldVersion) {
48+
// localStorage.setItem("ccported-version", newVersion.toISOString());
49+
// console.log(`[APP][head][check-version] New version available update sw, clearing cache -> reload...`);
50+
// registration.update();
51+
// registration.active?.postMessage({ action: "CLEAR_CACHE" });
52+
// }
53+
// });
54+
55+
// navigator.serviceWorker.addEventListener("message", (event) => {
56+
// if (event.data && event.data.type === "CACHE_CLEARED") {
57+
// console.log(`[APP][head][check-version][sw-message] ${event.data.status}`);
58+
// }
59+
// });
60+
// });
61+
// } else {
62+
// console.log(`[APP][head][check-sw] Service worker not supported`);
63+
// }
3464

35-
const version = localStorage.getItem("ccported-version");
36-
fetch("%sveltekit.assets%/version.txt").then(async (res) => {
37-
if (!res.ok) {
38-
console.log(`[APP][head][check-version] Failed to fetch version.txt: ${res.status}`);
39-
return;
40-
}
41-
const text = (await res.text()).trim();
42-
console.log(`[APP][head][check-version] Fetched version.txt content: "${text}"`);
43-
const newVersion = new Date(text);
44-
const oldVersion = version ? new Date(version) : null;
45-
console.log(`[APP][head][check-version] Fetched version: ${newVersion}, old version: ${oldVersion}`);
46-
if (!oldVersion || newVersion > oldVersion) {
47-
localStorage.setItem("ccported-version", newVersion.toISOString());
48-
console.log(`[APP][head][check-version] New version available update sw, clearing cache -> reload...`);
49-
registration.update();
50-
registration.active?.postMessage({ action: "CLEAR_CACHE" });
51-
}
52-
});
65+
// console.log("[APP][head] Test message");
5366

54-
navigator.serviceWorker.addEventListener("message", (event) => {
55-
if (event.data && event.data.type === "CACHE_CLEARED") {
56-
console.log(`[APP][head][check-version][sw-message] ${event.data.status}`);
57-
}
58-
});
67+
// Ensure that the service worker is not used
68+
if ("serviceWorker" in navigator) {
69+
navigator.serviceWorker.getRegistrations().then((registrations) => {
70+
for (let registration of registrations) {
71+
console.log(`[APP][head] Unregistering service worker: ${registration.scope}`);
72+
registration.unregister();
73+
}
5974
});
60-
} else {
61-
console.log(`[APP][head][check-sw] Service worker not supported`);
6275
}
63-
64-
console.log("[APP][head] Test message");
6576
</script>
6677
</head>
6778

src/routes/+layout.svelte

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,7 @@
5757
if (useGA4 && idToUse) {
5858
injectGA4(idToUse);
5959
}
60-
if ((!isAHost && !adblockEnabled) || SessionState.devMode) {
61-
console.log("[R][LAYOUT][BASE] Bad Ads enabled");
62-
injectBadAds();
63-
} else {
64-
if (isAHost && adsEnabled) {
65-
console.log("[R][LAYOUT][BASE] Good ads enabled");
66-
} else {
67-
console.log("[R][LAYOUT][BASE] No ads");
68-
}
69-
}
60+
7061
}
7162
});
7263
function injectGA4(trackingId: string) {
@@ -86,15 +77,7 @@
8677
`;
8778
document.head.appendChild(script2);
8879
}
89-
function injectBadAds() {
90-
const script = document.createElement("script");
91-
script.type = "text/javascript";
92-
script.async = true; // Dont wait up on script loading
93-
script.defer = true; // Ensure the script is executed after the document has been parsed
94-
script.src =
95-
"//pl27945770.effectivegatecpm.com/b0/88/ed/b088ed7c9240db179822a126a078b258.js";
96-
document.body.appendChild(script);
97-
}
80+
9881
</script>
9982

10083
<svelte:head>

src/routes/+page.svelte

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,15 @@
2626
adsEnabled = SessionState.adsEnabled;
2727
2828
function injectBadAds() {
29-
// src='//pl27945791.effectivegatecpm.com/f9/0f/48/f90f487cd8f3cdf83690f6955c1b5655.js'
30-
console.log("[R][LAYOUT][BASE] Bad ads not gonna inject cause this is popunder and annoying");
29+
const script = document.createElement("script");
30+
script.type = "text/javascript";
31+
script.async = true; // Dont wait up on script loading
32+
script.defer = true; // Ensure the script is executed after the document has been parsed
33+
script.src =
34+
"//pl27945770.effectivegatecpm.com/b0/88/ed/b088ed7c9240db179822a126a078b258.js";
35+
document.body.appendChild(script);
3136
}
32-
if ((!isAHost && !adblockEnabled)) {
37+
if ((!isAHost && !adblockEnabled) || SessionState.devMode) {
3338
console.log("[R][LAYOUT][BASE] Bad Ads enabled");
3439
injectBadAds();
3540
} else {
@@ -103,8 +108,23 @@
103108
> or through the discord (see link above and in the navigation).
104109
</p>
105110
<h3>CCPORTED</h3>
106-
<p>CCPorted is the greatest place to play video games. The CCPorted team parses through hundreds of games and only adds the highest-quality games to our library, ensuring a high quality gaming experience for the users. Log in to get added to leaderboards and compete with your friends. Play all kinds of games from nostalgic classics to the latest hits. Our extensive ROM library also features over 300 titles from the late 90s and early 2000s. Join the Discord to get site updates and request games. New games are added each week, and games are updated regularly to ensure a bug-free experience.</p>
107-
<p>Join the discord to request the <i>Underground Document</i>, a Google Doc with information on how to access other links for the site.</p>
111+
<p>
112+
CCPorted is the greatest place to play video games. The CCPorted
113+
team parses through hundreds of games and only adds the
114+
highest-quality games to our library, ensuring a high quality gaming
115+
experience for the users. Log in to get added to leaderboards and
116+
compete with your friends. Play all kinds of games from nostalgic
117+
classics to the latest hits. Our extensive ROM library also features
118+
over 300 titles from the late 90s and early 2000s. Join the Discord
119+
to get site updates and request games. New games are added each
120+
week, and games are updated regularly to ensure a bug-free
121+
experience.
122+
</p>
123+
<p>
124+
Join the discord to request the <i>Underground Document</i>, a
125+
Google Doc with information on how to access other links for the
126+
site.
127+
</p>
108128
<p>To view old notifications, visit the notifications page.</p>
109129
<h3>Partners</h3>
110130
<p>To become a partner, please contact us through the discord.</p>

0 commit comments

Comments
 (0)