[WORKING] Unlock any Medium Article

Unlock any paid article from Medium by using Freedium, works with custom domains too

目前為 2024-09-27 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         [WORKING] Unlock any Medium Article
// @namespace    https://github.com/insign
// @version      202409271723
// @description  Unlock any paid article from Medium by using Freedium, works with custom domains too
// @author       Hélio <[email protected]>
// @match        *://*/*
// @grant        none
// @license      WTFPL
// ==/UserScript==

(function() {
    'use strict';

    // Função para verificar a presença da meta tag específica
    function isMediumArticle() {
        return document.querySelector('meta[data-rh="true"][property="al:ios:app_name"][content="Medium"]') !== null;
    }

    // Função para realizar o redirecionamento
    function redirectToFreedium() {
        // Obtém a URL atual
        var currentURL = window.location.href;

        // Verifica se já não está na URL do Freedium para evitar loop
        if (!currentURL.startsWith('https://freedium.cfd/')) {
            // Cria a nova URL redirecionada
            var freediumURL = 'https://freedium.cfd/' + currentURL;

            // Redireciona para a nova URL
            window.location.replace(freediumURL);
        }
    }

    // Função principal que controla o fluxo
    function main() {
        // Verifica se a página é um artigo do Medium
        if (isMediumArticle()) {
            // Obtém o referenciador (a página anterior que o usuário veio)
            var referrer = document.referrer;

            var shouldRedirect = true;

            if (referrer) {
                try {
                    // Analisa a URL do referenciador para obter o hostname
                    var referrerHost = (new URL(referrer)).hostname;

                    // Verifica se o referenciador é freedium.cfd
                    if (referrerHost === 'freedium.cfd') {
                        shouldRedirect = false; // Não redireciona se veio do Freedium
                    }
                } catch (e) {
                    // Se não for possível analisar o referenciador, continua com o redirecionamento
                    console.error('Erro ao analisar o referenciador:', e);
                }
            }

            if (shouldRedirect) {
                redirectToFreedium();
            }
        }
    }

    // Executa a função principal quando o conteúdo do documento estiver carregado
    if (document.readyState === 'complete' || document.readyState === 'interactive') {
        setTimeout(main, 1);
    } else {
        document.addEventListener('DOMContentLoaded', main);
    }
})();