first commit

master
guofei 2024-07-03 14:42:48 +08:00
commit 53fec6ca78
23 changed files with 9844 additions and 0 deletions

11
.gitignore vendored 100644
View File

@ -0,0 +1,11 @@
node_modules
yarn.lock
package-lock.json
.DS_Store
dist
dist-ssr
*.local
devops/config.js
src/components.d.ts
.devcontainer/
.zip

3
.vscode/settings.json vendored 100644
View File

@ -0,0 +1,3 @@
{
"liveServer.settings.port": 5501
}

4131
game copy.html 100644

File diff suppressed because one or more lines are too long

4131
game.html 100644

File diff suppressed because one or more lines are too long

17
index.html 100644
View File

@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body>
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<script type="module" src="./src/main.js"></script>
</body>
</html>

25
package.json 100644
View File

@ -0,0 +1,25 @@
{
"name": "guanggao",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"dev": "vite ",
"build": "vite build"
},
"author": "",
"license": "ISC",
"devDependencies": {
"@vitejs/plugin-vue": "^5.0.4",
"rollup-plugin-copy": "^3.5.0",
"sass": "^1.77.1",
"vite": "^5.2.11",
"vite-plugin-cdn-import": "^1.0.1"
},
"dependencies": {
"axios": "^1.6.8",
"crypto-js": "^4.2.0",
"jquery": "^3.7.1",
"md5": "^2.3.0"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 186 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 346 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

View File

@ -0,0 +1,12 @@
1. 广告渠道的pixel。 见google tag文件将里边的代码放在页面head里就可以 √
2. 打点及文件下载。 在helpers.js中打点方法为BILog, 打点的触发时机在themes.js中。 页面加载的时候上传BILog
3. 文件下载。 在helper.js中 下载文件根据url中传入的clickid转化成clickcode添加到下载的文件安装包上 下载的时候上传BILog
3. cookie consent。 html和多语言翻译见cookie.json footer-cookie.php cookie.js √
# 使用方法
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<script type="module" src="./index.js"></script>
<link rel="stylesheet" type="text/css" src="./index.css"/>

12
readme.md 100644
View File

@ -0,0 +1,12 @@
# 使用方法
```
协议弹框使用jquery 动态写入需要引入jquery
1. 引入当前文件夹下的.js和.css文件
2. 下载已经挂到window.downloadPackage方法上了
```
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<script type="module" src="/main.js"></script>
<link rel="stylesheet" type="text/css" href="/main.css"/>

View File

@ -0,0 +1,144 @@
import * as helper from "./helpers";
// Available Cookies: all, necessary
// Setup default Cookie Consent
// Cookie Notice
const showCookieNotice = () => {
const notice = document.querySelector("#cookie-notice");
notice.style.display = "flex";
setTimeout(() => {
notice.style.display = "none";
}, 2000);
};
// Cookie Footer Initialization
const domCookieFooter = document.querySelector("#cookie-footer");
const cookieOpt = helper.getCookie("fp_opt");
const cookieBannerInitial = () => {
// Show Cookie Footer
domCookieFooter.style.display = "block";
helper.BILog("privacy_protocol_lp", {
privacy_action: "window_pop_up",
privacy_pop_style: 1,
privacy_lang: window.lang,
});
// Accept all cookies
if (cookieOpt === "all") {
helper.consentAllGranted();
}
// Cookie Footer
const btnConfig = document.querySelector("#cookie-config");
const btnClose = document.querySelector("#modal-close");
const domModalConfig = document.querySelector("#cookie-modal");
btnConfig.addEventListener("click", () => {
helper.BILog("privacy_protocol_lp", {
privacy_action: "custom_setting",
privacy_pop_style: 1,
privacy_lang: window.lang,
});
// Show Cookie Popup
domModalConfig.style.display = "flex";
// Close Cookie Footer
domCookieFooter.style.display = "none";
});
btnClose.addEventListener("click", () => {
// Close Cookie Popup
domModalConfig.style.display = "none";
});
// Accept All, in footer & in config modal
const btnAcceptAll = document.querySelectorAll(".accept-all");
btnAcceptAll.forEach((btn) => {
btn.addEventListener("click", () => {
document
.querySelectorAll('.cookie-item input[type="checkbox"]')
.forEach((el) => {
el.checked = true;
});
helper.consentAllGranted();
// Set Cookie
helper.setCookie("fp_opt", "all", 365);
// Close Cookie Footer
domCookieFooter.style.display = "none";
domModalConfig.style.display = "none";
showCookieNotice();
});
});
document
.querySelector("#cookie-footer .accept-all")
.addEventListener("click", () => {
helper.BILog("privacy_protocol_lp", {
privacy_action: "accept_all_cookies",
privacy_pop_style: 1,
privacy_lang: window.lang,
});
});
document
.querySelector("#cookie-modal .accept-all")
.addEventListener("click", () => {
helper.BILog("privacy_protocol_lp", {
privacy_action: "custom_accept_all_cookies",
privacy_pop_style: 1,
privacy_lang: window.lang,
});
});
// Confirm selections
const btnConfirm = document.querySelector(".cookie-confirm");
btnConfirm.addEventListener("click", () => {
if (
document.querySelector('.analytics input[type="checkbox"]')
.checked === true
) {
// marketing on
helper.setCookie("fp_opt", "all", 365);
helper.consentAllGranted();
helper.BILog("privacy_protocol_lp", {
privacy_action: "custom_confirm_selection",
privacy_marketing_cookie: "on",
privacy_pop_style: 1,
privacy_lang: window.lang,
});
} else {
// marketing off
helper.setCookie("fp_opt", "necessary", 365);
helper.BILog("privacy_protocol_lp", {
privacy_action: "custom_confirm_selection",
privacy_marketing_cookie: "off",
privacy_pop_style: 1,
privacy_lang: window.lang,
});
}
//Close Modal
domModalConfig.style.display = "none";
showCookieNotice();
});
// Cookie Details
const domCookieTypeTitle = document.querySelectorAll(".cookie-title");
domCookieTypeTitle.forEach((cookieTitle) => {
cookieTitle.querySelector("img").addEventListener("click", () => {
const cookieIntro = cookieTitle.nextElementSibling;
cookieIntro.style.display = "block";
});
});
};
helper.ifUseCookieConsent().then((data) => {
const currentCountry = data.data.data.location.country;
if (
!helper.bannerCountriesList.includes(currentCountry) ||
helper.getCookie("fp_opt")
) {
if (helper.getCookie("fp_opt") === "all") {
helper.consentAllGranted();
}
} else {
document.querySelector("#copyright").style.display = "none";
cookieBannerInitial();
}
});

View File

@ -0,0 +1,128 @@
{
"type": {
"footer_txt": "浮窗文案\r\n备注Privacy Policy、Terms of Use挂载超链接",
"footer_btn_left": "浮窗左侧按钮",
"footer_btn_right": "浮窗右侧按钮",
"modal_title": "弹窗标题",
"modal_txt": "弹窗正文",
"cookie_type_1": "cookie 类型 1",
"cookie_intro_1": "cookie 类型 1 说明",
"cookie_type_2": "cookie 类型 2",
"cookie_intro_2": "cookie 类型 2 说明",
"modal_btn_left": "弹窗左侧按钮",
"modal_btn_right": "弹窗右侧按钮",
"tips_success": "成功 tips"
},
"en": {
"footer_txt": "We hope to offer you higher quality services. Please read our %1Privacy Policy%2 and %3Terms of Use%2 carefully and confirm your acceptance before you download and play the game.",
"footer_btn_left": "Accept all cookies",
"footer_btn_right": "Customize cookies",
"modal_title": "Customize cookies",
"modal_txt": "When you visit our website, your browser may store or retrieve information in the form of cookies. These cookies are primarily used for the basic functioning of the website and for capabilities that offer personalized services. You can choose to disable or enable certain types of cookies according to your needs. Please review the descriptions of each cookie category and set them according to your preferences. Note that some cookies are essential and cannot be disabled; other types of cookies may affect your user experience or the services we offer, so please choose wisely.",
"cookie_type_1": "Necessary Cookie",
"cookie_intro_1": "This category of Cookie is related to the basic service functionality of the website and must be obtained to ensure the operation of the website; therefore, consent is mandatory, please understand.",
"cookie_type_2": "Maketing Cookie",
"cookie_intro_2": "This type of Cookie is primarily used for marketing activities, helping us to understand your behavioral interests so that we can provide you with personalized services.",
"modal_btn_left": "Confirm current selection",
"modal_btn_right": "Accept all Cookies",
"tips_success": "Your settings have been saved, come download the game now~"
},
"zh-CN": {
"footer_txt": "我们希望为您提供更高质量的服务,在您下载和玩游戏之前,请仔细阅读我们的%1隐私政策%2和%3使用条款%2并确认接受。",
"footer_btn_left": "接受所有 Cookie",
"footer_btn_right": "自定义 Cookie",
"modal_title": "自定义 Cookie",
"modal_txt": "当您访问我们的网页时您的浏览器可能会以cookie 的形式存储或检索信息。这些 cookie 主要用于网页的基础服务能力,和一些能够为您提供个性化服务的能力。您可以根据自身的需要,选择禁止或开启某些类型的 cookie请您浏览各类 cookie 的说明,按照自身需求进行设置。请注意,有一些 cookie 是必须获取的,无法禁止;其他类型的 cookie 可能会影响您的用户体验,或我们为您提供的服务,请您注意甄别。",
"cookie_type_1": "基础必要类 Cookie",
"cookie_intro_1": "该类 Cookie 涉及网页的基础服务能力,必须要获取才能保证网页运行,因此必须同意,请谅解",
"cookie_type_2": "市场类 Cookie",
"cookie_intro_2": "该类 Cookie 主要用于市场营销活动,帮助我们了解您的行为兴趣,以便我们能够为您提供个性化的服务。",
"modal_btn_left": "确认当前选择",
"modal_btn_right": "接受所有 Cookie",
"tips_success": "您的设置已保存,快来下载游戏吧~"
},
"fr": {
"footer_txt": "Nous espérons vous offrir des services de meilleure qualité. Veuillez lire attentivement notre %1Politique de Confidentialité%2 et nos %3Conditions d'Utilisation%2 et confirmer votre acceptation avant de télécharger et de jouer au jeu.",
"footer_btn_left": "Accepter tous les cookies",
"footer_btn_right": "Personnaliser les cookies",
"modal_title": "Personnaliser les cookies",
"modal_txt": "Lorsque vous visitez notre site web, votre navigateur peut stocker ou récupérer des informations sous forme de cookies. Ces cookies sont principalement utilisés pour les capacités de service de base du site web et pour certaines fonctionnalités qui peuvent vous fournir des services personnalisés. Vous pouvez choisir de désactiver ou d'activer certains types de cookies selon vos besoins. Veuillez consulter les descriptions de chaque catégorie de cookies et les configurer selon vos préférences. Notez que certains cookies sont essentiels et ne peuvent pas être désactivés ; d'autres types de cookies peuvent affecter votre expérience utilisateur ou les services que nous offrons, veuillez donc faire attention à votre choix.",
"cookie_type_1": "Cookie nécessaire",
"cookie_intro_1": "Cette catégorie de Cookie concerne les fonctionnalités de service de base du site Web et doit être obtenue pour garantir le fonctionnement du site ; par conséquent, le consentement est obligatoire, veuillez comprendre.",
"cookie_type_2": "Cookie marketing",
"cookie_intro_2": "Ce type de Cookie est principalement utilisé pour les activités de marketing, nous aidant à comprendre vos intérêts comportementaux afin de pouvoir vous offrir des services personnalisés.",
"modal_btn_left": "Confirmer la sélection actuelle",
"modal_btn_right": "Accepter tous les cookies",
"tips_success": "Vos paramètres ont été enregistrés, venez télécharger le jeu maintenant~"
},
"de": {
"footer_txt": "Wir hoffen, Ihnen hochwertigere Dienste anbieten zu können. Bitte lesen Sie unsere %1Datenschutzrichtlinie%2 und %3Nutzungsbedingungen%2 sorgfältig durch und bestätigen Sie Ihre Zustimmung, bevor Sie das Spiel herunterladen und spielen.",
"footer_btn_left": "Alle Cookies akzeptieren",
"footer_btn_right": "Cookies anpassen",
"modal_title": "Cookies anpassen",
"modal_txt": "Wenn Sie unsere Webseite besuchen, kann Ihr Browser Informationen in Form von Cookies speichern oder abrufen. Diese Cookies werden hauptsächlich für die grundlegenden Dienstleistungsfähigkeiten der Webseite und für Funktionen verwendet, die personalisierte Dienste bieten können. Sie können bestimmte Arten von Cookies nach Ihren Bedürfnissen deaktivieren oder aktivieren. Bitte lesen Sie die Beschreibungen der verschiedenen Cookie-Kategorien und nehmen Sie entsprechend Ihrer Bedürfnisse Einstellungen vor. Beachten Sie, dass einige Cookies unerlässlich sind und nicht deaktiviert werden können; andere Arten von Cookies können Ihre Benutzererfahrung oder die von uns angebotenen Dienste beeinflussen, bitte wählen Sie sorgfältig.",
"cookie_type_1": "Notwendiges Cookie",
"cookie_intro_1": "Diese Kategorie von Cookies ist für die grundlegenden Servicefunktionen der Webseite notwendig und muss akzeptiert werden, um den Betrieb der Webseite zu gewährleisten; daher ist die Zustimmung obligatorisch, bitte haben Sie Verständnis.",
"cookie_type_2": "Marketing-Cookie",
"cookie_intro_2": "Diese Art von Cookie wird hauptsächlich für Marketingaktivitäten verwendet, um uns zu helfen, Ihre Verhaltensinteressen zu verstehen, damit wir Ihnen personalisierte Dienste anbieten können.",
"modal_btn_left": "Aktuelle Auswahl bestätigen",
"modal_btn_right": "Alle Cookies akzeptieren",
"tips_success": "Ihre Einstellungen wurden gespeichert, laden Sie jetzt das Spiel herunter~"
},
"ja": {
"footer_txt": "より高品質のサービスを提供できることを願っています。ゲームをダウンロードしてプレイする前に、当社の%1プライバシーポリシー%2と%3利用規約%2を注意深くお読みになり、ご同意いただけることを確認してください。",
"footer_btn_left": "すべてのクッキーを許可",
"footer_btn_right": "クッキー設定",
"modal_title": "クッキー設定",
"modal_txt": "当社のウェブページを訪問する際、お使いのブラウザはクッキーの形で情報を保存または取得することがあります。これらのクッキーは主にウェブページの基本的な機能と、パーソナライズされたサービスを提供する能力のために使用されます。ご自身のニーズに応じて、特定のタイプのクッキーを無効にするか有効にするかを選択できます。各クッキーの説明をご覧になり、ご自身の要求に応じて設定してください。必須のクッキーもあり、無効にすることはできませんのでご注意ください。他のタイプのクッキーは、ユーザー体験や提供するサービスに影響を与える可能性がありますので、選択には注意してください。",
"cookie_type_1": "必要なクッキー",
"cookie_intro_1": "このカテゴリーのCookieは、ウェブサイトの基本的なサービス機能に関連しており、ウェブサイトの運営を保証するために必要です。したがって、同意が必須となりますので、ご了承ください。",
"cookie_type_2": "マーケティングCookie",
"cookie_intro_2": "この種類のCookieは、主にマーケティング活動に使用され、お客様の行動上の興味を理解することで、パーソナライズされたサービスを提供することができます。",
"modal_btn_left": "現在の選択を確認",
"modal_btn_right": "すべてのクッキーを許可",
"tips_success": "設定が保存されました。さあ、ゲームをダウンロードしましょう~"
},
"ko": {
"footer_txt": "우리는 여러분께 더 높은 품질의 서비스를 제공하고자 합니다. 게임을 다운로드하고 플레이하기 전에 %1개인정보처리방침%2 및 %3이용약관%2을 주의 깊게 읽고 동의 여부를 확인해 주시기 바랍니다.",
"footer_btn_left": "모든 쿠키 수락",
"footer_btn_right": "쿠키 사용자 정의",
"modal_title": "쿠키 사용자 정의",
"modal_txt": "웹사이트를 방문할 때 브라우저는 쿠키 형태로 정보를 저장하거나 검색할 수 있습니다. 이 쿠키들은 주로 웹사이트의 기본 서비스 기능과 개인화된 서비스를 제공할 수 있는 기능에 사용됩니다. 필요에 따라 특정 유형의 쿠키를 비활성화하거나 활성화할 수 있습니다. 각 쿠키 범주의 설명을 검토하고 자신의 필요에 맞게 설정하십시오. 일부 쿠키는 필수적이며 비활성화할 수 없음을 유의하십시오. 다른 유형의 쿠키는 사용자 경험이나 제공하는 서비스에 영향을 줄 수 있으므로 신중히 선택하십시오.",
"cookie_type_1": "필수 쿠키",
"cookie_intro_1": "이러한 쿠키 범주는 웹사이트의 기본 서비스 기능과 관련이 있으며, 웹사이트의 운영을 보장하기 위해 반드시 획득해야 합니다. 따라서 동의가 필수입니다. 이해해 주십시오.",
"cookie_type_2": "마케팅 쿠키",
"cookie_intro_2": "이러한 쿠키는 주로 마케팅 활동에 사용되며, 고객님의 행동적 관심사를 이해함으로써 개인화된 서비스를 제공할 수 있습니다.",
"modal_btn_left": "현재 선택 확인",
"modal_btn_right": "모든 쿠키 수락",
"tips_success": "설정이 저장되었습니다, 게임을 다운로드하세요~"
},
"zh-TW": {
"footer_txt": "我們希望為您提供更高品質的服務。請在下載並遊玩遊戲前,仔細閱讀我們的%1隱私政策%2和%3使用條款%2並確認接受。",
"footer_btn_left": "接受所有 Cookie",
"footer_btn_right": "自訂 Cookie",
"modal_title": "自訂 Cookie",
"modal_txt": "當您訪問我們的網頁時您的瀏覽器可能會以cookie的形式儲存或檢索資訊。這些cookie主要用於網頁的基礎服務能力以及一些能夠為您提供個性化服務的能力。您可以根據自身的需要選擇禁止或開啟某些類型的cookie請您瀏覽各類cookie的說明按照自身需求進行設置。請注意有一些cookie是必須獲取的無法禁止其他類型的cookie可能會影響您的用戶體驗或我們為您提供的服務請您注意甄別。",
"cookie_type_1": "基礎必要類 Cookie",
"cookie_intro_1": "該類 Cookie 涉及網頁的基礎服務能力,必須要獲取才能保證網頁運行,因此必須同意,請諒解。",
"cookie_type_2": "市場類 Cookie",
"cookie_intro_2": "該類 Cookie 主要用於市場營銷活動,幫助我們了解您的行為興趣,以便我們能夠為您提供個性化的服務。",
"modal_btn_left": "確認當前選擇",
"modal_btn_right": "接受所有 Cookie",
"tips_success": "您的設定已儲存,快來下載遊戲吧~"
},
"ru": {
"footer_txt": "Мы надеемся предложить вам услуги более высокого качества. Пожалуйста, внимательно прочитайте нашу %1Политику конфиденциальности%2 и %3Условия использования%2 и подтвердите ваше согласие, прежде чем скачивать и играть в игру.",
"footer_btn_left": "Принять все куки",
"footer_btn_right": "Настроить куки",
"modal_title": "Настроить куки",
"modal_txt": "Когда вы посещаете наш веб-сайт, ваш браузер может сохранять или извлекать информацию в виде куки. Эти куки в основном используются для базовых функций веб-сайта и для возможностей предоставления персонализированных услуг. Вы можете выбрать, запретить или включить определенные типы куки в соответствии с вашими потребностями. Пожалуйста, ознакомьтесь с описаниями каждой категории куки и настройте их в соответствии с вашими предпочтениями. Обратите внимание, что некоторые куки являются обязательными и не могут быть отключены; другие типы куки могут повлиять на ваш пользовательский опыт или на услуги, которые мы предлагаем, поэтому пожалуйста, выбирайте осознанно.",
"cookie_type_1": "Необходимый куки",
"cookie_intro_1": "Этот класс Cookie связан с базовыми функциями сервиса веб-сайта и должен быть получен для обеспечения работы сайта; следовательно, согласие является обязательным, пожалуйста, поймите.",
"cookie_type_2": "Маркетинговые куки",
"cookie_intro_2": "Этот тип Cookie в основном используется для маркетинговых активностей, помогая нам понять ваши поведенческие интересы, чтобы мы могли предложить вам персонализированные услуги.",
"modal_btn_left": "Подтвердить текущий выбор",
"modal_btn_right": "Принять все куки",
"tips_success": "Ваши настройки сохранены, приходите скачивать игру~"
}
}

View File

@ -0,0 +1,48 @@
const googleTags = [
`
(function(w, d, s, l, i) {
w[l] = w[l] || [];
w[l].push({
'gtm.start': new Date().getTime(),
event: 'gtm.js'
});
var f = d.getElementsByTagName(s)[0],
j = d.createElement(s),
dl = l != 'dataLayer' ? '&l=' + l : '';
j.async = true;
j.src =
'https://www.googletagmanager.com/gtm.js?id=' + i + dl;
f.parentNode.insertBefore(j, f);
})(window, document, 'script', 'dataLayer', 'GTM-TT3RP8FX');
`,
`
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
// Setup default Cookie Consent
gtag('consent', 'default', {
'ad_storage': 'granted',
'ad_user_data': 'granted',
'ad_personalization': 'granted',
'analytics_storage': 'granted',
});
gtag('consent', 'default', {
'ad_storage': 'denied',
'ad_user_data': 'denied',
'ad_personalization': 'denied',
'analytics_storage': 'denied',
'region': ['BE', 'EL', 'LT', 'PT', 'BG', 'ES', 'LU', 'RO', 'CZ', 'FR', 'HU', 'SI', 'DK', 'HR', 'MT', 'SK', 'DE', 'IT', 'NL', 'FI', 'EE', 'CY', 'AT', 'SE', 'IE', 'LV', 'PL', 'NO', 'IS', 'LI']
});
`,
];
export const asyncLoadGoogleTag = () => {
googleTags.forEach((scriptContent) => {
let script = document.createElement("script");
script.type = "text/javascript";
script.text = scriptContent;
script.async = true;
document.head.appendChild(script);
});
};

View File

@ -0,0 +1,493 @@
import hmacSHA256 from "crypto-js/hmac-sha256";
import Base64 from "crypto-js/enc-base64";
import axios from "axios";
import md5 from "md5";
const cryptoAlt = (obj, key) => {
const hashDigest = hmacSHA256(JSON.stringify(obj), key);
const hmacDigest = Base64.stringify(hashDigest);
return hmacDigest;
};
const GaMaps = {
ss: "G-NK21CX9CG0",
ss_pk: "G-NK21CX9CG0",
koa: "G-SRMNZTXWFQ",
st: "G-SRMNZTXWFQ",
entropy: "G-MZTZZ0GX0N",
mc: "G-RKZ5FCNRMD",
mo: "G-5P5SJJKY77",
};
const appId = {
ss: "627a1da83e6d9717222693d5",
ss_pk: "627a1da83e6d9717222693d5",
koa: "62fef5d838fd9e09520e7c34",
st: "56b21e4c-0c54-4f10-bc45-537b728af411",
entropy: "6391da126cec4e09951a3344",
mc: "c7e96053-2a18-4587-95cf-2aadc8524cb7",
mo: "f95e76b2-c0f2-4a9d-8675-f34b28e473f5",
};
const custom_api = "https://upload-s3.funplus.com/api/upload_s3/event";
const tag = "funplus.global.prod.pc_core";
const key = "2905ac8d9fbae0020c541675edb34941";
const api = "https://ss-logagent-cdn.kingsgroupgames.com/log";
// Detect Browser
export const getBrowserName = () => {
const agent = window.navigator.userAgent.toLowerCase();
switch (true) {
case agent.indexOf("edge") > -1:
return "MS Edge";
case agent.indexOf("edg/") > -1:
return "Edge ( chromium based)";
case agent.indexOf("yabrowser") > -1:
return "YaBrowser";
case agent.indexOf("opr") > -1 && !!window.opr:
return "Opera";
case agent.indexOf("chrome") > -1 && !!window.chrome:
return "Chrome";
case agent.indexOf("trident") > -1:
return "MS IE";
case agent.indexOf("firefox") > -1:
return "Mozilla Firefox";
case agent.indexOf("safari") > -1:
return "Safari";
default:
return "other";
}
};
// Detect OS
export const getOs = () => {
var OSName = "Not Known";
if (window.navigator.userAgent.indexOf("Win") != -1) OSName = "Windows";
if (window.navigator.userAgent.indexOf("Mac") != -1) OSName = "Mac OS";
if (window.navigator.userAgent.indexOf("CrOS") != -1) OSName = "Chrome OS";
if (window.navigator.userAgent.indexOf("MSIE") > -1) OSName = "IE";
if (window.navigator.userAgent.indexOf("rv:11.0") > -1) OSName = "IE";
return OSName;
};
// Detect OS Version
export const getOsVersion = () => {
var agent = navigator.userAgent.toLowerCase();
if (agent.indexOf("win32") >= 0 || agent.indexOf("wow32") >= 0) {
return "win32";
} else if (agent.indexOf("win64") >= 0 || agent.indexOf("wow64") >= 0) {
return "win64";
}
return "not win";
};
// Detect Windows Version
export const getWindowsVersion = () => {
var OSName = "Not Windows";
if (window.navigator.userAgent.indexOf("Win") != -1) {
OSName = "Windows 11";
if (window.navigator.userAgent.indexOf("Windows NT 10.0") != -1)
OSName = "Windows 10";
if (window.navigator.userAgent.indexOf("Windows NT 6.3") != -1)
OSName = "Windows 8.1";
if (window.navigator.userAgent.indexOf("Windows NT 6.2") != -1)
OSName = "Windows 8";
if (window.navigator.userAgent.indexOf("Windows NT 6.1") != -1)
OSName = "Windows 7";
if (window.navigator.userAgent.indexOf("Windows NT 6.0") != -1)
OSName = "Windows Vista";
if (window.navigator.userAgent.indexOf("Windows NT 5.1") != -1)
OSName = "Windows XP";
if (window.navigator.userAgent.indexOf("Windows NT 5.0") != -1)
OSName = "Windows 2000";
}
return OSName;
};
export const getUrlParam = (key) => {
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
const value = urlParams.get(key);
if (!value) return;
return decodeURIComponent(value);
};
// Manipulate Cookies
export const setCookie = (name, value, days) => {
var expires = "";
if (days) {
var date = new Date();
date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
expires = "; expires=" + date.toUTCString();
}
document.cookie = name + "=" + (value || "") + expires + "; path=/";
};
export const getCookie = (name) => {
var nameEQ = name + "=";
var ca = document.cookie.split(";");
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == " ") c = c.substring(1, c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
}
return null;
};
// Get Channel Name
export const getChannelName = () => {
let channel = getUrlParam("ms");
switch (channel) {
case "gg":
return "google";
case "fb":
return "facebook";
case "yt":
return "youtubekol";
case "tw":
return "twitter";
case "xs":
return "Xsolla Partner Network";
case "mt":
return "mytarget";
case "mtz":
return "mytarget_z";
case "rd":
return "reddit";
case "ppl":
return "PropellerAds";
default:
return channel;
}
};
// Detect Chrome Version
export const getChromeVersion = () => {
var raw = navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./);
return raw ? parseInt(raw[2], 10) : "Not Chrome";
};
// Encrypt
const HMAC = async (key, message) => {
try {
const g = (str) =>
new Uint8Array(
[...unescape(encodeURIComponent(str))].map((c) => c.charCodeAt(0))
),
k = g(key),
m = g(message),
c = await crypto.subtle.importKey(
"raw",
k,
{ name: "HMAC", hash: "SHA-256" },
true,
["sign"]
),
s = await crypto.subtle.sign("HMAC", c, m);
[...new Uint8Array(s)].map((b) => b.toString(16).padStart(2, "0")).join("");
return btoa(String.fromCharCode(...new Uint8Array(s)));
} catch {}
};
let clickid =
getUrlParam("gclid") ||
getUrlParam("fbclid") ||
getUrlParam("twclid") ||
getUrlParam("tracking_id") ||
getUrlParam("click-id") ||
getUrlParam("transaction_id") ||
getUrlParam("dclid") ||
getUrlParam("rb_clickid") ||
getUrlParam("suid");
// 通用渠道
if (!clickid) {
if (getUrlParam("auto") == 1 && getUrlParam("ms")) {
if (getCookie("clickid")) {
clickid = getCookie("clickid");
} else {
clickid = getUrlParam("ms") + Date.now();
setCookie("clickid", clickid, 1);
}
}
}
const clickcode = clickid ? md5(clickid).slice(0, 10) : "";
export const defaultDownload = () => {
const PcDownloadSrc = {
ss: "https://userplatform-download.akamaized.net/official-website/pc-launcher-setup/State.of.Survival.PC.V1.0.exe",
ss_pk:
"https://userplatform-download.akamaized.net/official-website/pc-launcher-setup/State.of.Survival.Parkour.PC.V1.0.exe",
koa: "https://userplatform-download.akamaized.net/official-website/pc-launcher-setup/King.of.Avalon.PC.V1.0.exe",
st: "https://userplatform-download.akamaized.net/official-website/pc-launcher-setup/Stormshot.PC.V1.0.exe",
entropy:
"https://userplatform-download.akamaized.net/official-website/pc-launcher-setup/Entropy.PC.V1.0.exe",
mc: "https://userplatform-download.akamaized.net/official-website/pc-launcher-setup/MistyContinent.PC.V1.0.exe",
mo: "https://userplatform-download.akamaized.net/official-website/pc-launcher-setup/Sea.of.Conquest.PC.V1.0.exe",
};
const MacDownloadSrc = {
st: "https://userplatform-download.akamaized.net/official-website/pc-launcher-setup-mac/Stormshot.V1.0.pkg",
ss: "https://userplatform-download.akamaized.net/official-website/pc-launcher-setup-mac/State.of.Survival.V1.0.pkg",
};
var link = document.createElement("a");
var body = document.querySelector("body");
let downloadSrc = PcDownloadSrc;
if (
getOs() === "Mac OS" &&
window.project in MacDownloadSrc &&
document.querySelector("#download-btn").getAttribute("data-mac") ===
"enable"
) {
downloadSrc = MacDownloadSrc;
}
link.href = clickcode
? downloadSrc[window.project] + "?clickcode=" + clickcode
: downloadSrc[window.project];
// fix Firefox
link.style.display = "none";
body.appendChild(link);
link.click();
body.removeChild(link);
window.URL.revokeObjectURL(link.href);
$(".download-notice").show();
};
// Handle Log
export const log_realtime = (event) => {
let clickcode_temp = !clickcode ? "null" : clickcode;
var secret = "e03b0da71d31f4c9e55b6f547f782097";
HMAC(secret, clickcode_temp).then(function (sign) {
fetch(custom_api, {
method: "post",
body: "",
credentials: "include",
mode: "cors",
headers: new Headers({
"Content-Type": "application/json",
"X-Content-Secret": sign,
platform: getOs(),
event: event,
appVersion: getChannelName(),
deviceId: clickcode_temp,
content: window.page_id,
osVersion: getOsVersion(),
appId: appId[window.project],
env: window.location.href,
}),
}).then((response) => response.json());
});
};
export const log_error = (event, errCode, errMessage) => {
// 1001 页面加载错误, 1002 页面page_view打点错误 1003 页面download错误
var secret = "e03b0da71d31f4c9e55b6f547f782097";
HMAC(secret, errCode).then(function (sign) {
fetch(custom_api, {
method: "post",
body: "",
credentials: "include",
mode: "cors",
headers: new Headers({
"Content-Type": "application/json",
"X-Content-Secret": sign,
platform: getOs(),
event: event,
appVersion: getChannelName(),
deviceId: errCode,
content: errMessage,
osVersion: getOsVersion(),
appId: appId[window.project],
env: window.location.href,
}),
}).then((response) => response.json());
});
};
export const BILog = async (event, additionalDetail) => {
/**
* Post data to log agent when download button clicked
* gclid, click_code
*/
// Handle PWN exceptions
let pwn_adgroup_name, pwn_ad_name;
if (getChannelName() == "pwn" && getUrlParam("source")) {
pwn_adgroup_name = getUrlParam("source").split("_")[0];
pwn_ad_name = getUrlParam("source").split("_")[1];
}
const dataLog = {
log_source: "wp",
data_version: "1.0",
properties: {
click_id: clickid,
click_code: clickcode,
os: getOs(),
os_version: getWindowsVersion(),
browser: getBrowserName(),
chrome_version: getChromeVersion(),
user_agent: navigator.userAgent,
},
detail: {
media_source: getChannelName(),
campaign_id:
getUrlParam("utm_campaign") ||
getUrlParam("campaign_id") ||
getUrlParam("cp_id"),
adgroup_id:
getUrlParam("utm_medium") ||
getUrlParam("adgroup_id") ||
getUrlParam("ag_id"),
page_id: window.page_id,
ad_id: getUrlParam("utm_source") || getUrlParam("ad_id"),
dt: "",
network: getUrlParam("network"),
campaign_name: getUrlParam("cp") || getUrlParam("campaign"),
adgroup_name: getUrlParam("ag") || pwn_adgroup_name,
ad_name: getUrlParam("ad") || pwn_ad_name,
cost_value: getUrlParam("cost_value"),
referrer: document.referrer,
url: window.location.href,
...additionalDetail,
},
};
// Handle FB repeated params key problem
if (getChannelName() === "facebook") {
dataLog["detail"]["ad_id"] = getUrlParam("ad_id");
dataLog["detail"]["adgroup_id"] = getUrlParam("adgroup_id");
dataLog["detail"]["campaign_id"] = getUrlParam("campaign_id");
}
//handle error code
const errCode = event === "pc_page_view" ? 1002 : 1003;
var timeNow = Date.now();
var signature = md5(tag + ":" + timeNow + ":" + key);
var new_api =
api +
"?tag=" +
tag +
"&timestamp=" +
timeNow +
"&signature=" +
signature +
"&num=1";
dataLog["event_ts"] = timeNow;
dataLog["event"] = event;
dataLog["app_id"] = `${window.project}.global.prod`;
// Modify Log Data for SS Parkour
if (window.project === "ss_pk") {
dataLog["app_id"] = "ss.global.prod";
dataLog["properties"]["pkg_channel"] = "ss_funplus_pc_parkour";
}
var request = new XMLHttpRequest();
request.open("POST", new_api, true);
request.setRequestHeader("Content-Type", "application/json; charset=UTF-8");
try {
if (getChannelName() == "google") {
gtag("get", GaMaps[window.project], "client_id", (clientID) => {
dataLog["detail"]["ga_client_id"] = clientID;
request.send(JSON.stringify(dataLog));
});
} else if (getChannelName() == "facebook") {
dataLog["detail"]["fbp"] = getCookie("_fbp");
dataLog["detail"]["fbc"] = getCookie("_fbc");
setTimeout(() => {
request.send(JSON.stringify(dataLog));
}, 100);
} else {
setTimeout(() => {
request.send(JSON.stringify(dataLog));
}, 100);
}
} catch (err) {
log_error("pc_page_view", errCode, err);
}
};
// Cookie Consent
export const consentAllGranted = () => {
gtag("consent", "update", {
ad_storage: "granted",
ad_user_data: "granted",
ad_personalization: "granted",
analytics_storage: "granted",
});
};
export const bannerCountriesList = [
"BE",
"EL",
"LT",
"PT",
"BG",
"ES",
"LU",
"RO",
"CZ",
"FR",
"HU",
"SI",
"DK",
"HR",
"MT",
"SK",
"DE",
"IT",
"NL",
"FI",
"EE",
"CY",
"AT",
"SE",
"IE",
"LV",
"PL",
"NO",
"IS",
"LI",
];
export const ifUseCookieConsent = () => {
const sign = "GwcRLrF8NBOvk4/N4Bna6aDkM28Vm1XjBLv6NdTH7a0=";
const params = {
app_id: "web",
device_id: "web",
from: "web",
lang: "en",
};
const apiDomains = {
koa: "https://koa-pc.kingsgroupgames.com",
ss: "https://sos-pc.kingsgroupgames.com",
ss_pk: "https://sos-pc.kingsgroupgames.com",
st: "https://st-pc.kingsgroupgames.com",
mo: "https://soc.seaofconquest.com",
mc: "https://mc-pc.kingsgroupgames.com",
entropy: "https://entropy-pc.kingsgroupgames.com",
};
if (window.location.hostname === "localhost") {
return Promise.resolve({
data: { data: { location: { country: "FR" } } },
});
} else {
const res = axios.post(
apiDomains[window.project] + "/api/get_ip_location/",
params,
{
headers: {
"Content-Type": "application/json",
auth: sign,
},
}
);
return res;
}
};

