Udemy Express Checkout Link Generator

Adds a direct express checkout link for Udemy courses with coupon codes

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Udemy Express Checkout Link Generator
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Adds a direct express checkout link for Udemy courses with coupon codes
// @author       ikigaiDH
// @match        https://www.udemy.com/course/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=udemy.com
// @grant        none
// @license      GPL-3.0-only
// ==/UserScript==

(function() {
    'use strict';

    function createExpressCheckoutLink(courseId, couponCode) {
        const link = document.createElement('a');
        link.href = `https://www.udemy.com/payment/checkout/express/course/${courseId}/?discountCode=${couponCode}`;
        link.textContent = '⚡ Express Checkout';
        link.style.position = 'fixed';
        link.style.top = '75px';
        link.style.right = '10px';
        link.style.zIndex = '9999';
        link.style.backgroundColor = '#3e4143';
        link.style.color = 'white';
        link.style.padding = '12px 20px';
        link.style.borderRadius = '4px';
        link.style.fontWeight = 'bold';
        link.style.textDecoration = 'none';
        link.style.boxShadow = '0 2px 8px rgba(0,0,0,0.2)';
        link.style.fontFamily = 'Arial, sans-serif';
        link.style.fontSize = '14px';
        link.style.cursor = 'pointer';
        link.addEventListener('mouseover', () => {
            link.style.backgroundColor = '#A9A5A5';
        });
        link.addEventListener('mouseout', () => {
            link.style.backgroundColor = '#3e4143';
        });

        document.body.appendChild(link);
    }

    function extractCouponCode() {
        const urlParams = new URLSearchParams(window.location.search);
        return urlParams.get('couponCode');
    }

    function init() {
        const courseElement = document.querySelector('[data-clp-course-id]');
        const couponCode = extractCouponCode();

        if (courseElement && couponCode) {
            const courseId = courseElement.dataset.clpCourseId;
            createExpressCheckoutLink(courseId, couponCode);
        }
    }

    // Wait for page to load completely
    window.addEventListener('load', init);
})();