deAMP

AMP sucks, thus no AMP thanks.

18.08.2023 itibariyledir. En son verisyonu görün.

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

You will need to install an extension such as Tampermonkey to install this script.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği indirebilmeniz için ayrıca Tampermonkey gibi bir eklenti kurmanız gerekmektedir.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name               deAMP
// @name:zh-TW         deAMP
// @description        AMP sucks, thus no AMP thanks.
// @description:zh-TW  垃圾 AMP,好走不送。
// @author             Jason Kwok
// @namespace          https://jasonhk.dev/
// @version            2.1.0
// @license            MIT
// @match              http*://*/*
// @run-at             document_end
// @grant              GM_getValue
// @grant              GM_setValue
// @require            https://cdn.jsdelivr.net/npm/[email protected]/uuid-random.min.js
// @supportURL         https://greasyfork.org/scripts/450569/feedback
// ==/UserScript==

const SESSION_KEY = getSessionKey();

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(SESSION_KEY);

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

    sessionStorage.removeItem(SESSION_KEY);
}


function getSessionKey()
{
    const key = GM_getValue("SESSION_KEY");
    if (key) { return key; }

    GM_setValue("SESSION_KEY", uuid());
    return getSessionKey();
}