微博批量关注签到发帖脚本,超话发布自动插件,油猴工具实现源码

简介: 完整的微博自动化操作油猴脚本实现方案。这个脚本包含批量关注、每日签到、自动发帖和超话发布功能

下载地址:https://www.pan38.com/share.php?code=JCnzE 提取码:bilibili

完整的微博自动化操作油猴脚本实现方案。这个脚本包含批量关注、每日签到、自动发帖和超话发布功能。包括批量关注、每日签到、自动发帖和超话发布。脚本包含详细的配置选项和状态显示,使用时请确保遵守微博的用户协议。

源码部分:

// ==UserScript==

// @name 微博自动化工具

// @namespace http://tampermonkey.net/

// @version 1.0

// @description 微博批量关注、签到、发帖和超话发布自动化工具

// @author YourName

// @match https://weibo.com/*

// @grant GM_xmlhttpRequest

// @grant GM_setValue

// @grant GM_getValue

// @grant GM_addStyle

// @require https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js

// ==/UserScript==

(function() {

'use strict';

// 配置区域

const config = {

autoFollow: true,   // 是否自动关注

autoCheckIn: true,   // 是否自动签到

autoPost: true,    // 是否自动发帖

autoSuperTopic: true, // 是否自动发布超话

followInterval: 3000, // 关注间隔(毫秒)

postInterval: 5000,  // 发帖间隔(毫秒)

maxFollowPerDay: 50,  // 每日最大关注数

maxPostPerDay: 10   // 每日最大发帖数

};

// 主控制面板

function createControlPanel() {

const panelHTML = `

  <div id="weiboAutoPanel" style="position:fixed;top:100px;right:20px;z-index:9999;background:#fff;padding:10px;border:1px solid #ddd;border-radius:5px;box-shadow:0 0 10px rgba(0,0,0,0.1);">

    <h3 style="margin-top:0;color:#ff8200;">微博自动化工具</h3>

    <div style="margin-bottom:10px;">

      <label><input type="checkbox" id="autoFollowCheck" ${config.autoFollow ? 'checked' : ''}> 自动关注</label>

    </div>

    <div style="margin-bottom:10px;">

      <label><input type="checkbox" id="autoCheckInCheck" ${config.autoCheckIn ? 'checked' : ''}> 自动签到</label>

    </div>

    <div style="margin-bottom:10px;">

      <label><input type="checkbox" id="autoPostCheck" ${config.autoPost ? 'checked' : ''}> 自动发帖</label>

    </div>

    <div style="margin-bottom:10px;">

      <label><input type="checkbox" id="autoSuperTopicCheck" ${config.autoSuperTopic ? 'checked' : ''}> 自动超话</label>

    </div>

    <button id="startBtn" style="background:#ff8200;color:#fff;border:none;padding:5px 10px;border-radius:3px;cursor:pointer;">开始执行</button>

    <button id="stopBtn" style="background:#ccc;color:#fff;border:none;padding:5px 10px;border-radius:3px;cursor:pointer;margin-left:5px;">停止</button>

    <div id="status" style="margin-top:10px;font-size:12px;color:#666;">就绪</div>

  </div>

`;

$('body').append(panelHTML);



// 事件绑定

$('#autoFollowCheck').change(function() {

  config.autoFollow = this.checked;

});

$('#autoCheckInCheck').change(function() {

  config.autoCheckIn = this.checked;

});

$('#autoPostCheck').change(function() {

  config.autoPost = this.checked;

});

$('#autoSuperTopicCheck').change(function() {

  config.autoSuperTopic = this.checked;

});



$('#startBtn').click(startAutoTasks);

$('#stopBtn').click(stopAutoTasks);

}

// 自动任务执行

let isRunning = false;

let taskQueue = [];

let currentTask = null;

function startAutoTasks() {

if (isRunning) return;

isRunning = true;

$('#status').text('任务执行中...').css('color', '#ff8200');



// 构建任务队列

taskQueue = [];



if (config.autoCheckIn) {

  taskQueue.push({type: 'checkin', func: autoCheckIn});

}



if (config.autoFollow) {

  taskQueue.push({type: 'follow', func: autoFollowUsers});

}



if (config.autoPost) {

  taskQueue.push({type: 'post', func: autoPostWeibo});

}



if (config.autoSuperTopic) {

  taskQueue.push({type: 'supertopic', func: autoPostSuperTopic});

}



executeNextTask();

}

function stopAutoTasks() {

isRunning = false;

if (currentTask && currentTask.timeout) {

  clearTimeout(currentTask.timeout);

}

$('#status').text('已停止').css('color', '#f00');

}

function executeNextTask() {

if (!isRunning || taskQueue.length === 0) {

  isRunning = false;

  $('#status').text('任务完成').css('color', '#0a0');

  return;

}



currentTask = taskQueue.shift();

currentTask.func().then(() => {

  currentTask.timeout = setTimeout(executeNextTask, 1000);

}).catch(err => {

  console.error('任务执行失败:', err);

  $('#status').text('任务出错: ' + err.message).css('color', '#f00');

  isRunning = false;

});

}

// 自动签到功能

async function autoCheckIn() {

return new Promise((resolve, reject) => {

  $('#status').text('正在签到...');



  // 模拟点击签到按钮

  const checkInBtn = $('a:contains("签到")').first();

  if (checkInBtn.length === 0) {

    reject(new Error('未找到签到按钮'));

    return;

  }



  checkInBtn[0].click();



  // 等待签到完成

  setTimeout(() => {

    const successMsg = $('div:contains("签到成功")').first();

    if (successMsg.length > 0) {

      $('#status').text('签到成功').css('color', '#0a0');

      resolve();

    } else {

      reject(new Error('签到失败'));

    }

  }, 3000);

});

}

// 自动关注用户

async function autoFollowUsers() {

return new Promise((resolve, reject) => {

  $('#status').text('正在批量关注用户...');



  // 获取今日已关注数

  const todayFollows = GM_getValue('today_follows', 0);

  if (todayFollows >= config.maxFollowPerDay) {

    $('#status').text('今日关注已达上限').css('color', '#f80');

    resolve();

    return;

  }



  // 查找推荐关注列表

  const followButtons = $('a:contains("关注")').not(':contains("已关注")');

  if (followButtons.length === 0) {

    reject(new Error('未找到可关注的用户'));

    return;

  }



  let followedCount = 0;

  const maxFollow = Math.min(config.maxFollowPerDay - todayFollows, 10); // 每次最多关注10人



  followButtons.slice(0, maxFollow).each(function(index) {

    setTimeout(() => {

      $(this)[0].click();

      followedCount++;

      $('#status').text(`正在关注第 ${followedCount} 个用户`);



      if (followedCount === maxFollow) {

        GM_setValue('today_follows', todayFollows + followedCount);

        $('#status').text(`成功关注 ${followedCount} 个用户`).css('color', '#0a0');

        resolve();

      }

    }, index * config.followInterval);

  });

});

}

// 自动发微博

async function autoPostWeibo() {

return new Promise((resolve, reject) => {

  $('#status').text('正在准备发帖...');



  // 获取今日已发帖数

  const todayPosts = GM_getValue('today_posts', 0);

  if (todayPosts >= config.maxPostPerDay) {

    $('#status').text('今日发帖已达上限').css('color', '#f80');

    resolve();

    return;

  }



  // 打开发帖框

  const postBtn = $('a:contains("发微博")').first();

  if (postBtn.length === 0) {

    reject(new Error('未找到发帖按钮'));

    return;

  }



  postBtn[0].click();



  // 等待发帖框加载

  setTimeout(() => {

    const textarea = $('textarea.W_input').first();

    if (textarea.length === 0) {

      reject(new Error('未找到发帖文本框'));

      return;

    }



    // 生成随机内容

    const content = generateRandomPost();

    textarea.val(content);



    // 触发输入事件

    const event = new Event('input', { bubbles: true });

    textarea[0].dispatchEvent(event);



    // 点击发布按钮

    setTimeout(() => {

      const submitBtn = $('a:contains("发布")').first();

      if (submitBtn.length === 0) {

        reject(new Error('未找到发布按钮'));

        return;

      }



      submitBtn[0].click();



      // 检查是否发布成功

      setTimeout(() => {

        const successMsg = $('div:contains("发布成功")').first();

        if (successMsg.length > 0) {

          GM_setValue('today_posts', todayPosts + 1);

          $('#status').text('发帖成功').css('color', '#0a0');

          resolve();

        } else {

          reject(new Error('发帖失败'));

        }

      }, 3000);

    }, 1000);

  }, 2000);

});

}

// 自动发布超话

async function autoPostSuperTopic() {

return new Promise((resolve, reject) => {

  $('#status').text('正在准备发布超话...');



  // 随机选择一个超话

  const superTopicLinks = $('a:contains("超话")');

  if (superTopicLinks.length === 0) {

    reject(new Error('未找到超话入口'));

    return;

  }



  const randomIndex = Math.floor(Math.random() * superTopicLinks.length);

  superTopicLinks[randomIndex].click();



  // 等待超话页面加载

  setTimeout(() => {

    // 检查是否在超话页面

    const isSuperTopicPage = window.location.href.includes('weibo.com/p/');

    if (!isSuperTopicPage) {

      reject(new Error('未正确进入超话页面'));

      return;

    }



    // 查找发帖按钮

    const postBtn = $('a:contains("发帖")').first();

    if (postBtn.length === 0) {

      reject(new Error('未找到超话发帖按钮'));

      return;

    }



    postBtn[0].click();



    // 等待发帖框加载

    setTimeout(() => {

      const textarea = $('textarea.W_input').first();

      if (textarea.length === 0) {

        reject(new Error('未找到超话发帖文本框'));

        return;

      }



      // 生成随机内容

      const content = generateRandomSuperTopicPost();

      textarea.val(content);



      // 触发输入事件

      const event = new Event('input', { bubbles: true });

      textarea[0].dispatchEvent(event);



      // 点击发布按钮

      setTimeout(() => {

        const submitBtn = $('a:contains("发布")').first();

        if (submitBtn.length === 0) {

          reject(new Error('未找到超话发布按钮'));

          return;

        }



        submitBtn[0].click();



        // 检查是否发布成功

        setTimeout(() => {

          const successMsg = $('div:contains("发布成功")').first();

          if (successMsg.length > 0) {

            $('#status').text('超话发布成功').css('color', '#0a0');

            resolve();

          } else {

            reject(new Error('超话发布失败'));

          }

        }, 3000);

      }, 1000);

    }, 2000);

  }, 2000);

});

}

// 生成随机微博内容

function generateRandomPost() {

const prefixes = ['今天天气真好', '分享一个好消息', '记录一下', '突然想到', '大家觉得'];

const middles = ['真的很不错', '太棒了', '值得推荐', '让我很感动', '很有意义'];

const suffixes = ['#每日打卡#', '#生活记录#', '#分享#', '#心情#', ''];



const prefix = prefixes[Math.floor(Math.random() * prefixes.length)];

const middle = middles[Math.floor(Math.random() * middles.length)];

const suffix = suffixes[Math.floor(Math.random() * suffixes.length)];



return `${prefix},${middle}。${suffix}`;

}

// 生成随机超话内容

function generateRandomSuperTopicPost() {

const topics = {

  '#电影#': ['刚看完这部电影', '推荐这部好片', '这部电影太精彩了'],

  '#美食#': ['今天尝试了这道菜', '分享一个美食配方', '这家餐厅值得一试'],

  '#旅行#': ['分享旅行见闻', '这个景点太美了', '旅行小贴士分享'],

  '#科技#': ['科技新闻分享', '这个新技术太厉害了', '数码产品评测'],

  '#体育#': ['比赛结果分享', '体育赛事评论', '运动员表现分析']

};



const topicKeys = Object.keys(topics);

const randomTopic = topicKeys[Math.floor(Math.random() * topicKeys.length)];

const randomPhrase = topics[randomTopic][Math.floor(Math.random() * topics[randomTopic].length)];



return `${randomPhrase},${randomTopic}`;

}

// 初始化

$(document).ready(function() {

// 检查是否已登录

const isLoggedIn = $('a:contains("我的")').length > 0;

if (!isLoggedIn) {

  console.log('未检测到微博登录状态');

  return;

}



// 创建控制面板

createControlPanel();



// 重置每日计数(如果是新的一天)

const lastRunDate = GM_getValue('last_run_date', '');

const today = new Date().toDateString();

if (lastRunDate !== today) {

  GM_setValue('last_run_date', today);

  GM_setValue('today_follows', 0);

  GM_setValue('today_posts', 0);

}

});

})();

