deAMP

AMP sucks, thus no AMP thanks.

目前为 2022-09-01 提交的版本。查看 最新版本

// ==UserScript==
// @name               deAMP
// @description        AMP sucks, thus no AMP thanks.
// @author             Jason Kwok
// @namespace          https://jasonhk.dev/
// @version            1.0.0
// @license            MIT
// @match              http*://*/*
// @run-at             document_end
// @grant              none
// ==/UserScript==

const isAmp = (document.querySelector("html[⚡], html[amp]") !== null);
const canonical = document.head.querySelector("link[rel=canonical][href]");

if (isAmp && (canonical !== null))
{
    const lastVisit = sessionStorage.getItem("deAmp.lastVisit");

    if (location.href !== lastVisit)
    {
        sessionStorage.setItem("deAmp.lastVisit", location.href);
        location.replace(canonical.href);
    }
    else
    {
        sessionStorage.removeItem("deAmp.lastVisit");
    }
}
else
{
    console.debug("[deAMP] Not a valid AMP page.");
    sessionStorage.removeItem("deAmp.lastVisit");
}

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址