heardic 发表于 2025-12-24 00:12:23

阿里云CDN白嫖到2051年、华为云Versatile白嫖到2034年全自动续费脚本

阿里云CDN能白嫖到2051年
1、进去选择免费版、不要选择基础款或其他,付费0元购买。
2、进入套餐管理页面,设置续费规则,弹出的页面选续费一年,支付0元。
3、每次续费一年,重复执行25次,领满到2050年,结束。
注意:需要把脚本中 const newUrl = ‘https://common-buy.aliyun.com/?orderType=RENEW&commodityCode=dcdn_dcdnserviceplan_public_cn&instanceId=esa-site-b09w1w6r9zpc%E2%80%99
替换为自己的续费购买页面链接

static/image/hrline/5.gif
华为云 Versatile 平台(免费版)每次可续费 1 个月,支付金额 0 元,可以续费到 2034 年(120 次续费)
由于平台产品升级维护中,目前已临时关闭自行订阅通道。需进入官方微信群进行申请开通:https://bbs.huaweicloud.com/forum/thread-0293199360683166027-1-1.html
确保账户已开通 Versatile
进入华为云续费管理页面确认有 Versatile 实例。

// ==UserScript==
// @name         华为云自动续费助手
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description自动点击华为云续费管理页面的 "续费"、"去支付" 按钮
// @author       You
// @match      https://account.huaweicloud.com/usercenter/*
// @grant      window.close
// @grant      GM_openInTab
// @run-at       document-idle
// ==/UserScript==

(function () {
    'use strict';

    console.log('[华为云助手] 脚本已启动');

    // 配置项
    const CONFIG = {
      retryInterval: 500, // 重试间隔 (ms)
      maxAttempts: 60,    // 最大重试次数 (30秒)
    };

    /**
   * 等待元素出现
   * @param {string} selector CSS选择器
   * @param {string|null} textContent 包含的文本 (可选)
   * @returns {Promise<Element>}
   */
    function waitForElement(selector, textContent = null) {
      return new Promise((resolve, reject) => {
            let attempts = 0;

            const check = () => {
                attempts++;
                const elements = document.querySelectorAll(selector);

                for (const elem of elements) {
                  // 如果指定了文本,检查文本内容是否包含;否则直接返回第一个匹配项
                  if (!textContent || (elem.textContent && elem.textContent.includes(textContent))) {
                        console.log(`[华为云助手] 找到元素: ${selector} "${textContent || ''}"`);
                        resolve(elem);
                        return;
                  }
                }

                if (attempts >= CONFIG.maxAttempts) {
                  console.warn(`[华为云助手] 未找到元素: ${selector} "${textContent || ''}"`);
                  reject(new Error(`未找到元素: ${selector}`));
                } else {
                  setTimeout(check, CONFIG.retryInterval);
                }
            };

            check();
      });
    }

    /**
   * 点击元素并记录
   */
    async function clickElement(element, description) {
      console.log(`[华为云助手] 点击: ${description}`);
      element.click();
      await delay(1000);
    }

    function delay(ms) {
      return new Promise(resolve => setTimeout(resolve, ms));
    }

    // --- 页面处理逻辑 ---

    // 1. 续费管理页面 (Renewal Management)
    async function handleRenewalPage() {
      console.log('[华为云助手] 正在执行续费管理页面逻辑...');
      
      try {
            // 方案1: 使用 ID 选择器(更精确)
            let renewBtn = null;
            
            try {
                // 尝试通过 ID 模式匹配(匹配包含 "_renew" 的 span)
                renewBtn = await waitForElement('span', '续费');
            } catch (e) {
                console.log('[华为云助手] 未找到 ID 匹配的续费按钮,尝试备用选择器...');
                // 方案2: 使用 class 组合选择器
                renewBtn = await waitForElement('.ti3-action-menu-item.ng-star-inserted', '续费');
            }
            
            if (renewBtn) {
                await clickElement(renewBtn, '续费按钮');
                console.log('[华为云助手] ✅ 续费页面操作完成,等待进入购买页...');
            }
      } catch (error) {
            console.error('[华为云助手] ❌ 续费页面执行出错:', error);
      }
    }

    // 2. 购买/确认页面 (Buy Page)
    async function handleBuyPage() {
      console.log('[华为云助手] 正在执行购买/配置页面逻辑...');
      try {
            // 用户验证过的"1个月"按钮选择器
            const durationBtn = await waitForElement('.item-box.ng-star-inserted', '1个月');
            if (durationBtn) {
                await clickElement(durationBtn, '时长选择(1个月)');
            }

            // 等待价格刷新
            await delay(1500);

            // 用户验证过的"去支付"按钮选择器
            const submitBtn = await waitForElement('#submit_bnt_renew', '去支付');
            if (submitBtn) {
                await clickElement(submitBtn, '去支付按钮');
                console.log('[华为云助手] ✅ 购买配置完成,等待进入支付页...');
            }
      } catch (error) {
         console.error('[华为云助手] ❌ 购买/支付页面执行出错:', error);
      }
    }

    // 3. 支付收银台 (Cashier)
    async function handlePaymentPage() {
         console.log('[华为云助手] 正在执行支付页面逻辑...');
         try {
            // 直接查找 #payconfirm 按钮
            const confirmBtn = await waitForElement('#payconfirm', '确认付款');

            if (confirmBtn) {
                await clickElement(confirmBtn, '确认付款按钮');
                console.log('[华为云助手] ✅ 支付操作完成');
               
                // 等待支付处理完成
                await delay(2000);
               
                // 查找并点击"返回续费管理"按钮
                console.log('[华为云助手] 查找"返回续费管理"按钮...');
                try {
                  const returnBtn = await waitForElement('#toMyRenew', '返回续费管理');
                  if (returnBtn) {
                        await clickElement(returnBtn, '返回续费管理按钮');
                        console.log('[华为云助手] ✅ 已返回续费管理页面');
                        
                        // 等待页面跳转完成
                        await delay(2000);
                        
                        // 刷新页面以更新资源状态
                        console.log('[华为云助手] 刷新页面以更新资源状态...');
                        location.reload();
                  }
                } catch (e) {
                  console.log('[华为云助手] 未找到返回按钮,可能已自动跳转');
                }
            }
         } catch (e) {
             console.error('[华为云助手] ❌ 未找到支付收银台按钮:', e);
         }
    }

    // --- 路由控制 ---

    function router() {
      const url = window.location.href;
      const hash = window.location.hash;
      console.log('[华为云助手] 当前 URL:', url);
      console.log('[华为云助手] 当前 Hash:', hash);

      // 检查页面上是否存在关键元素来判断页面类型
      const hasPayConfirmBtn = document.querySelector('#payconfirm');
      const hasRenewalTable = document.querySelector('');
      const hasSubmitRenewBtn = document.querySelector('#submit_bnt_renew');

      console.log('[华为云助手] 页面元素检测:', {
            hasPayConfirmBtn: !!hasPayConfirmBtn,
            hasRenewalTable: !!hasRenewalTable,
            hasSubmitRenewBtn: !!hasSubmitRenewBtn
      });

      // 优先级1: 支付页面(通过元素检测)
      if (hasPayConfirmBtn) {
            console.log('[华为云助手] 检测到支付页面(通过 #payconfirm 元素)');
            handlePaymentPage();
      }
      // 优先级2: 购买配置页面(通过元素检测)
      else if (hasSubmitRenewBtn) {
            console.log('[华为云助手] 检测到购买配置页面(通过 #submit_bnt_renew 元素)');
            handleBuyPage();
      }
      // 优先级3: 续费管理页面(通过 URL 或元素检测)
      else if (url.includes('/userindex/renewalManagement') || hash.includes('renewalManagement') || hasRenewalTable) {
            console.log('[华为云助手] 检测到续费管理页面');
            handleRenewalPage();
      }
      // 备用:通过 URL 关键词判断
      else if (url.includes('common-buy') || url.includes('order')) {
            console.log('[华为云助手] 通过 URL 检测到购买页面');
            handleBuyPage();
      }
      else if (url.includes('pay') || url.includes('cashier')) {
            console.log('[华为云助手] 通过 URL 检测到支付页面');
            handlePaymentPage();
      }
      else {
            console.log('[华为云助手] 未匹配到任何已知页面类型');
      }
    }

    // --- 启动 & 监听 ---

    // 1. 立即执行一次
    if (document.readyState === 'loading') {
      document.addEventListener('DOMContentLoaded', router);
    } else {
      router();
    }

    // 2. 监听 URL 变化 (针对单页应用 SPA)
    let lastUrl = location.href;
    new MutationObserver(() => {
      const url = location.href;
      if (url !== lastUrl) {
            lastUrl = url;
            console.log('[华为云助手] URL 变化检测:', url);
            // URL 变化后等待一点时间让 DOM 渲染
            setTimeout(router, 1500);
      }
    }).observe(document, {subtree: true, childList: true});

})();