1
src/common/md5.min.js vendored 100644
View File

@ -0,0 +1 @@
!function(n){"use strict";function d(n,t){var r=(65535&n)+(65535&t);return(n>>16)+(t>>16)+(r>>16)<<16|65535&r}function f(n,t,r,e,o,u){return d(function(n,t){return n<<t|n>>>32-t}(d(d(t,n),d(e,u)),o),r)}function l(n,t,r,e,o,u,c){return f(t&r|~t&e,n,t,o,u,c)}function g(n,t,r,e,o,u,c){return f(t&e|r&~e,n,t,o,u,c)}function v(n,t,r,e,o,u,c){return f(t^r^e,n,t,o,u,c)}function m(n,t,r,e,o,u,c){return f(r^(t|~e),n,t,o,u,c)}function i(n,t){var r,e,o,u,c;n[t>>5]|=128<<t%32,n[14+(t+64>>>9<<4)]=t;var f=1732584193,i=-271733879,a=-1732584194,h=271733878;for(r=0;r<n.length;r+=16)i=m(i=m(i=m(i=m(i=v(i=v(i=v(i=v(i=g(i=g(i=g(i=g(i=l(i=l(i=l(i=l(o=i,a=l(u=a,h=l(c=h,f=l(e=f,i,a,h,n[r],7,-680876936),i,a,n[r+1],12,-389564586),f,i,n[r+2],17,606105819),h,f,n[r+3],22,-1044525330),a=l(a,h=l(h,f=l(f,i,a,h,n[r+4],7,-176418897),i,a,n[r+5],12,1200080426),f,i,n[r+6],17,-1473231341),h,f,n[r+7],22,-45705983),a=l(a,h=l(h,f=l(f,i,a,h,n[r+8],7,1770035416),i,a,n[r+9],12,-1958414417),f,i,n[r+10],17,-42063),h,f,n[r+11],22,-1990404162),a=l(a,h=l(h,f=l(f,i,a,h,n[r+12],7,1804603682),i,a,n[r+13],12,-40341101),f,i,n[r+14],17,-1502002290),h,f,n[r+15],22,1236535329),a=g(a,h=g(h,f=g(f,i,a,h,n[r+1],5,-165796510),i,a,n[r+6],9,-1069501632),f,i,n[r+11],14,643717713),h,f,n[r],20,-373897302),a=g(a,h=g(h,f=g(f,i,a,h,n[r+5],5,-701558691),i,a,n[r+10],9,38016083),f,i,n[r+15],14,-660478335),h,f,n[r+4],20,-405537848),a=g(a,h=g(h,f=g(f,i,a,h,n[r+9],5,568446438),i,a,n[r+14],9,-1019803690),f,i,n[r+3],14,-187363961),h,f,n[r+8],20,1163531501),a=g(a,h=g(h,f=g(f,i,a,h,n[r+13],5,-1444681467),i,a,n[r+2],9,-51403784),f,i,n[r+7],14,1735328473),h,f,n[r+12],20,-1926607734),a=v(a,h=v(h,f=v(f,i,a,h,n[r+5],4,-378558),i,a,n[r+8],11,-2022574463),f,i,n[r+11],16,1839030562),h,f,n[r+14],23,-35309556),a=v(a,h=v(h,f=v(f,i,a,h,n[r+1],4,-1530992060),i,a,n[r+4],11,1272893353),f,i,n[r+7],16,-155497632),h,f,n[r+10],23,-1094730640),a=v(a,h=v(h,f=v(f,i,a,h,n[r+13],4,681279174),i,a,n[r],11,-358537222),f,i,n[r+3],16,-722521979),h,f,n[r+6],23,76029189),a=v(a,h=v(h,f=v(f,i,a,h,n[r+9],4,-640364487),i,a,n[r+12],11,-421815835),f,i,n[r+15],16,530742520),h,f,n[r+2],23,-995338651),a=m(a,h=m(h,f=m(f,i,a,h,n[r],6,-198630844),i,a,n[r+7],10,1126891415),f,i,n[r+14],15,-1416354905),h,f,n[r+5],21,-57434055),a=m(a,h=m(h,f=m(f,i,a,h,n[r+12],6,1700485571),i,a,n[r+3],10,-1894986606),f,i,n[r+10],15,-1051523),h,f,n[r+1],21,-2054922799),a=m(a,h=m(h,f=m(f,i,a,h,n[r+8],6,1873313359),i,a,n[r+15],10,-30611744),f,i,n[r+6],15,-1560198380),h,f,n[r+13],21,1309151649),a=m(a,h=m(h,f=m(f,i,a,h,n[r+4],6,-145523070),i,a,n[r+11],10,-1120210379),f,i,n[r+2],15,718787259),h,f,n[r+9],21,-343485551),f=d(f,e),i=d(i,o),a=d(a,u),h=d(h,c);return[f,i,a,h]}function a(n){var t,r="",e=32*n.length;for(t=0;t<e;t+=8)r+=String.fromCharCode(n[t>>5]>>>t%32&255);return r}function h(n){var t,r=[];for(r[(n.length>>2)-1]=void 0,t=0;t<r.length;t+=1)r[t]=0;var e=8*n.length;for(t=0;t<e;t+=8)r[t>>5]|=(255&n.charCodeAt(t/8))<<t%32;return r}function e(n){var t,r,e="0123456789abcdef",o="";for(r=0;r<n.length;r+=1)t=n.charCodeAt(r),o+=e.charAt(t>>>4&15)+e.charAt(15&t);return o}function r(n){return unescape(encodeURIComponent(n))}function o(n){return function(n){return a(i(h(n),8*n.length))}(r(n))}function u(n,t){return function(n,t){var r,e,o=h(n),u=[],c=[];for(u[15]=c[15]=void 0,16<o.length&&(o=i(o,8*n.length)),r=0;r<16;r+=1)u[r]=909522486^o[r],c[r]=1549556828^o[r];return e=i(u.concat(h(t)),512+8*t.length),a(i(c.concat(e),640))}(r(n),r(t))}function t(n,t,r){return t?r?u(t,n):function(n,t){return e(u(n,t))}(t,n):r?o(n):function(n){return e(o(n))}(n)}"function"==typeof define&&define.amd?define(function(){return t}):"object"==typeof module&&module.exports?module.exports=t:n.md5=t}(this);

