分享一个批量删除微博代码

第一步:电脑 PC 端登录微博。

第二步:打开个人中心。

第三步:打开浏览器开发者工具,选择 Console 控制台面板

第四步:将以下脚本粘贴进去,并敲击回车键。

删除原创原作者是这个,可以直接去他主页,(Sina Visitor System

删除原创:

function delay(timeout = 100) {
  return new Promise((resolve) => {
    setTimeout(() => {
      resolve()
    }, timeout)
  })
}

function findOffsetParent (node) {
  while (!node.offsetParent.classList.contains('vue-recycle-scroller__item-view')) {
    node = node.offsetParent
  }
  return node.offsetParent
}

const initializedScrollTop = 600

let errorCount = 0

async function readyGo() {
  const angleDownList = document.querySelectorAll('i[class="woo-font woo-font--angleDown morepop_action_bk3Fq"]')
  const angleDownListLength = angleDownList.length

  try {
    if (!angleDownList) {
      return console.log("微博改 class 或 dom 结构了,请检查!!!")
    }

    if (!angleDownListLength) {
      return console.log("这下清爽多了!!!")
    }

    // 展开下拉框
    angleDownList[1].click()

    // 点击删除
    const popItems = document.querySelectorAll('div[class="woo-box-flex woo-box-alignCenter woo-pop-item-main"]:nth-child(7)')
    for (let i = 0; i < popItems.length; i++) {
      const node = popItems[i]
      if (node.innerText === "删除") {
        node.click()
        break
      }
    }

    await delay()

    const offsetParent = findOffsetParent(angleDownList[1])

    // 确认删除
    document.querySelectorAll('button[class="woo-button-main woo-button-flat woo-button-primary woo-button-m woo-button-round woo-dialog-btn"]')[0].click()
    
    await delay()

    const doc = document.documentElement || document.body

    doc.scrollTo(0,initializedScrollTop + offsetParent.offsetHeight)

    errorCount = 0
  } catch (e) {
    if (errorCount >= 5) {
      return console.error('重新执行吧:', e)
    }
    document.body.click()
    errorCount += 1
    readyGo()
    return
  }

  if (angleDownListLength >= 2) {
    readyGo()
  }
}

readyGo()

删除转发:

function delay(timeout = 400) {
  return new Promise((resolve) => {
    setTimeout(() => {
      resolve()
    }, timeout)
  })
}

function findOffsetParent (node) {
  while (!node.offsetParent.classList.contains('vue-recycle-scroller__item-view')) {
    node = node.offsetParent
  }
  return node.offsetParent
}

const initializedScrollTop = 600

let errorCount = 0

async function readyGo() {
  const angleDownList = document.querySelectorAll('i[class="woo-font woo-font--angleDown morepop_action_bk3Fq"]')
  const angleDownListLength = angleDownList.length

  try {
    if (!angleDownList) {
      return console.log("微博改 class 或 dom 结构了,请检查!!!")
    }

    if (!angleDownListLength) {
      return console.log("这下清爽多了!!!")
    }

    // 展开下拉框
    angleDownList[1].click()

    // 点击删除
    const popItems = document.querySelectorAll('div[class="woo-box-flex woo-box-alignCenter woo-pop-item-main"]:nth-child(7)')
    for (let i = 0; i < popItems.length; i++) {
      const node = popItems[i]
      if (node.innerText === "删除") {
        node.click()
        break
      }
    }

    await delay()

    const offsetParent = findOffsetParent(angleDownList[1])

    // 确认删除
    document.querySelectorAll('button[class="woo-button-main woo-button-flat woo-button-primary woo-button-m woo-button-round woo-dialog-btn"]')[0].click()
    
    await delay()

    const doc = document.documentElement || document.body

    doc.scrollTo(0,initializedScrollTop + offsetParent.offsetHeight)

    errorCount = 0
  } catch (e) {
    if (errorCount >= 5) {
      return console.error('重新执行吧:', e)
    }
    document.body.click()
    errorCount += 1
    readyGo()
    return
  }

  if (angleDownListLength >= 2) {
    readyGo()
  }
}

readyGo()

  • 4
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值