Greasy Fork

来自缓存

Greasy Fork is available in English.

AI 编程订阅优惠助手(AI Coding Subscription Discount Helper)

【第三方社区插件】在顶部提示可用优惠和活动规则([Third-party community script] Shows a top banner with available discounts and promo rules.)

当前为 2026-04-22 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         AI 编程订阅优惠助手(AI Coding Subscription Discount Helper)
// @name:en      AI 编程订阅优惠助手(AI Coding Subscription Discount Helper)
// @namespace    http://tampermonkey.net/
// @version      1.2.6
// @description  【第三方社区插件】在顶部提示可用优惠和活动规则([Third-party community script] Shows a top banner with available discounts and promo rules.)
// @description:en  【第三方社区插件】在顶部提示可用优惠和活动规则([Third-party community script] Shows a top banner with available discounts and promo rules.)
// @author       YourName
// @match        *://*.bigmodel.cn/*
// @match        *://z.ai/*
// @match        *://platform.minimaxi.com/*
// @match        *://replit.com/*
// @match        *://*.qiniu.com/*
// @match        *://*.siliconflow.cn/*
// @match        *://*.volcengine.com/*
// @match        *://*.codebuddy.cn/*
// @match        *://*.xfyun.cn/*
// @run-at       document-start
// @grant        GM_addStyle
// @license      MIT
// ==/UserScript==

(function () {
    'use strict';

    const I18N = {
        zh: {
            tooltip: '第三方社区脚本,与平台官方无关联',
            badge: '第三方',
            defaultDiscountText: '当前页面有可用优惠',
            guideLinkText: '[官方活动说明] →',
            guideLinkTitle: '查看平台活动规则',
            cta: '一键使用'
        },
        en: {
            tooltip: 'Community script, not affiliated with the platform',
            badge: 'Third-party',
            defaultDiscountText: 'An offer is available on this page.',
            guideLinkText: '[Promo rules] →',
            guideLinkTitle: 'View the platform promotion rules',
            cta: 'Use now'
        }
    };

    // ==========================================
    // 配置区域:在这里配置你的各平台邀请链接
    // 可选字段:
    // - discountTextEn: 英文优惠文案
    // - guideUrlEn: 英文规则页链接(未提供时回退到 guideUrl)
    // ==========================================
    const CONFIG = {
        // 1. 智谱 GLM (国内版)
        'bigmodel.cn': {
            targetUrls: ['glm-coding', 'pay', 'pricing'],
            inviteLink: 'https://www.bigmodel.cn/glm-coding?ic=EVDHUUYDNB',
            discountText: '首次成功付费订阅且仅限于订阅【GLM Coding】服务时,可享受该订单金额5%的立减优惠',
            discountTextEn: 'First-time paid subscribers who subscribe to GLM Coding can receive an instant 5% discount on the order total.',
            buttonAction: 'url',
            guideUrl: 'https://docs.bigmodel.cn/cn/coding-plan/credit-campaign-rules'
        },
        // 2. 智谱 Z.ai (国际版)
        'z.ai': {
            targetUrls: ['pricing', 'subscribe', 'upgrade'],
            inviteLink: 'https://z.ai/subscribe?ic=TDAWEJFQ18',
            discountText: '成功支付首次订阅【GLM Coding】服务的受邀用户,将享受订单金额即时 10%的折扣!',
            discountTextEn: 'Invited users who complete their first GLM Coding subscription payment get an instant 10% discount on the order.',
            buttonAction: 'url',
            guideUrl: 'https://docs.z.ai/devpack/credit-campaign-rules',
            guideUrlEn: 'https://docs.z.ai/devpack/credit-campaign-rules'
        },
        // 3. MiniMaxi Token Plan
        'platform.minimaxi.com': {
            targetUrls: ['billing', 'pricing', 'subscription'],
            inviteLink: 'https://platform.minimaxi.com/subscribe/token-plan?code=IEQUPQdHDm&source=link',
            discountText: '通过邀请链接购买 Token Plan,可在结算时享受 9 折优惠',
            discountTextEn: 'Buy the Token Plan through the referral link to get 10% off at checkout.',
            buttonAction: 'url',
            guideUrl: 'https://platform.minimaxi.com/docs/token-plan/promotion',
            guideUrlEn: 'https://platform.minimaxi.com/docs/token-plan/promotion'
        },
        // 4. Replit
        'replit.com': {
            targetUrls: ['pricing', 'join', 'upgrade'],
            inviteLink: 'https://replit.com/join/jmuageupkm-maxusharmness',
            discountText: '订阅 Replit Core 计划,即刻获得 10 美元信用额度!',
            discountTextEn: 'Subscribe to Replit Core and receive $10 in credits instantly.',
            buttonAction: 'url',
            guideUrl: 'https://replit.com/refer',
            guideUrlEn: 'https://replit.com/refer'
        },
        // 5. 七牛云 (DeepSeek API)
        'qiniu.com': {
            targetUrls: ['topup', 'pricing', 'promotion'],
            inviteLink: 'https://s.qiniu.com/nmU7je',
            discountText: '完成首次体验及激活,即时获赠 1000 万 Token!',
            discountTextEn: 'Complete your first trial and activation to receive 10 million Tokens instantly.',
            buttonAction: 'url',
            guideUrl: 'https://www.qiniu.com/ai/promotion/invite'
        },
        // 6. 硅基流动 (SiliconFlow)
        'siliconflow.cn': {
            targetUrls: ['pricing', 'topup', 'billing'],
            inviteLink: 'https://cloud.siliconflow.cn/i/yUFjwvQd',
            discountText: '使用专属链接注册,获取全模型通用推理代金券!',
            discountTextEn: 'Register with the referral link to receive general-purpose inference coupons for all models.',
            buttonAction: 'url',
            guideUrl: 'https://cloud.siliconflow.cn/me/campaigns/inviter'
        },
        // 7. 火山引擎(方舟 Coding Plan)
        'www.volcengine.com': {
            targetUrls: ['codingplan', 'pricing', 'upgrade'],
            inviteLink: 'https://volcengine.com/L/glyaeiHZZH8/',
            discountText: '受邀下单享 9 折优惠',
            discountTextEn: 'Invited users get 10% off eligible Coding Plan orders.',
            buttonAction: 'url',
            guideUrl: 'https://www.volcengine.com/activity/codingplan'
        },
        // 8. 腾讯云 AI 代码助手 (CodeBuddy)
        'www.codebuddy.cn': {
            targetUrls: ['pricing', 'upgrade', 'profile'],
            inviteLink: 'https://www.codebuddy.cn/fission/?inviteCode=kjqyyg41iq121',
            discountText: '绑定推荐码,获赠高级模型对话次数或延长试用期!',
            discountTextEn: 'Bind the referral code to get extra premium-model chats or an extended trial period.',
            buttonAction: 'url',
            guideUrl: 'https://www.codebuddy.cn/fission/'
        },
        // 9. 讯飞星辰 Coding Plan
        'xfyun.cn': {
            targetUrls: ['packageSubscription', 'upgrade', 'profile'],
            inviteLink: 'https://maas.xfyun.cn/packageSubscription?inviteCode=MAAS-94E2A226',
            discountText: '¥19起,首月¥3.9最低门槛,被邀请人可获得支付金额等额礼品卡,可用于平台模型调用抵扣。',
            discountTextEn: 'Starting from ¥19/mo, first month as low as ¥3.9. Invitees receive a gift card equal to the payment amount, usable as credit for platform model API calls.',
            buttonAction: 'url',
            guideUrl: 'https://www.xfyun.cn/doc/spark/CodingPlanEvent.html#coding-plan-%E5%A5%BD%E5%8F%8B%E9%82%80%E8%AF%B7%E6%B4%BB%E5%8A%A8%E8%A7%84%E5%88%99'
        },
    };

    const currentHost = window.location.hostname;
    const currentHref = window.location.href;
    const preferredLocale = getPreferredLocale();
    const i18n = I18N[preferredLocale];

    function getPreferredLocale() {
        const languages = Array.isArray(navigator.languages) && navigator.languages.length
            ? navigator.languages
            : [navigator.language || ''];

        return languages.some((language) => typeof language === 'string' && language.toLowerCase().startsWith('zh'))
            ? 'zh'
            : 'en';
    }

    function getLocalizedConfigValue(config, zhKey, enKey) {
        if (!config) return '';
        if (preferredLocale === 'en' && config[enKey]) return config[enKey];
        return config[zhKey] || config[enKey] || '';
    }

    function matchesConfiguredDomain(host, domain) {
        const normalizedDomain = domain.replace(/^www\./, '');
        return host === domain
            || host.endsWith(`.${domain}`)
            || host === normalizedDomain
            || host.endsWith(`.${normalizedDomain}`);
    }

    // ==========================================
    // 推广模块:灵动鸟 (Dynamic Island) 风格,极简优雅
    // ==========================================
    window.addEventListener('DOMContentLoaded', () => {
        let matchedConfig = null;

        for (const [domain, config] of Object.entries(CONFIG)) {
            if (!matchesConfiguredDomain(currentHost, domain)) continue;
            matchedConfig = config;
            break;
        }

        if (!matchedConfig) return;
        if (sessionStorage.getItem('ai-discount-ignored')) return;

        const discountText = getLocalizedConfigValue(matchedConfig, 'discountText', 'discountTextEn') || i18n.defaultDiscountText;
        const guideUrl = getLocalizedConfigValue(matchedConfig, 'guideUrl', 'guideUrlEn');

        const widgetHtml = `
            <div id="ai-discount-island" class="ai-island-wrapper" title="${i18n.tooltip}">
                <div class="ai-island-icon">🎁</div>
                <div class="ai-island-content">
                    <div class="ai-island-text">
                        <span class="ai-island-badge">${i18n.badge}</span>
                        ${discountText}
                        ${guideUrl ? `<a href="${guideUrl}" target="_blank" rel="noopener noreferrer" class="ai-island-link" title="${i18n.guideLinkTitle}" onclick="event.stopPropagation()">${i18n.guideLinkText}</a>` : ''}
                    </div>
                    <button id="ai-island-btn" class="ai-island-btn">${i18n.cta}</button>
                    <button id="ai-island-close" class="ai-island-close">&times;</button>
                </div>
            </div>
        `;

        GM_addStyle(`
            .ai-island-wrapper {
                position: fixed;
                top: 24px;
                left: 50%;
                transform: translateX(-50%) translateY(-150%);
                z-index: 2147483647;
                display: flex;
                align-items: center;
                background: rgba(0, 0, 0, 0.85);
                backdrop-filter: blur(20px) saturate(200%);
                -webkit-backdrop-filter: blur(20px) saturate(200%);
                border: 1px solid rgba(255, 255, 255, 0.15);
                box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
                border-radius: 40px;
                padding: 6px 12px;
                height: 44px;
                box-sizing: border-box;
                font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
                color: white;
                transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1),
                            max-width 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
                overflow: hidden;
                white-space: nowrap;
                max-width: 44px;
            }
            .ai-island-wrapper.show {
                transform: translateX(-50%) translateY(0);
            }
            .ai-island-wrapper.expanded {
                max-width: 800px;
            }
            .ai-island-icon {
                font-size: 18px;
                line-height: 1;
                cursor: pointer;
                flex-shrink: 0;
            }
            .ai-island-content {
                display: flex;
                align-items: center;
                opacity: 0;
                transform: translateX(-10px);
                transition: all 0.3s ease;
                pointer-events: none;
                margin-left: 12px;
            }
            .ai-island-wrapper.expanded .ai-island-content {
                opacity: 1;
                transform: translateX(0);
                pointer-events: auto;
                transition-delay: 0.15s;
            }
            .ai-island-text {
                font-size: 13px;
                font-weight: 500;
                margin-right: 16px;
                color: #f5f5f7;
                display: flex;
                align-items: center;
            }
            .ai-island-badge {
                background: rgba(255, 152, 0, 0.2);
                color: #ffb74d;
                border: 1px solid rgba(255, 152, 0, 0.4);
                padding: 2px 6px;
                border-radius: 4px;
                font-size: 10px;
                font-weight: 700;
                margin-right: 8px;
                flex-shrink: 0;
            }
            .ai-island-link {
                color: #4ea3ff;
                text-decoration: none;
                font-size: 11px;
                margin-left: 8px;
                opacity: 0.85;
                font-weight: 400;
                transition: opacity 0.2s;
            }
            .ai-island-link:hover {
                text-decoration: underline;
                opacity: 1;
            }
            .ai-island-btn {
                background: linear-gradient(135deg, #0071e3, #4ea3ff);
                color: white;
                border: none;
                border-radius: 20px;
                padding: 6px 14px;
                font-size: 12px;
                font-weight: 600;
                cursor: pointer;
                box-shadow: 0 2px 8px rgba(0, 113, 227, 0.4);
                transition: transform 0.2s;
                flex-shrink: 0;
            }
            .ai-island-btn:hover {
                transform: scale(1.05);
            }
            .ai-island-close {
                background: transparent;
                border: none;
                color: rgba(255, 255, 255, 0.5);
                font-size: 18px;
                cursor: pointer;
                margin-left: 8px;
                padding: 0 4px;
                flex-shrink: 0;
            }
            .ai-island-close:hover {
                color: white;
            }
            @media (prefers-color-scheme: light) {
                .ai-island-wrapper {
                    background: rgba(255, 255, 255, 0.9);
                    border: 1px solid rgba(0, 0, 0, 0.1);
                    color: #1d1d1f;
                    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
                }
                .ai-island-text {
                    color: #1d1d1f;
                }
                .ai-island-badge {
                    background: rgba(230, 81, 0, 0.1);
                    color: #e65100;
                    border-color: rgba(230, 81, 0, 0.3);
                }
                .ai-island-close {
                    color: rgba(0, 0, 0, 0.4);
                }
                .ai-island-close:hover {
                    color: black;
                }
            }
        `);

        document.body.insertAdjacentHTML('beforeend', widgetHtml);

        const island = document.getElementById('ai-discount-island');
        const islandIcon = island.querySelector('.ai-island-icon');
        const closeButton = document.getElementById('ai-island-close');
        const actionButton = document.getElementById('ai-island-btn');
        let autoCollapseTimer = null;

        function expandIsland() {
            island.classList.add('expanded');
            clearTimeout(autoCollapseTimer);
            autoCollapseTimer = setTimeout(() => {
                island.classList.remove('expanded');
            }, 8000);
        }

        setTimeout(() => {
            island.classList.add('show');
            setTimeout(expandIsland, 500);
        }, 800);

        island.addEventListener('mouseenter', expandIsland);
        island.addEventListener('mouseleave', () => {
            autoCollapseTimer = setTimeout(() => {
                island.classList.remove('expanded');
            }, 3000);
        });

        closeButton.addEventListener('click', (event) => {
            event.stopPropagation();
            island.classList.remove('show');
            setTimeout(() => island.remove(), 600);
            sessionStorage.setItem('ai-discount-ignored', 'true');
        });

        actionButton.addEventListener('click', () => {
            window.location.href = matchedConfig.inviteLink;
        });

        islandIcon.addEventListener('click', expandIsland);
    });
})();