revert(ui): drop the Samsung Internet install notice
The banner is not wanted on the page. Remove ui/install-tip.js, its container in index.html, the startup call, the .notice styles and the PRECACHE entry; keep the documented fact (install from Chrome) in AGENTS.md/README instead. VERSION 2026.11.24.7. Verified with a SamsungBrowser UA at 360px: no banner, no .notice nodes, hero follows the header, installabilityErrors [].
This commit is contained in:
1 parent
2edbc39805
commit
aead0bb6e5
8 files changed
+4
-146
No files matched your search
@@ -7,7 +7,6 @@ import { countUpInside, initMotion, initReveal } from "./motion.js";
|
||||
import { homeView } from "./views/home.js";
|
||||
import { adminView } from "./views/admin.js";
|
||||
import { privacyView } from "./views/privacy.js";
|
||||
import { initInstallTip } from "./install-tip.js";
|
||||
import "./pwa.js";
|
||||
|
||||
const main = document.getElementById("main");
|
||||
@@ -79,7 +78,6 @@ async function boot() {
|
||||
defineRoutes({ "/": homeView, "/admin": adminView, "/privacy": privacyView }, "/");
|
||||
onRouteChange(renderRoute);
|
||||
startRouter();
|
||||
initInstallTip();
|
||||
|
||||
if (result.source === "cache") {
|
||||
toast("เปิดแบบออฟไลน์ — แสดงข้อมูลที่บันทึกไว้ในเครื่อง");
|
||||
|
||||
@@ -1,97 +0,0 @@
|
||||
/* install-tip.js — แนะนำทางติดตั้งที่ผ่านการตรวจของระบบ
|
||||
*
|
||||
* ทำไมต้องมี: Samsung Internet สร้าง WebAPK ด้วย targetSdkVersion เก่า ทำให้ Android 14+
|
||||
* (One UI 9 / Android 16) ขึ้นกล่อง Google Play Protect ว่า "แอปสร้างสำหรับ Android รุ่นเก่า
|
||||
* และไม่มีการป้องกันความเป็นส่วนตัวล่าสุด" แล้วบล็อกการติดตั้ง — เป็นปัญหาของตัวเบราว์เซอร์
|
||||
* ไม่ใช่ของเว็บ (Chrome บนเครื่องเดียวกันติดตั้งได้ปกติ)
|
||||
* → ตรวจ UA แล้วพาไปติดตั้งผ่าน Chrome แทน พร้อมคัดลอกลิงก์ไว้เปิดเอง
|
||||
*/
|
||||
|
||||
const DISMISS_KEY = "hobbypj.install.tip.dismissed.v1";
|
||||
|
||||
function isSamsungInternet() {
|
||||
return /SamsungBrowser\//i.test(navigator.userAgent);
|
||||
}
|
||||
|
||||
function isStandalone() {
|
||||
return (
|
||||
window.matchMedia("(display-mode: standalone)").matches ||
|
||||
window.matchMedia("(display-mode: minimal-ui)").matches ||
|
||||
navigator.standalone === true
|
||||
);
|
||||
}
|
||||
|
||||
function isAndroid() {
|
||||
return /Android/i.test(navigator.userAgent);
|
||||
}
|
||||
|
||||
/** intent เปิดลิงก์เดียวกันด้วย Chrome (ถ้าเครื่องมี Chrome) */
|
||||
function chromeIntent(url) {
|
||||
const clean = url.replace(/^https?:\/\//i, "");
|
||||
return `intent://${clean}#Intent;scheme=https;package=com.android.chrome;end`;
|
||||
}
|
||||
|
||||
function dismissed() {
|
||||
try {
|
||||
return localStorage.getItem(DISMISS_KEY) === "1";
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function rememberDismissed() {
|
||||
try {
|
||||
localStorage.setItem(DISMISS_KEY, "1");
|
||||
} catch {
|
||||
/* เก็บไม่ได้ก็ไม่เป็นไร */
|
||||
}
|
||||
}
|
||||
|
||||
/** เรียกตอนบูต — แสดงคำแนะนำเฉพาะ Samsung Internet ที่ยังไม่ได้ติดตั้ง */
|
||||
export function initInstallTip() {
|
||||
if (!isAndroid() || !isSamsungInternet() || isStandalone() || dismissed()) return null;
|
||||
const host = document.getElementById("install-tip");
|
||||
if (!host) return null;
|
||||
|
||||
const currentUrl = location.href;
|
||||
host.innerHTML = `
|
||||
<div class="notice" role="status">
|
||||
<div class="notice__body">
|
||||
<p class="notice__title">ติดตั้งผ่าน Samsung Internet ยังถูกบล็อก</p>
|
||||
<p class="notice__text">
|
||||
Android ขึ้นเตือนว่า “ไม่มีการป้องกันความเป็นส่วนตัวล่าสุด” เพราะ Samsung Internet
|
||||
สร้างแพ็กเกจติดตั้งเวอร์ชันเก่า (ไม่ใช่ปัญหาของเว็บนี้) — เปิดลิงก์เดียวกันด้วย Chrome
|
||||
แล้วเลือก “ติดตั้งแอป” จะติดตั้งได้ปกติ
|
||||
</p>
|
||||
<div class="notice__actions">
|
||||
<a class="btn btn--primary btn--sm" href="${chromeIntent(currentUrl)}">เปิดด้วย Chrome</a>
|
||||
<button class="btn btn--quiet btn--sm" type="button" data-act="copy">คัดลอกลิงก์</button>
|
||||
<button class="btn btn--quiet btn--sm" type="button" data-act="dismiss">ปิดข้อความนี้</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
host.hidden = false;
|
||||
|
||||
host.addEventListener("click", async (event) => {
|
||||
const action = event.target.closest("[data-act]")?.dataset.act;
|
||||
if (!action) return;
|
||||
if (action === "dismiss") {
|
||||
rememberDismissed();
|
||||
host.hidden = true;
|
||||
host.replaceChildren();
|
||||
return;
|
||||
}
|
||||
if (action === "copy") {
|
||||
try {
|
||||
await navigator.clipboard.writeText(currentUrl);
|
||||
event.target.textContent = "คัดลอกแล้ว";
|
||||
} catch {
|
||||
/* Safari/เบราว์เซอร์ที่ไม่ให้ clipboard — ผู้ใช้คัดลอกจาก address bar เองได้ */
|
||||
window.prompt("คัดลอกลิงก์นี้ไปเปิดใน Chrome", currentUrl);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return host;
|
||||
}
|
||||
Reference in new issue
Block a user