From 77d33c7a7a5303b289bfa6d6a02051b6b71e1a8b Mon Sep 17 00:00:00 2001 From: Andrea Vos Date: Sat, 19 Apr 2025 15:04:06 +0200 Subject: [PATCH 01/20] geniee test --- layouts/default.vue | 17 +++++++++++++++-- locale/en/translations.suml | 6 ++++++ pages/privacy.vue | 8 ++++---- plugins/globals.ts | 1 + 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/layouts/default.vue b/layouts/default.vue index b232e3ea5..b11e0f2e6 100644 --- a/layouts/default.vue +++ b/layouts/default.vue @@ -17,6 +17,10 @@ const TESTER_PASSWORD_HASH = '82feeb96d60170e714df8fb062301e90'; declare global { interface Window { dataLayer: unknown[]; + gnshbrequest: { + cmd: any[], + forceInternalRequest: () => void, + }; } } @@ -95,9 +99,18 @@ const loadAds = async (): Promise => { } try { + window.gnshbrequest = window.gnshbrequest || {cmd:[]}; + window.gnshbrequest.cmd.push(function(){ + window.gnshbrequest.forceInternalRequest(); + }); + await loadScript( - 'publift', - 'https://cdn.fuseplatform.net/publift/tags/2/3329/fuse.js', + 'gpt', + 'https://securepubads.g.doubleclick.net/tag/js/gpt.js', + ); + await loadScript( + 'geniee', + 'https://cpt.geniee.jp/hb/v1/222988/2860/wrapper.min.js', ); } catch (error) { if (error instanceof LoadScriptError) { diff --git a/locale/en/translations.suml b/locale/en/translations.suml index bb1182e8e..790c3d754 100644 --- a/locale/en/translations.suml +++ b/locale/en/translations.suml @@ -1384,6 +1384,12 @@ privacy: It uses cookies that enable it to serve ads to our users based on previous visits to our site and other sites. You may opt out of personalised advertising by not giving your consent when prompted by clicking this link: + geniee: > + In order to fund the project we show ads using third party vendors, including Geniee, + whose privacy policy is available {https://en.geniee.co.jp/privacy/=here}. + It uses cookies that enable it to serve ads to our users based on previous visits to our site and other sites. + You may opt out of personalised advertising by not giving your consent when prompted + by clicking this link: logsBackups: > Logs and backups are stored for no longer than 18 months. gdpr: > diff --git a/pages/privacy.vue b/pages/privacy.vue index 9c248aa15..a5e90a5d1 100644 --- a/pages/privacy.vue +++ b/pages/privacy.vue @@ -29,8 +29,8 @@ const config = useConfig();

terms.lastUpdatequotation.colon - 2024-03-03 - (Sentry) + 2025-04-20 + (Geniee)

@@ -52,8 +52,8 @@ const config = useConfig();

privacy.content.turnstile

privacy.content.sentry

- privacy.content.publift - + privacy.content.geniee + privacy.content.gtm

privacy.content.logsBackups

diff --git a/plugins/globals.ts b/plugins/globals.ts index e5876ab2b..23beb2695 100644 --- a/plugins/globals.ts +++ b/plugins/globals.ts @@ -78,6 +78,7 @@ export default defineNuxtPlugin((nuxtApp) => { return new Promise((resolve, reject) => { const script = document.createElement('script'); script.setAttribute('src', src); + script.async = true; if (nonce) { script.setAttribute('nonce', nonce); } From fa4e2a3676c1e776435ceb69e42ed50d3ac6f24a Mon Sep 17 00:00:00 2001 From: Andrea Vos Date: Sat, 19 Apr 2025 15:18:22 +0200 Subject: [PATCH 02/20] (lint) --- layouts/default.vue | 8 ++++---- pages/privacy.vue | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/layouts/default.vue b/layouts/default.vue index b11e0f2e6..556989ecb 100644 --- a/layouts/default.vue +++ b/layouts/default.vue @@ -18,8 +18,8 @@ declare global { interface Window { dataLayer: unknown[]; gnshbrequest: { - cmd: any[], - forceInternalRequest: () => void, + cmd: any[]; + forceInternalRequest: () => void; }; } } @@ -99,8 +99,8 @@ const loadAds = async (): Promise => { } try { - window.gnshbrequest = window.gnshbrequest || {cmd:[]}; - window.gnshbrequest.cmd.push(function(){ + window.gnshbrequest = window.gnshbrequest || { cmd: [] }; + window.gnshbrequest.cmd.push(function () { window.gnshbrequest.forceInternalRequest(); }); diff --git a/pages/privacy.vue b/pages/privacy.vue index a5e90a5d1..14af7de15 100644 --- a/pages/privacy.vue +++ b/pages/privacy.vue @@ -53,7 +53,7 @@ const config = useConfig();

privacy.content.sentry

privacy.content.geniee - + privacy.content.gtm

privacy.content.logsBackups

From 4a2bbfee81337ded490ef5231e20a2b0eb5fc237 Mon Sep 17 00:00:00 2001 From: Andrea Vos Date: Sat, 19 Apr 2025 16:47:37 +0200 Subject: [PATCH 03/20] geniee test --- layouts/default.vue | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/layouts/default.vue b/layouts/default.vue index 556989ecb..0e017171d 100644 --- a/layouts/default.vue +++ b/layouts/default.vue @@ -107,10 +107,14 @@ const loadAds = async (): Promise => { await loadScript( 'gpt', 'https://securepubads.g.doubleclick.net/tag/js/gpt.js', + undefined, + 'head', ); await loadScript( 'geniee', 'https://cpt.geniee.jp/hb/v1/222988/2860/wrapper.min.js', + undefined, + 'head', ); } catch (error) { if (error instanceof LoadScriptError) { From 021973d6e53847b538ab1831d0b54fc1b261d8ff Mon Sep 17 00:00:00 2001 From: Andrea Vos Date: Wed, 23 Apr 2025 08:38:28 +0200 Subject: [PATCH 04/20] geniee split test --- layouts/default.vue | 51 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 39 insertions(+), 12 deletions(-) diff --git a/layouts/default.vue b/layouts/default.vue index 0e017171d..2cde0da76 100644 --- a/layouts/default.vue +++ b/layouts/default.vue @@ -21,6 +21,9 @@ declare global { cmd: any[]; forceInternalRequest: () => void; }; + adpushup: { + que: any[]; + }; } } @@ -104,18 +107,42 @@ const loadAds = async (): Promise => { window.gnshbrequest.forceInternalRequest(); }); - await loadScript( - 'gpt', - 'https://securepubads.g.doubleclick.net/tag/js/gpt.js', - undefined, - 'head', - ); - await loadScript( - 'geniee', - 'https://cpt.geniee.jp/hb/v1/222988/2860/wrapper.min.js', - undefined, - 'head', - ); + const splitProbability = Math.floor(Math.random() * 100); + if (splitProbability < 50) { + const s1 = document.createElement("script"); + s1.async = true; + const element = + document.getElementsByTagName("head")[0] || + document.getElementsByTagName("body")[0]; + s1.src = "https://cdn.fuseplatform.net/publift/tags/2/3329/fuse.js"; + element.appendChild(s1); + } else { + (function (w, d) { + const s = d.createElement("script"); + s.src = "//cdn.adpushup.com/47589/adpushup.js"; + s.crossOrigin = "anonymous"; + s.type = "text/javascript"; + s.async = true; + ( + d.getElementsByTagName("head")[0] || + d.getElementsByTagName("body")[0] + ).appendChild(s); + w.adpushup = w.adpushup || { que: [] }; + })(window, document); + } + + // await loadScript( + // 'gpt', + // 'https://securepubads.g.doubleclick.net/tag/js/gpt.js', + // undefined, + // 'head', + // ); + // await loadScript( + // 'geniee', + // 'https://cpt.geniee.jp/hb/v1/222988/2860/wrapper.min.js', + // undefined, + // 'head', + // ); } catch (error) { if (error instanceof LoadScriptError) { return; From 868840f5cb442871f3a729eb82b4c263cc192d46 Mon Sep 17 00:00:00 2001 From: Andrea Vos Date: Sun, 27 Apr 2025 17:36:36 +0200 Subject: [PATCH 05/20] geniee split test --- components/AdsProviderSwitch.vue | 30 ++++++++++ layouts/default.vue | 98 +++++++++++++++++--------------- pages/index-locale.vue | 3 + pages/privacy.vue | 3 +- 4 files changed, 88 insertions(+), 46 deletions(-) create mode 100644 components/AdsProviderSwitch.vue diff --git a/components/AdsProviderSwitch.vue b/components/AdsProviderSwitch.vue new file mode 100644 index 000000000..8e165bffa --- /dev/null +++ b/components/AdsProviderSwitch.vue @@ -0,0 +1,30 @@ + + + \ No newline at end of file diff --git a/layouts/default.vue b/layouts/default.vue index 2cde0da76..d93da6230 100644 --- a/layouts/default.vue +++ b/layouts/default.vue @@ -2,6 +2,7 @@ import sorter from 'avris-sorter'; import md5 from 'js-md5'; import { useCookie } from 'nuxt/app'; +import { useStorage } from '@vueuse/core' import useConfig from '~/composables/useConfig.ts'; import useDark from '~/composables/useDark.ts'; @@ -86,63 +87,70 @@ const confirmAge = async (): Promise => { localStorage.setItem('ageConfirmed', '1'); }; +const provider = useStorage('ads-provider', null); + +if (provider.value === null) { + provider.value = Math.random() < 0.5 ? 'publift' : 'geniee'; +} + const adsEnabled = computed((): boolean => { - if (isGranted()) { - const adsVisible = parseInt(localStorage.getItem('adsVisible') || '0') === 1; - if (!adsVisible) { - return false; - } + if (isGranted() && provider.value === 'none') { + return false; } return !!config.ads?.enabled && import.meta.env?.APP_ENV === 'production'; }); + +const loadAdsForProvider = { + 'publift': async (): Promise => { + await loadScript( + 'publift', + 'https://cdn.fuseplatform.net/publift/tags/2/3329/fuse.js', + undefined, + 'head', + ); + }, + 'geniee': async (): Promise => { + window.gnshbrequest = window.gnshbrequest || {cmd:[]}; + window.gnshbrequest.cmd.push(function(){ + window.gnshbrequest.forceInternalRequest(); + }); + + await loadScript( + 'gpt', + 'https://securepubads.g.doubleclick.net/tag/js/gpt.js', + undefined, + 'head', + ); + await loadScript( + 'geniee', + 'https://cpt.geniee.jp/hb/v1/222988/2860/wrapper.min.js', + undefined, + 'head', + ); + }, + 'pushup': async (): Promise => { + await loadScript( + 'adpushup', + 'https://cdn.adpushup.com/47589/adpushup.js', + undefined, + 'head', + ); + }, +} + const loadAds = async (): Promise => { if (!adsEnabled.value) { return; } try { - window.gnshbrequest = window.gnshbrequest || { cmd: [] }; - window.gnshbrequest.cmd.push(function () { - window.gnshbrequest.forceInternalRequest(); - }); - - const splitProbability = Math.floor(Math.random() * 100); - if (splitProbability < 50) { - const s1 = document.createElement("script"); - s1.async = true; - const element = - document.getElementsByTagName("head")[0] || - document.getElementsByTagName("body")[0]; - s1.src = "https://cdn.fuseplatform.net/publift/tags/2/3329/fuse.js"; - element.appendChild(s1); - } else { - (function (w, d) { - const s = d.createElement("script"); - s.src = "//cdn.adpushup.com/47589/adpushup.js"; - s.crossOrigin = "anonymous"; - s.type = "text/javascript"; - s.async = true; - ( - d.getElementsByTagName("head")[0] || - d.getElementsByTagName("body")[0] - ).appendChild(s); - w.adpushup = w.adpushup || { que: [] }; - })(window, document); + console.log('loading', provider.value); + const key = provider.value as keyof typeof loadAdsForProvider; + if (!loadAdsForProvider.hasOwnProperty(key)) { + throw new Error("Invalid provider: " + key); } - - // await loadScript( - // 'gpt', - // 'https://securepubads.g.doubleclick.net/tag/js/gpt.js', - // undefined, - // 'head', - // ); - // await loadScript( - // 'geniee', - // 'https://cpt.geniee.jp/hb/v1/222988/2860/wrapper.min.js', - // undefined, - // 'head', - // ); + await loadAdsForProvider[key](); } catch (error) { if (error instanceof LoadScriptError) { return; diff --git a/pages/index-locale.vue b/pages/index-locale.vue index 18ca9fff5..79f1fcb39 100644 --- a/pages/index-locale.vue +++ b/pages/index-locale.vue @@ -62,6 +62,9 @@ const { data: featuredPosts } = useAsyncData('featured-posts', async () => { diff --git a/layouts/default.vue b/layouts/default.vue index d93da6230..228e287b1 100644 --- a/layouts/default.vue +++ b/layouts/default.vue @@ -1,8 +1,8 @@