在油猴安装好脚本后,打开https://account.huaweicloud.com/usercenter/?locale=zh-cn#/userindex/renewalManagement
脚本会自动执行以下流程:点击 “续费” 按钮
选择 “1个月” 时长
点击 “去支付”
点击 “确认付款”(0 元)
点击 “返回续费管理”
刷新页面,重复上述流程也可以打开浏览器控制台(F12),查看脚本执行日志:[华为云助手] 脚本已启动
[华为云助手] 检测到续费管理页面
[华为云助手] 找到元素: span "续费"
[华为云助手] 点击: 续费按钮
...祝大家白嫖愉快!{:deyi:}

倒霉鬼 发表于 2025-12-24 01:32:32

不错,谢谢{:huaixiao:}

lvyulong 发表于 2025-12-24 03:03:03


厉害兄弟

yroiwueiorqwuei 发表于 2025-12-24 08:03:27

阿里云cdn免费版给多少资源?

Xina 发表于 2025-12-24 08:08:25

谢谢分享

annad 发表于 2025-12-24 09:45:30

感谢分享,脚本很好用

Rurune 发表于 2025-12-25 15:16:41

感谢分享,收藏了

ksmlc 发表于 2025-12-25 15:20:10

esa没备案比edgeone还慢

uume 发表于 2025-12-25 15:33:57

谢谢分享

ysblack 发表于 2025-12-25 15:39:20

感谢分享

q2533q 发表于 2025-12-26 10:55:13

都续到千年以后了

gulonfuhe 发表于 2025-12-26 15:12:51

谢谢提供 就是不能下载啊

FinishIt 发表于 2025-12-26 16:01:19

不错 ~
页: [1]
查看完整版本: 阿里云CDN白嫖到2051年、华为云Versatile白嫖到2034年全自动续费脚本