Break medium wall!

Adds a button to redirect Medium articles to freedium.cfd

当前为 2024-06-18 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Break medium wall!
// @namespace    http://tampermonkey.net/
// @version      1.1
// @license MIT 
// @description  Adds a button to redirect Medium articles to freedium.cfd
// @author       biganthonymo
// @match        *://*.medium.com/*
// @match        *://*.towardsdatascience.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Create the button
    var button = document.createElement("button");
    button.innerHTML = '<img src="https://cdn.iconscout.com/icon/free/png-512/free-hammer-252-444777.png" style="width: 26px; height: 26px; vertical-align: middle; margin-right: 8px;">Break the medium wall!';
    button.style.position = "fixed";
    button.style.top = "50%";
    button.style.right = "10px";
    button.style.zIndex = "10000";
    button.style.padding = "10px 20px";
    button.style.backgroundColor = "#f66";
    button.style.color = "#fff";
    button.style.border = "none";
    button.style.borderRadius = "5px";
    button.style.cursor = "pointer";
    button.style.fontSize = "16px";
    button.style.boxShadow = "0px 0px 10px rgba(0, 0, 0, 0.5)";
    button.style.display = "flex";
    button.style.alignItems = "center";

    // Add the button to the body
    document.body.appendChild(button);

    // Add click event to the button
    button.addEventListener("click", function() {
        var currentUrl = window.location.href;
        var domainPattern = /^(?:https?:\/\/)?(?:[^@\n]+@)?(?:www\.)?([^:\/\n\?\=]+)/im;
        var domain = currentUrl.match(domainPattern)[1];
        if (domain.endsWith("medium.com") || domain.endsWith("towardsdatascience.com")) {
            var freeURL = "https://freedium.cfd/" + currentUrl;
            window.location.href = freeURL;
        } else {
            alert("This link is not under medium.com or towardsdatascience.com");
        }
    });
})();