Greasy Fork

Greasy Fork is available in English.

AliExpress Product Link Fixer

Fixes AliExpress product links to all point to the actual product pages instead of annoying marketing pages. No more stupid "3 in 1", "Bundle deals" or "SuperDeals" pages making ordering harder.

目前为 2024-12-21 提交的版本,查看 最新版本

// ==UserScript==
// @name         AliExpress Product Link Fixer
// @namespace    http://tampermonkey.net/
// @version      1.0
// @license      MIT
// @description  Fixes AliExpress product links to all point to the actual product pages instead of annoying marketing pages. No more stupid "3 in 1", "Bundle deals" or "SuperDeals" pages making ordering harder.
// @author       NewsGuyTor
// @match        https://*.aliexpress.com/*
// @icon         https://www.aliexpress.com/favicon.ico
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Function to fix links
    function fixLinks() {
        // Select all anchor elements on the page
        const links = document.querySelectorAll('a[href*="/gcp/"], a[href*="/ssr/"]');

        links.forEach(link => {
            const url = new URL(link.href);
            const productId = url.searchParams.get('productIds');

            if (productId) {
                // Get the current domain from the link, preserving subdomains
                const domain = url.host;

                // Update the href to point to the actual product page on the same domain
                link.href = `https://${domain}/item/${productId}.html`;
            }
        });
    }

    // Run the function on page load
    fixLinks();

    // Run the function again if the page content changes (for dynamically loaded content)
    const observer = new MutationObserver(fixLinks);
    observer.observe(document.body, { childList: true, subtree: true });
})();