幻域

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 11|回复: 0

关于脚本

[复制链接]

6727

主题

137

回帖

1万

积分

羽化登仙

是非在己,毁誉由人,得失不论

Rank: 9Rank: 9Rank: 9

UID
1
源力
-4333
灵气
5646
在线时间
385 小时
注册时间
2023-9-16

论坛模范灌水大师在线之王将心比心金点子声明远扬活跃大师管理必备发声者元旦徽章千天纪念

发表于 5 天前 | 显示全部楼层 |阅读模式

尽快登录注册

您需要 登录 才可以下载或查看,没有账号?立即注册

x
1脚本代码简单,开源,可以配合ai自行二改,更好食用
2这个是配合免费用户的星辰恋食用的,不会用,可以不用,或者自行b站,本网站不会提供教程的,ios建议stay软件
android与win建议油猴
3直接食用地区greasy fork最新greasy fork
4
  1. // ==UserScript==
  2. // @name         幻域—自助领取现金红包
  3. // @namespace    http://tampermonkey.net/
  4. // @version      0.6
  5. // @description  领取现金红包,无套路,辅助脚本,为活动服务
  6. // @author       您
  7. // @match        *://*/*
  8. // @grant        GM_setValue
  9. // @grant        GM_getValue
  10. // @grant        GM_notification
  11. // @grant        GM_addStyle
  12. // @grant        GM_xmlhttpRequest
  13. // @grant        GM_openInTab
  14. // ==/UserScript==

  15. (function() {
  16.     'use strict';

  17.     const CONFIG = {
  18.         TARGET_URL: "https://hyzy.0189700.xyz/forum.php?mod=viewthread&tid=7232",
  19.         REPLACE_URL: "https://link3.cc/rwcc",
  20.         BUTTON_STYLE: {
  21.             position: "fixed",
  22.             bottom: "20px",
  23.             right: "20px",
  24.             zIndex: "9999",
  25.             padding: "10px 15px",
  26.             backgroundColor: "#4CAF50",
  27.             color: "white",
  28.             border: "none",
  29.             borderRadius: "5px",
  30.             cursor: "pointer",
  31.             fontSize: "14px",
  32.             boxShadow: "0 2px 5px rgba(0,0,0,0.3)"
  33.         },
  34.         CHECK_INTERVAL: 60000
  35.     };

  36.     GM_addStyle(`
  37.         .manual-check-btn {
  38.             transition: all 0.2s ease;
  39.         }
  40.         .manual-check-btn:hover {
  41.             background-color: #45a049 !important;
  42.         }
  43.         .manual-check-btn:active {
  44.             transform: scale(0.98);
  45.         }
  46.         .manual-check-btn.loading {
  47.             background-color: #2196F3 !important;
  48.         }
  49.         .manual-check-btn.error {
  50.             background-color: #f44336 !important;
  51.         }
  52.     `);

  53.     function isTodayProcessed() {
  54.         const today = new Date().toDateString();
  55.         return GM_getValue('lastProcessDate') === today;
  56.     }

  57.     function markTodayProcessed() {
  58.         const today = new Date().toDateString();
  59.         GM_setValue('lastProcessDate', today);
  60.     }

  61.     function parsePostContent(html) {
  62.         try {
  63.             const parser = new DOMParser();
  64.             const doc = parser.parseFromString(html, 'text/html');
  65.             const posts = doc.querySelectorAll('.t_f');
  66.             return posts.length > 0 ? posts[posts.length-1].textContent.trim() : null;
  67.         } catch (e) {
  68.             console.error("出错了(ノ´д`)别找我,我也不会处理呢:", e);
  69.             return null;
  70.         }
  71.     }

  72.     async function fetchPostContent() {
  73.         return new Promise((resolve, reject) => {
  74.             GM_xmlhttpRequest({
  75.                 method: "GET",
  76.                 url: CONFIG.TARGET_URL,
  77.                 timeout: 10000,
  78.                 onload: function(response) {
  79.                     if (response.status === 200) {
  80.                         const content = parsePostContent(response.responseText);
  81.                         content ? resolve(content) : reject(new Error("没找到"));
  82.                     } else {
  83.                         reject(new Error(`HTTP错误: ${response.status}`));
  84.                     }
  85.                 },
  86.                 onerror: function(error) {
  87.                     reject(new Error(`请求失败,呃,哈哈哈: ${error.statusText}`));
  88.                 },
  89.                 ontimeout: function() {
  90.                     reject(new Error("请求超时,试试挂梯子"));
  91.                 }
  92.             });
  93.         });
  94.     }

  95.     function openTargetLink() {
  96.         try {
  97.             // 方法1: 使用GM_openInTab(推荐)
  98.             if (typeof GM_openInTab === 'function') {
  99.                 GM_openInTab(CONFIG.REPLACE_URL, { active: true });
  100.                 return true;
  101.             }
  102.             
  103.             // 方法2: 使用window.open
  104.             const newWindow = window.open(CONFIG.REPLACE_URL, '_blank');
  105.             if (!newWindow || newWindow.closed) {
  106.                 throw new Error("弹出窗口被阻止");
  107.             }
  108.             return true;
  109.             
  110.         } catch (e) {
  111.             console.error("打开链接失败:", e);
  112.             GM_notification({
  113.                 text: `无法自动打开链接,请手动访问: ${CONFIG.REPLACE_URL}`,
  114.                 title: "论坛回复检测 - 操作需要",
  115.                 timeout: 8000
  116.             });
  117.             return false;
  118.         }
  119.     }

  120.     async function checkReply(isManual = false) {
  121.         const btn = document.querySelector('.manual-check-btn');
  122.         if (btn) {
  123.             btn.classList.add('loading');
  124.             btn.textContent = '检测中...';
  125.         }

  126.         try {
  127.             if (!isManual && isTodayProcessed()) {
  128.                 console.log("今日已检测过");
  129.                 return;
  130.             }

  131.             const lastReply = await fetchPostContent();
  132.             if (!lastReply) throw new Error("未获取到有效回复");

  133.             console.log("检测到回复内容:", lastReply);
  134.             
  135.             if (lastReply === "1") {
  136.                 if (!openTargetLink()) {
  137.                     throw new Error("链接打开失败");
  138.                 }
  139.                 GM_notification({
  140.                     text: "已执行1的操作并打开链接",
  141.                     title: "检测结果",
  142.                     timeout: 5000
  143.                 });
  144.             } else {
  145.                 GM_notification({
  146.                     text: `当前回复内容: ${lastReply}`,
  147.                     title: "检测结果",
  148.                     timeout: 5000
  149.                 });
  150.             }

  151.             if (!isManual) markTodayProcessed();
  152.             
  153.         } catch (error) {
  154.             console.error("检测出错:", error);
  155.             GM_notification({
  156.                 text: `错误: ${error.message}`,
  157.                 title: "检测失败",
  158.                 timeout: 6000,
  159.                 highlight: true
  160.             });
  161.             if (btn) btn.classList.add('error');
  162.         } finally {
  163.             if (btn) {
  164.                 btn.classList.remove('loading', 'error');
  165.                 btn.textContent = '检测是否有红包';
  166.             }
  167.         }
  168.     }

  169.     function createManualButton() {
  170.         if (document.querySelector('.manual-check-btn')) return;
  171.         
  172.         const btn = document.createElement('button');
  173.         btn.className = 'manual-check-btn';
  174.         btn.textContent = '检测红包';
  175.         Object.assign(btn.style, CONFIG.BUTTON_STYLE);
  176.         btn.addEventListener('click', () => checkReply(true));
  177.         document.body.appendChild(btn);
  178.     }

  179.     function startAutoCheck() {
  180.         setInterval(() => {
  181.             const now = new Date();
  182.             if (now.getHours() === 12 && now.getMinutes() === 0) {
  183.                 checkReply();
  184.             }
  185.         }, CONFIG.CHECK_INTERVAL);
  186.     }

  187.     function init() {
  188.         createManualButton();
  189.         startAutoCheck();
  190.         console.log("脚本已初始化,目标URL:", CONFIG.TARGET_URL);
  191.     }

  192.     if (document.readyState === 'complete') {
  193.         init();
  194.     } else {
  195.         window.addEventListener('load', init);
  196.     }
  197. })();
复制代码

源代码

世界上一共有三个Cthulhu,你,我,他
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|幻域 |网站地图

GMT+8, 2025-8-25 18:05 , Processed in 0.060978 second(s), 28 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表