Redirect Medium URLs

Add a button at the beginning of the body on medium.com to redirect to a modified URL

目前為 2024-04-15 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Redirect Medium URLs
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Add a button at the beginning of the body on medium.com to redirect to a modified URL
// @author       Your name
// @match        *://*/*
// @grant        none

// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    // Function to check if the page is on Medium
    function isMedium() {
        var metaTags = document.querySelectorAll('meta[name="twitter:app:name:iphone"]');
        return metaTags.length > 0 && metaTags[0].getAttribute('content') === 'Medium';
    }

    // Check if the current page is Medium
    if (isMedium()) {
        // Create a button element
        var redirectButton = document.createElement('button');
        redirectButton.textContent = 'Read on Medium-Free';
        redirectButton.style.position = 'fixed';
        redirectButton.style.top = '20px';
        redirectButton.style.left = '20px';
        redirectButton.style.zIndex = '9999';
        redirectButton.style.padding = '10px';
        redirectButton.style.backgroundColor = '#007bff';
        redirectButton.style.color = '#fff';
        redirectButton.style.border = 'none';
        redirectButton.style.borderRadius = '5px';
        redirectButton.style.cursor = 'pointer';

        // Get the current URL
        var currentUrl = window.location.href;

        // Modify the URL
        var redirectUrl = "https://medium-free.vercel.app/read?url=" + encodeURIComponent(currentUrl);

        // Add click event listener to redirect the page
        redirectButton.addEventListener('click', function() {
            window.location.href = redirectUrl;
        });

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