Unlock All Medium.com Blogs

Bypass all medium blogs paywall (external domains and subdomains too)

// ==UserScript==
// @name         Unlock All Medium.com Blogs
// @description  Bypass all medium blogs paywall (external domains and subdomains too)
// @version      1.1
// @match        *://*/*
// @author       SH3LL
// @license      MIT
// @namespace https://greasyfork.org/users/762057
// ==/UserScript==

(function() {
    'use strict';

    // Medium tag hook
    const mediumTag = document.querySelector('meta[data-rh="true"][property="og:site_name"][content="Medium"]');
    // Check the tag
    if (mediumTag) {
        console.log("Medium.com TAG Found");

        const authorTag1 = document.querySelector('meta[data-rh="true"][name="author"]')
        const authorTag2 = document.querySelector('meta[property="article:author"]')
        if (authorTag1 || authorTag2) {
            const unlocked_page="https://medium.rest/query-by-url?urlPost="+window.location.href;
            console.log("Redirection to: "+unlocked_page);
            window.location.href=unlocked_page;
        } else {
            console.log("Medium.com AUTHOR TAG Not Found. Not Redirected !");
        }
    } else {
        console.log("Medium.com BLOG TAG Not Found. Not Redirected !");
    }

    // Change the background color of medium.rest
    if(window.location.href.includes("medium.rest")){
        document.body.style.backgroundImage = 'none';
    }
})();