Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (() => {
- let e;
- function t() {
- const e = document.querySelectorAll(".pwa-install-like-app");
- e.length > 0 && e.forEach((e => {
- e.remove()
- }))
- }
- function instPwa() {
- const e = document.querySelectorAll(".pwa-install-like-app");
- e.length > 0 && e.forEach((e => {
- e.click()
- }))
- }
- window.addEventListener("load", (() => {
- if ("serviceWorker" in navigator) try {
- navigator.serviceWorker.register("/local/assets/js/pwa-worker.js")
- } catch (e) {
- console.log("Service worker register fail")
- }
- //instPwa();
- $("#pwa-install").click();
- })), window.addEventListener("DOMContentLoaded", (() => {
- let e = "browser tab";
- window.matchMedia("(display-mode: standalone)").matches && (e = "standalone", t()), console.log("DISPLAY_MODE_LAUNCH:", e)
- })), window.addEventListener("beforeinstallprompt", (t => {
- // TODO
- alert("beforeinstallprompt");
- t.preventDefault(), e = t,
- function() {
- const t = document.querySelectorAll(".pwa-install-like-app");
- t.length > 0 && t.forEach((t => {
- t.addEventListener("click", (async () => {
- //console.log(e.prompt());
- //console.log(e.userChoice);
- e.prompt(), "accepted" === await e.userChoice && console.log("User accepted the A2HS prompt")
- }));
- }))
- }(), console.log("beforeinstallprompt event was fired");
- //instPwa();
- $("#pwa-install").click();
- })), window.addEventListener("appinstalled", (() => {
- t(), e = null, console.log("PWA was installed")
- }));
- })();
- $(function(){
- $("#pwa-install").click();
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement