PWA Manifest

Turn any site into a PWA

当前为 2025-11-28 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        PWA Manifest
// @namespace   Violentmonkey Scripts
// @match       *://*/*
// @grant       none
// @version     1.0
// @author      LieFlatandSleep
// @description Turn any site into a PWA
// ==/UserScript==

function getSiteName() {
    const title = document.title?.trim();
    if (title && title.length > 0) return title;

    const host = window.location.hostname
        .replace(/^www\./, '')
        .replace(/\.[^.]+$/, ''); 

    return host.charAt(0).toUpperCase() + host.slice(1);
}

const siteName = encodeURIComponent(getSiteName());


const manifestLink = document.createElement('link');
manifestLink.rel = 'manifest';
manifestLink.href = `https://api.lowtechguys.com/manif?name=${siteName}`;


const head = document.head || document.getElementsByTagName('head')[0];


if (head) {
    head.appendChild(manifestLink);
    console.log('Manifest injected for:', siteName);
} else {
    // If head doesn't exist yet, wait for it
    new MutationObserver((mutations, observer) => {
        const h = document.head;
        if (h) {
            h.appendChild(manifestLink);
            console.log('Manifest injected (late) for:', siteName);
            observer.disconnect();
        }
    }).observe(document.documentElement, { childList: true, subtree: true });
}