View File

@ -0,0 +1,69 @@
import * as helper from "./helpers";
window.curFF = false;
window.addEventListener("load", function () {
helper.BILog("pc_page_view");
if (helper.getOs() != "IE") {
helper.log_realtime("pc_page_view");
}
// steam & macstore & scheme showing notice on page landing
if (
(enable_steam && helper.getOs() === "Windows") ||
(enable_macstore && isArmMac()) ||
enable_scheme
) {
var link = document.createElement("a");
var body = document.querySelector("body");
link.href = enable_steam ? window.steam_link : window.scheme_link;
// fix Firefox
link.style.display = "none";
body.appendChild(link);
link.click();
body.removeChild(link);
window.URL.revokeObjectURL(link.href);
}
const downloadBtn = document.querySelector("#download-btn");
downloadBtn &&
downloadBtn.addEventListener("click", (event) => {
// Show download notice
// Windows, can download
if (helper.getOs() === "Windows") {
helper.defaultDownload();
} else {
// Not windows, but did not enable webgame
// if (!enable_webgame) {
helper.defaultDownload();
// }
}
// Trigger BI logagent on download
helper.BILog("pc_download");
if (helper.getOs() != "IE") {
helper.log_realtime("pc_download");
}
});
var btnCopy = document.querySelector("#btn-copy");
if (btnCopy) {
var clipboard = new ClipboardJS(btnCopy);
clipboard.on("success", function (e) {
btnCopy.querySelector(".tooltiptext").style.visibility = "visible";
btnCopy.querySelector(".tooltiptext").style.opacity = "1";
e.clearSelection();
});
}
});
// 页面错误处理
window.onerror = function (message) {
helper.log_error("pc_page_view", 1001, message);
};
// 1. 下载文件添加clickcode 不用管直接解析url就行会有判断
// 2. goolge script 更新 将里边的代码放在页面head里就可以
// 3. 打点 就是埋点 调用 load 下载按钮 helper.BILog("pc_page_view");

Binary file not shown.

After

Width:  |  Height:  |  Size: 186 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 346 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

284
src/index.scss 100644
View File

@ -0,0 +1,284 @@
#cookie-agreement {
position: fixed;
bottom: 0;
left: 50%;
right: 0;
transform: translateX(-50%);
max-width: 1200px;
background-color: rgba(0, 0, 0, 0.8);
.cookie-agreement__warpper {
display: flex;
align-items: center;
}
.cookie-content {
margin: 10px 10px 10px;
padding: 10px;
color: white;
font-size: 14px;
}
.rgreement-btn-box {
display: flex;
margin: 0 10px;
height: 40px;
.rgreement-btn {
border: 0;
border-radius: 4px;
width: 200px;
cursor: pointer;
font-size: 14px;
&:last-child {
margin-left: 20px;
}
&.accept {
color: #fff;
background-color: #ff8002;
}
&.customize {
border: 1px #ff8002 solid;
color: #ff8002;
background-color: transparent;
}
}
}
}
@media screen and (max-width: 1200px) {
#cookie-agreement {
width: 100%;
.cookie-agreement__warpper {
flex-direction: column;
}
.rgreement-btn-box {
width: 97%;
margin-bottom: 10px;
}
.rgreement-btn {
width: initial;
flex: 1;
}
}
}
#cookieConfirmModal {
width: 100vw;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
position: fixed;
top: 0;
left: 0;
z-index: 1000;
@media screen and (max-width: 1100px) {
#cookieBanner {
width: 70%;
}
}
#cookieBanner {
background-repeat: no-repeat;
background-size: 120% 120%;
background-position: -7px -7px;
max-width: 1200px;
padding: 10px;
font-size: 14px;
color: #1d1d1d;
position: relative;
#modalClose {
position: absolute;
top: 10px;
right: 10px;
cursor: pointer;
img {
width: 1rem;
height: 1rem;
}
}
.confirm-title {
text-align: center;
padding-bottom: 10px;
font-size: 16px;
font-weight: 600;
}
@media all and (orientation: landscape) {
.confirm-content {
height: 90px;
}
}
@media all and (orientation: portrait) {
.confirm-content {
height: 192px;
}
}
.confirm-content {
overflow: auto;
line-height: 1.5;
margin-bottom: 10px;
}
}
.footer-btn-container {
display: flex;
margin-top: 6px;
.footer-cookie-btn {
border: 0;
padding: 8px 5px;
flex: 1;
border-radius: 4px;
cursor: pointer;
flex: 1;
font-size: 14px;
&:last-child {
margin-left: 10px;
}
&.submit-accpet-all {
color: #fff;
background-color: #ff8002;
}
&.select-current {
border: 1px #ff8002 solid;
color: #ff8002;
background-color: transparent;
}
}
}
}
.cookie-item__warpper {
padding: 6px 0;
display: flex;
flex-direction: column;
align-items: center;
.cookie-item {
width: 100%;
padding-top: 6px;
border-top: 1px #aba7a7 solid;
&:nth-child(2) {
border-bottom: 1px #aba7a7 solid;
}
.item-title-container {
display: flex;
flex: 1;
align-items: center;
.item-title {
font-weight: 600;
font-size: 14px;
padding-left: 10px;
}
.item-details-img {
width: 16px;
height: 16px;
margin-left: 10px;
}
}
}
.details-tips {
width: 100%;
text-align: left;
padding-left: 16px;
font-size: 12px;
}
}
.cookie-item {
display: flex;
input[type="checkbox"].switch {
outline: none;
appearance: none;
-webkit-appearance: none;
-moz-appearance: none;
position: relative;
width: 40px;
height: 22px;
background: #ccc;
border-radius: 14px;
transition: border-color 0.3s, background-color 0.3s;
}
input[type="checkbox"].switch::after {
content: "";
display: inline-block;
width: 1rem;
height: 1rem;
border-radius: 50%;
background: #fff;
box-shadow: 0, 0, 2px, #999;
transition: 0.4s;
top: 2px;
position: absolute;
left: 3px;
}
input[type="checkbox"].switch:checked {
background: rgb(19, 206, 102);
}
input[type="checkbox"].switch:checked::after {
content: "";
position: absolute;
left: 55%;
top: 3px;
}
}
@media all and (orientation: landscape) {
}
@media all and (orientation: portrait) {
}
#cookieNotice {
width: 100vw;
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
position: fixed;
top: 0;
left: 0;
z-index: 2000;
@media all and (orientation: landscape) {
}
@media all and (orientation: portrait) {
.cookie-notice-content {
width: 80%;
}
}
.cookie-notice-content {
background-color: #999;
color: #e2e2e2;
padding: 6px;
border-radius: 10px;
}
}
.download-notice {
position: absolute;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
display: none;
background-color: rgba(0, 0, 0, .5);
z-index: 101;
pointer-events: auto;
.center-notice {
position: absolute;
top: 45%;
left: 50%;
transform: translate(-50%, -50%);
z-index: 10000;
}
}

