// ==UserScript== // @name 梓梓点赞评论破解2.0 // @namespace https://example.org/learn // @version 1.0.2 // @description 油猴JS学习演示脚本,去除卡密、后端服务器调用。仅用于前端DOM、定时器编程学习,严禁在易班平台用于自动评论点赞! // @match https://s.yiban.cn/app/* // @exclude https://s.yiban.cn/app/383996/post-detail/wxnC9a90k2Bge27 // @grant GM_addStyle // @license All Rights Reserved // ==/UserScript== (function () { "use strict"; let COMMENT_COUNTER = 0; let msg_text; window.liked_count = 1; window.valid_liked_count = 1; // 移除服务器地址 sever = 'http://111.228.46.57:8000'; const floatingWindowHTML = `
学习演示脚本(仅编程学习,禁止刷网薪)
公告:本脚本仅前端JS学习演示,请勿在易班正式使用和转发!
评论次数:
0
点赞次数:
0
`; document.body.insertAdjacentHTML('afterbegin', floatingWindowHTML); GM_addStyle(` #floatingWindow { position: fixed; bottom: 10px; left: 10px; width: 300px; max-height: 500px; background: #2c3e50; color: #fff; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.3); padding: 10px; font-family: Arial, sans-serif; transition: all 0.3s ease; z-index:9999; } #title { font-size: 13px; font-weight: bold; margin-bottom: 10px; } #announcement { font-size: 13px; color: #bdc3c7; margin-bottom: 10px; } #countdown, #likes{ font-size: 13px; color: #ecf0f1; } #toggleBtn { position: absolute; top: 10px; right: 10px; font-size: 17px; cursor: pointer; color: #fff; background: rgba(0, 0, 0, 0.3); border-radius: 50%; padding: 5px; } #floatingWindow.collapsed { max-height: 40px; overflow: hidden; } `); const toggleBtn = document.getElementById('toggleBtn'); const floatingWindow = document.getElementById('floatingWindow'); toggleBtn.addEventListener('click', () => { floatingWindow.classList.toggle('collapsed'); toggleBtn.innerHTML = floatingWindow.classList.contains('collapsed') ? '▲' : '▼'; }); setTimeout(() => { window.scrollTo(0, document.querySelector("body > div.container.with-bg > section > section.comments.box").offsetTop); setTimeout(() => { window.scrollTo(0, document.querySelector("body > div.container.with-bg > section > section.comments.box").offsetTop + 105 * 20); setTimeout(() => { const reloadCoult = document.querySelector("body > div.container.with-bg > section > section.comments.box > div").children.length; if (reloadCoult >= 35) { Thumbs(); executeFirstPart(); } else { alert("【学习Demo】DOM元素检测失败,页面结构不匹配"); } }, 2000); }, 2000); }, 3800); function executeFirstPart() { const input_div = document.querySelector("body > div.container.with-bg > section > section.submit > div > div"); if (input_div) { input_div.click(); setTimeout(() => { const input_text = document.querySelector("body > div.container.with-bg > section > section.submit > div > div.inner > div.input-wrapper > input[type=text]"); const text = getRandomMessage(); msg_text = text; if(input_text){ input_text.value = text; input_text.dispatchEvent(new Event('input')); const send_btn = document.querySelector("body > div.container.with-bg > section > section.submit > div > div.inner > div.submit-btn.btn"); if(send_btn) send_btn.click(); } setTimeout(() => { startInterval(); }, 2000); }, 1000); } } function startInterval() { console.log("【学习Demo】开始计时"); COMMENT_COUNTER++; if (COMMENT_COUNTER == 30) { document.getElementById("comment_counter").textContent = "30(已完成)"; document.getElementById("finish_text").textContent = "【学习Demo】模拟任务结束"; return; } let time = 60; const send_cd = setInterval(() => { time = time - 1; document.getElementById("comment_counter").textContent = COMMENT_COUNTER + "/" + time; if (time == 0) { executeFirstPart(); clearInterval(send_cd); } }, 1000); } function Thumbs() { const _t = setInterval(() => { const dom = document.querySelector( "body > div.container.with-bg > section > section.comments.box > div > div:nth-child(" + liked_count + ") > div > div.status > div.actions > div.like > div" ); if(!dom) { clearInterval(_t); return; } if (!dom.firstChild.classList.contains("liked")) { dom.click(); valid_liked_count++; liked_count++; document.getElementById("thum_counter").textContent = liked_count; if (valid_liked_count >= 35) { clearInterval(_t); document.getElementById("thum_counter").textContent = liked_count + "(已完成)"; } } else { liked_count++; } }, 4000); } // 随机文案生成函数 function getRandomMessage() { const words1 = ["希望", "憧憬", "友爱", "团结", "合作", "愉快", "勤奋", "刻苦", "认真"]; const words2 = ["整洁", "称赞", "简洁", "秀丽", "匀称", "标致", "感激", "魅力", "优秀"]; const phrases = [ "不要等待机会,而要创造机会。", "每天告诉自己一次,我真的很不错。", "发光并非太阳的专利,你也可以发光。", "业精于勤荒于嬉,行成于思毁于随。" ]; const randomChoice = Math.random(); if (randomChoice < 0.5) { const randomIndex = Math.floor(Math.random() * phrases.length); return phrases[randomIndex]; } else { const randomWords = []; while (randomWords.length < 3) { const wordList = Math.random() < 0.5 ? words1 : words2; const randomWord = wordList[Math.floor(Math.random() * wordList.length)]; if (!randomWords.includes(randomWord)) { randomWords.push(randomWord); } } return randomWords.join(", "); } } })();