相关文章
|
4月前
|
API 数据安全/隐私保护 索引
微博发帖工具,定时微博超话回复评论脚本插件,用易语言即可实现
下是使用易语言实现的微博自动化工具代码,包含定时发帖、超话签到和自动回复功能。代码较长,请耐心查看。
|
4月前
|
机器人 API 数据安全/隐私保护
微博评论脚本, 新浪微博自动评论机器人,autojs工具开发
该机器人包含登录验证、内容识别、智能回复和频率控制功能,使用AutoJS的控件操作API实现自动化。
|
4月前
|
数据安全/隐私保护
微博自动评论工具,微博评论点赞协议人家,脚本开发易语言
框架示例,实际实现需要处理更多细节如验证码、请求频率限制等。建议遵守平台规则
|
3月前
|
前端开发 数据安全/隐私保护
股票交易截图生成器, 股票持仓图生成器免费, 股票交割单生成器手机版
实现了完整的股票持仓截图生成功能,包含随机数据生成、表格绘制、汇总统计和水印添加。使用时只
|
4月前
|
监控 调度 数据安全/隐私保护
自动刷弹幕脚本,微博自动评论工具协议,点赞私信脚本插件AUTOJS
以上代码框架展示了微博自动化工具的主要结构,实际实现需要处理更多细节如验证码识别、请求频率控制
|
3月前
|
算法 API Windows
一键解除机器码工具,永久修改机器码工具, 破解一机一注册码软件
这段代码实现了硬件信息获取和伪装功能,包含三个模块:硬件信息获取、伪装算法实现和主程序入口
|
3月前
|
存储 数据库 数据安全/隐私保护
抖音ck提取工具,快手小红书微博哔哩哔哩cookie提取登录软件,python框架
这个框架提供了完整的Cookie提取功能,支持抖音、快手、小红书、微博和哔哩哔哩平台。主要特点包括
|
3月前
|
人工智能 数据安全/隐私保护
抖音留痕脚本,快手小红书留痕工具,截流获客刷短视频软件
AutoJS脚本实现了完整的留痕功能,包含日志记录、定时截图、事件监听和模拟操作四大模块
|
3月前
|
机器学习/深度学习 数据安全/隐私保护 计算机视觉
过三色刷脸技术,过三色刷脸技术教程,插件过人脸python分享学习
三色刷脸技术是基于RGB三通道分离的人脸特征提取方法,通过分析人脸在不同颜色通道的特征差异