297
src/main.js 100644
View File

@ -0,0 +1,297 @@
import cookieLanguage from "./common/cookie.json";
import { getUrlParam } from "./common/helpers";
import { asyncLoadGoogleTag } from "./common/google.tag";
import * as helper from "./common/helpers";
import "./index.scss";
function getLanguage() {
const lang = getUrlParam("lang") ?? "en";
return cookieLanguage[lang] || cookieLanguage["en"];
}
const replaceAgreementLink = (privacyContent) => {
const newString = [
"<a href='https://funplus.com/privacy-policy/' target='_blank' style='color:#ddb463'>",
"</a>",
"<a href='https://funplus.com/terms-conditions/' target='_blank' style='color:#ddb463'>",
];
return privacyContent
.replaceAll("%1", newString[0])
.replaceAll("%2", newString[1])
.replaceAll("%3", newString[2]);
};
const showCookieNotice = () => {
$("#cookieNotice").show();
setTimeout(() => {
$("#cookieNotice").hide();
}, 2000);
};
function cookieAgreementInit() {
const lang = getLanguage();
const cookieAgreement = $(`<div id="cookie-agreement"></div>`);
cookieAgreement.css("display", "none");
const cookieWarpper = $(`<div class="cookie-agreement__warpper"></div>`);
const cookieContent = $(`<div class="cookie-content"></div>`).html(
`${replaceAgreementLink(lang.footer_txt)}`
);
const cookieBtns = $(`<div class="rgreement-btn-box">
<button id="acceptAllPrivacy" class="rgreement-btn accept">${lang.footer_btn_left}</button>
<button id="customizePrivacy" class="rgreement-btn customize">${lang.footer_btn_right}</button>
</div>`);
cookieWarpper.append(cookieContent).append(cookieBtns);
cookieAgreement.append(cookieWarpper).hide();
return cookieAgreement;
}
function getCookieItem(title, tips, checked, disabled) {
const cookieItemWarpper = $(`<div class="cookie-item__warpper"></div>`);
const cookieItem = $(`<div class="cookie-item"></div>`);
const itemTitleContainer = $(`<div class="item-title-container"></div>`);
const itemTitle = $(`<div class="item-title">${title}</div>`);
const itemDetailImg = $(
`<img class="item-details-img" src="./images/details.png" />`
);
const itemSwitch = $(`<input type="checkbox" class="switch">`);
if (checked) {
itemSwitch.attr("checked", checked);
}
if (disabled) {
itemSwitch.attr("disabled", true);
}
const detailTips = $(
'<div class="details-tips" style="display:none;"></div>'
);
detailTips.text(tips);
itemTitleContainer.append(itemTitle).append(itemDetailImg);
cookieItem.append(itemTitleContainer).append(itemSwitch);
cookieItemWarpper.append(cookieItem).append(detailTips);
return cookieItemWarpper;
}
function cookieConfirmModal() {
const lang = getLanguage();
const container = $(`<div id="cookieConfirmModal"></div>`);
container.css("display", "none");
const banner = $(`<div id="cookieBanner"></div>`);
banner.css({
backgroundImage: `url(./images/modal-bg.png)`,
});
const bannerClose = $(
`<div id="modalClose"> <img src="./images/close.png" /></div>`
);
const title = $(`<div class="confirm-title">${lang.modal_title}</div>`);
const content = $(`<div class="confirm-content">${lang.modal_txt}</div>`);
const settings = $(`<div class="setting"></div>`);
// 协议 1
const cookieItem1 = getCookieItem(
lang.cookie_type_1,
lang.cookie_intro_1,
true,
true
);
const cookieItem2 = getCookieItem(
lang.cookie_type_2,
lang.cookie_intro_2,
false
);
settings.append(cookieItem1).append(cookieItem2);
// 提交
const footerBtnContainer = $(`<div class="footer-btn-container"></div>`);
const saveCurrent = $(
"<button id='selectCurrent'>" + lang.modal_btn_left + "</button>"
);
saveCurrent.addClass("footer-cookie-btn select-current");
const submitAcceptCurrent = $(
"<button id='submitAccpetAll'>" + lang.modal_btn_right + "</button>"
);
submitAcceptCurrent.addClass("footer-cookie-btn submit-accpet-all");
footerBtnContainer.append(saveCurrent).append(submitAcceptCurrent);
banner
.append(bannerClose)
.append(title)
.append(content)
.append(settings)
.append(footerBtnContainer);
container.append(banner);
return container;
}
const getNotice = () => {
const lang = getLanguage();
const cookieNotice = $(`<div id="cookieNotice"></div>`);
cookieNotice.css("display", "none");
cookieNotice.append(
`<div class="cookie-notice-content">${lang.tips_success}</div>`
);
cookieNotice.css("display", "hidden");
return cookieNotice;
};
const downloadNotice = () => {
const noticeContainer = $('<div class="download-notice"></div>');
noticeContainer.append('<div class="backdrop"></div>');
noticeContainer.append(
$(
'<div class="center-notice"><img src="https://kg-web-cdn.akamaized.net/official-website/pc-landing-builder/wp-content/themes/pc_landing/dist/images/notice-mo-en.png"/></div>'
)
);
return noticeContainer;
};
// 接受所有协议
const allPrivacyClick = () => {
helper.BILog("privacy_protocol_lp", {
privacy_action: "accept_all_cookies",
privacy_pop_style: 1,
privacy_lang: window.lang,
});
helper.consentAllGranted();
helper.setCookie("fp_opt", "all", 365);
$("#cookie-agreement").hide();
$("#cookieConfirmModal").hide();
showCookieNotice();
};
const handleAddEvents = () => {
// 接受所有协议
$("#acceptAllPrivacy").on("click", function () {
allPrivacyClick();
});
// 自定义协议
$("#customizePrivacy").on("click", function () {
$("#cookie-agreement").hide();
$("#cookieConfirmModal").show();
});
// 关闭弹框
$("#modalClose").on("click", function () {
$("#cookieConfirmModal").hide();
});
// 查看详情
$(
".cookie-item__warpper .item-details-img,.cookie-item__warpper .item-title"
).on("click", function () {
$(this).parents(".cookie-item").next().toggle(300);
});
// 开关
$(".cookie-item input[type=checkbox]").on("change", function () {
const checked = this.checked;
});
// 保存当前
$("#selectCurrent").on("click", function () {
const _checked = $(".cookie-item__warpper input[type=checkbox]")[1].checked;
// 全部同意
if (_checked) {
helper.setCookie("fp_opt", "all", 365);
helper.consentAllGranted();
helper.BILog("privacy_protocol_lp", {
privacy_action: "custom_confirm_selection",
privacy_marketing_cookie: "on",
privacy_pop_style: 1,
privacy_lang: window.lang,
});
} else {
helper.setCookie("fp_opt", "necessary", 365);
helper.BILog("privacy_protocol_lp", {
privacy_action: "custom_confirm_selection",
privacy_marketing_cookie: "off",
privacy_pop_style: 1,
privacy_lang: window.lang,
});
}
$("#cookieConfirmModal").hide();
showCookieNotice();
});
$("#submitAccpetAll").on("click", function () {
$(".cookie-item__warpper input[type=checkbox]").each(function () {
$(this).attr("checked", true);
});
allPrivacyClick();
});
$(".download-notice").on("click", function () {
$(this).hide();
});
};
const handleAddWindowLoad = () => {
window.curFF = false;
window.addEventListener("load", function () {
helper.BILog("pc_page_view");
if (helper.getOs() != "IE") {
helper.log_realtime("pc_page_view");
}
});
window.onerror = function (message) {
helper.log_error("pc_page_view", 1001, message);
};
window.downloadPackage = () => {
if (helper.getOs() === "Windows") {
helper.defaultDownload();
} else {
// Not windows, but did not enable webgame
// if (!enable_webgame) {
helper.defaultDownload();
// }
}
// Trigger BI logagent on download
helper.BILog("pc_download");
if (helper.getOs() != "IE") {
helper.log_realtime("pc_download");
}
};
};
window.page_id = 'game-1'
window.project = "mo";
// 加载google tag
asyncLoadGoogleTag();
// 加载dom
const cookieAgreementEl = cookieAgreementInit();
const confirmModalEl = cookieConfirmModal();
const noticeEl = getNotice();
const downloadNoticeEl = downloadNotice();
$("body")
.append(cookieAgreementEl)
.append(confirmModalEl)
.append(noticeEl)
.append(downloadNoticeEl);
// 监听事件
handleAddEvents();
handleAddWindowLoad();
helper.ifUseCookieConsent().then((data) => {
const currentCountry = data.data.data.location.country;
// 如果没有包含国家
if (
!helper.bannerCountriesList.includes(currentCountry) ||
helper.getCookie("fp_opt")
) {
// 直接同意所有的协议
if (helper.getCookie("fp_opt") === "all") {
helper.consentAllGranted();
}
} else {
// 包含欧盟协议,需要弹框
$("#cookie-agreement").show();
helper.BILog("privacy_protocol_lp", {
privacy_action: "window_pop#_up",
privacy_pop_style: 1,
privacy_lang: window.lang,
});
const cookieOpt = helper.getCookie("fp_opt");
if (cookieOpt === "all") {
helper.consentAllGranted();
}
}
});

38
vite.config.js 100644
View File

@ -0,0 +1,38 @@
import { defineConfig } from "vite";
import { resolve } from "path";
import copy from "rollup-plugin-copy";
export default defineConfig({
base: "./",
plugins: [
// copy({
// verbose: true,
// hook: "closeBundle",
// targets: [{ src: "readme.md", dest: "dist", rename: "readme.md" }],
// }),
],
terserOptions: {
compress: {
drop_console: true,
},
},
build: {
outDir: "dist",
emptyOutDir: true,
rollupOptions: {
input: {
main: resolve(__dirname, "index.html"),
},
output: {
entryFileNames: "[name].js",
chunkFileNames: "[name].js",
assetFileNames: `[name].[ext]`,
},
},
},
resolve: {
alias: {
"@": resolve(__dirname, "./src"),
},
},
});