medium bypass

bypass medium paywall by using archive.is

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         medium bypass
// @namespace    http://tampermonkey.net/
// @version      0.0.2
// @description  bypass medium paywall by using archive.is
// @author       The DT
// @match        https://*/*
// @icon         https://github.com/thedtvn/thedtvn/raw/main/trace.svg?raw=true
// @grant        none
// @license      Apache License 2.0
// ==/UserScript==

(async function() {
    'use strict';

    // archive.is Part
    if (location.href.match(/^https?:\/\/archive\.is\/[a-zA-Z0-9]{5}/)) {
        let container = document.body;
        let clone_div = document.getElementById("CONTENT");
        let clone_input_header = document.querySelector('[name="q"]');
        console.log(clone_input_header);
        for (let i of document.querySelectorAll("a")) {
            if (i.href.startsWith("https://archive.is/o/")) {
                i.href = i.href.replace(/^https?:\/\/archive\.is\/o\/[a-zA-Z0-9]{5}\//, "");
            }
            i.removeAttribute("target");
        }
        container.innerHTML = "";
        clone_div.style = "";
        clone_input_header.style = "text-align: center;"
        clone_input_header.style.width = "100%";
        container.style = "overflow-x: hidden; margin: 0px;"
        container.insertBefore(clone_div, container.firstChild);
        container.insertBefore(clone_input_header, container.firstChild);
        document.getElementById("hashtags").remove()
        let dialog_box = document.querySelector('[role="dialog"]');
        if (!dialog_box) return
        dialog_box.remove()
        return
    }

    // Medium Part
    function check_is_pre() {
        let elm = document.querySelector('[type="application/ld+json"]');
        if (!elm) return false
        let json_data_str = elm.innerText;
        let json_data = JSON.parse(json_data_str);
        return !json_data.isAccessibleForFree;
    }
    function check() {
        let is_pre = check_is_pre();
        if (!is_pre) return
        let pageurl = location.href;
        let url_obj = new URL("https://archive.is/submit/");
        url_obj.searchParams.set("submitid", "");
        url_obj.searchParams.set("url", pageurl);
        location.replace(url_obj.href);
    }
    let is_site_meta = document.querySelector('meta[property="og:site_name"]');
    if (!is_site_meta) return
    let is_medium = is_site_meta.content == "Medium";
    if (!is_medium) return
    window.addEventListener("load", check);
    window.addEventListener("pushState", async (event) => {
        await new Promise(r => setTimeout(r, 1000));
        check()
    });
})();