Greasy Fork 支持简体中文。

Redirect WordPress Plugins to Instawp

Redirect WordPress plugin links to Instawp.io

目前為 2023-07-27 提交的版本,檢視 最新版本

// ==UserScript==
// @name         Redirect WordPress Plugins to Instawp
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Redirect WordPress plugin links to Instawp.io
// @author       You
// @include      https://wordpress.org/plugins/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Function to redirect the URL to Instawp.io
    function redirectToInstawp(url) {
        var instawpURL = url.replace("https://wordpress.org/plugins/", "https://instawp.io/plugins/");
        window.location.href = instawpURL;
    }

    // Create a button element
    var redirectButton = document.createElement("button");
    redirectButton.textContent = "InstaWP";
    redirectButton.style.padding = "6px 20px";
    redirectButton.style.backgroundColor = "#005E54";
    redirectButton.style.color = "#fff";
    redirectButton.style.border = "1px solid #000";
    redirectButton.style.borderRadius = "3px";
    redirectButton.style.cursor = "pointer";
    redirectButton.style.transition = "background-color 0.3s ease";
    redirectButton.style.marginLeft = "20px";
    redirectButton.style.fontSize = "14.4px";

    // Add CSS hover effect
    redirectButton.addEventListener("mouseenter", function() {
        redirectButton.style.backgroundColor = "#337E76";
    });
    redirectButton.addEventListener("mouseleave", function() {
        redirectButton.style.backgroundColor = "#005E54";
    });

    // Add a click event listener to the button
    redirectButton.addEventListener("click", function() {
        // Get the current URL and redirect to Instawp
        redirectToInstawp(window.location.href);
    });

    // Find the "Download" button
    var downloadButton = document.querySelector('.plugin-actions a.plugin-download');

    // Insert the new button after the "Download" button
    if (downloadButton) {
        downloadButton.parentNode.insertBefore(redirectButton, downloadButton.nextSibling);
    }
})();