Greasy Fork

Medium to Freedium

Freedium: Your paywall breakthrough for Medium!

当前为 2025-03-15 提交的版本,查看 最新版本

// ==UserScript==
// @name         Medium to Freedium
// @namespace    http://tampermonkey.net/
// @version      2.0.0
// @description  Freedium: Your paywall breakthrough for Medium!
// @author       Diegiwg
// @match        https://medium.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=freedium.cfd
// @grant        none
// @run-at       document-end
// ==/UserScript==

(function() {
    'use strict';

    function replaceHomepageLinkWithButton(functionToExecute) {
        const homepageLink = document.querySelector('[aria-label="Homepage"]');

        if (homepageLink) {
            const newButton = document.createElement('button');

            newButton.className = homepageLink.className;
            newButton.innerHTML = "Medium to Freedium";
            newButton.style = "color: rgb(18 102 49); font-size: 2rem;"

            newButton.addEventListener('click', functionToExecute);

            homepageLink.replaceWith(newButton);
        } else {
            console.log('Element with aria-label "Homepage" not found.');
        }
    }

    function yourFunctionToExecute() {
        window.location.href = 'https://freedium.cfd/' + window.location.href;
    }

    replaceHomepageLinkWithButton(yourFunctionToExecute);
})();