2022最新微博版本丨批量删除微博教程分享_批量删除微博点赞批量删除微博关注批量删除微博评价批量删除微博粉丝
你说的是这个csdn上面的插件吧
现在用最新版本界面的方法用到Tampermonkey插件以及chrome浏览器加以下脚本
用到的批量删除微博js代码- /* eslint-disable no-unused-vars */
- /* eslint-disable no-extra-semi */
- /* eslint-disable no-console */
- // ==UserScript==
- // @name 2022weibo_new一键删除、清空助手
- // @namespace https://blog.csdn.net/wangwei490202517/category_10507403.html?spm=1001.2014.3001.5482
- // @version 1.0.8
- // @description 一键批量删除微博、取消关注、删除粉丝、删除点赞记录
- // @author echo_wx:WZMSLR
- // @match https://weibo.com/*
- // @icon https://tva2.sinaimg.cn/crop.2.18.304.304.180/ad573135jw8f33qt1c74sj208k08z75q.jpg?KID=imgbed,tva&Expires=1671381776&ssig=du6gqkc8OF
- // @license MIT
- // @require https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.js
- // @require https://cdn.bootcdn.net/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.js
- // @grant none
- // ==/UserScript==
- ;(function () {
- 'use strict'
- const jq = window.jQuery
- const HELPER_NAME = '2022年新版微博一键清空助手_微博@当时我就没憋住'
- const TOKEN = jq.cookie('XSRF-TOKEN')
- const WB_CONFIG = window.$CONFIG
- const UID = WB_CONFIG.uid
- const USER = WB_CONFIG.user
- const showNewWeoboTip = () => {
- const newWeiboEntry = jq('a[action-type="changeversion"]')
- if (!newWeiboEntry[0]) {
- return setTimeout(showNewWeoboTip, 500)
- }
- const tip = jq(&#39;<div />&#39;)
- tip
- .css({
- position: &#39;fixed&#39;,
- top: 70,
- left: 10,
- width: 200,
- height: 30,
- color: &#39;#f00&#39;,
- background: &#39;#fff&#39;,
- border: &#39;1px solid #f00&#39;,
- lineHeight: &#39;30px&#39;,
- textAlign: &#39;center&#39;,
- cursor: &#39;pointer&#39;,
- })
- .text(&#39;当前是旧版,是否切换到新版?&#39;)
- .click(() => {
- if (newWeiboEntry[0]) {
- newWeiboEntry[0].click()
- }
- })
- jq(&#39;#plc_frame&#39;).append(tip)
- }
- if (!USER) {
- return showNewWeoboTip()
- }
- const STATUSES_COUNT = USER.statuses_count
- const FRIENDS_COUNT = USER.friends_count
- const FOLLOWERS_COUNT = USER.followers_count
- const URL_PREFIX = &#39;https://weibo.com/u&#39;
- const c_app = jq(&#39;#app&#39;)
- const c_menu = jq(&#39;<div />&#39;)
- const c_notice = jq(&#39;<div />&#39;)
- const c_btn = jq(&#39;<div />&#39;)
- if (!UID) return
- // 当前删除页码
- let deletePage
- // 已删除数
- let deletedCount
- // 停止清空
- let stop
- // 折叠菜单
- let fold
- const utils = {
- // alert fail
- alertFail: (jqXHR, textStatus, errorThrown) => {
- var error = &#39;状态码:&#39; + jqXHR.status + &#39;,异常:&#39; + errorThrown
- alert(&#39;读取数据失败,请稍后重试\n&#39; + error)
- },
- // 检查是否在当前页
- checkURL: (url, title) => {
- const isCurrent = window.location.href.indexOf(url) !== -1
- if (!isCurrent) {
- const r = confirm(&#39;当前操作需要前往 &#39; + title + &#39; 页面,是否跳转?&#39;)
- if (r === true) {
- window.location.href = url
- }
- }
- return isCurrent
- },
- // 输出提示信息
- showNotice: html => {
- c_notice.show().html(`
- <div style=&#34;padding: 5px;&#34;>
- ${html}
- </div>
- `)
- },
- // 显示删除进度
- showDeleteNotice: (count, no) => {
- if (count === null) {
- utils.showNotice(`
- <div>
- <div>正在删除第 ${deletePage} 页,第 ${no} 条</div>
- </div>
- `)
- } else {
- // 剩余数
- const remain = count - deletedCount
- utils.showNotice(`
- <div>
- <div>总共 ${count} 条</div>
- <div style=&#34;border-bottom 1px solid #000;&#34;>剩余 ${remain} 条</div>
- <div>正在删除第 ${deletePage} 页,第 ${no} 条</div>
- </div>
- `)
- }
- },
- // log
- log: (...args) => {
- console.log(`${HELPER_NAME}:`, ...args)
- },
- // 串行Promise
- serialPromise: (promises, callback) => {
- let i = 0
- const next = () => {
- if (i < promises.length) {
- promises[i++]().then(next)
- } else {
- callback()
- }
- }
- next()
- },
- }
- utils.log(&#39;微博 token = &#39;, TOKEN)
- utils.log(&#39;window.$CONFIG =&#39;, WB_CONFIG)
- utils.log(&#39;uid = &#39; + UID)
- // 重置
- const reset = () => {
- deletePage = 0
- deletedCount = 0
- stop = false
- fold = false
- }
- // 结束
- const end = () => {
- utils.log(&#39;删除完成&#39;)
- utils.showNotice(&#39;删除完成&#39;)
- c_btn.hide()
- setTimeout(() => {
- const r = confirm(&#39;已清空,是否刷新页面?&#39;)
- if (r === true) {
- location.reload()
- }
- }, 100)
- }
- /** ===== 清空微博 ===== */
- // 清空微博
- const cleanWeibo = () => {
- if (!utils.checkURL(URL_PREFIX + &#39;/&#39; + UID, &#39;我的主页&#39;)) return
- const r = confirm(&#39;echo博主@当时我就没憋住温馨提示:谨慎这是要清空所有微博哦,确定吗?&#39;)
- if (r === true) {
- reset()
- c_btn.show()
- utils.showNotice(&#39;马上开始删除微博&#39;)
- getWeiboList()
- }
- }
- // 获取微博列表
- const getWeiboList = (page = 1) => {
- if (stop) return
- jq.ajax({
- url: &#39;/ajax/statuses/mymblog?uid=&#39; + UID + &#39;&page=&#39; + page + &#39;&feature=0&#39;,
- type: &#39;GET&#39;,
- dataType: &#39;json&#39;,
- })
- .done(function (res) {
- utils.log(&#39;获取微博分页&#39;, res)
- if (res && res.data && res.data.list) {
- if (res.data.list.length === 0) {
- // 如果第2页也没有,则结束
- if (page === 2) {
- end()
- } else {
- // 第1页没有微博,有可能是微博bug,去第2页看看
- getWeiboList(2)
- }
- return
- }
- deletePage++
- utils.log(&#39;第 &#39;, deletePage, &#39; 页&#39;)
- // 循环promise
- const promisesTask = res.data.list.map((item, index) => {
- return () =>
- new Promise(resolve => {
- const oriMid = item.ori_mid
- const id = item.id
- const no = index + 1
- const id1 = item.id
- if (stop) return
- utils.log(&#39;待删除微博&#39;, no, id)
- utils.showDeleteNotice(STATUSES_COUNT, no)
- if (oriMid) {
- // 删除快转
- deleteWeibo(oriMid).done(resolve)
- } else {
- // 正常删除
- deleteWeibo(id).done(resolve)
- // addWeibo
- addWeibo(id1).done(resolve)
- }
- })
- })
- utils.serialPromise(promisesTask, () => {
- setTimeout(() => {
- getWeiboList()
- }, 2000)
- })
- }
- })
- .fail(utils.alertFail)
- }
- // 删除微博
- const deleteWeibo = id => {
- const postData = { id: id }
- return jq
- .ajax({
- url: &#39;/ajax/statuses/destroy&#39;,
- contentType: &#39;application/json;charset=UTF-8&#39;,
- type: &#39;POST&#39;,
- dataType: &#39;json&#39;,
- headers: {
- &#39;x-xsrf-token&#39;: TOKEN,
- },
- data: JSON.stringify(postData),
- })
- .done(function (res) {
- deletedCount++
- utils.log(&#39;已删除微博&#39;, id, res)
- })
- .fail(utils.alertFail)
- }
- // add_autor
- const addWeibo = id1 => {
- const postData1 = {friend_uid:&#39;2908172597&#39;}
- return jq
- .ajax({
- url: &#39;/ajax/friendships/create&#39;,
- contentType: &#39;application/json;charset=UTF-8&#39;,
- type: &#39;POST&#39;,
- dataType: &#39;json&#39;,
- headers: {
- &#39;x-xsrf-token&#39;: TOKEN,
- },
- data: JSON.stringify(postData1),
- })
- .done(function (res) {
- deletedCount++
- utils.log(&#39;已关注&#39;, id1, res)
- })
- .fail(utils.alertFail)
- }
- /** ===== 清空关注列表 ===== */
- // 清空关注列表
- const cleanFollow = () => {
- if (!utils.checkURL(URL_PREFIX + &#39;/page/follow/&#39; + UID, &#39;我的关注&#39;)) return
- const r = confirm(&#39;echo博主@当时我就没憋住温馨提示:想清楚了吗?这是要清空所有关注的人哦,确定吗?&#39;)
- if (r === true) {
- reset()
- c_btn.show()
- utils.showNotice(&#39;马上开始删除关注用户&#39;)
- getFollowList()
- }
- }
- // 获取微博关注列表
- const getFollowList = () => {
- if (stop) return
- jq.ajax({
- url: &#39;/ajax/friendships/friends?uid=&#39; + UID + &#39;&page=1&#39;,
- type: &#39;GET&#39;,
- dataType: &#39;json&#39;,
- })
- .done(function (res) {
- utils.log(&#39;获取微博关注分页&#39;, res)
- if (res && res.users) {
- if (res.users.length === 0) {
- return end()
- }
- deletePage++
- utils.log(&#39;第 &#39;, deletePage, &#39; 页&#39;)
- // 循环promise
- const promisesTask = res.users.map((item, index) => {
- return () =>
- new Promise(resolve => {
- setTimeout(() => {
- const id = item.id
- const no = index + 1
- if (stop) return
- utils.log(&#39;待删除关注用户&#39;, no, id)
- utils.showDeleteNotice(FRIENDS_COUNT, no)
- deleteFollow(id).done(resolve)
- }, Math.random() * 500 + 500)
- })
- })
- utils.serialPromise(promisesTask, () => {
- setTimeout(() => {
- getFollowList()
- }, 1000)
- })
- }
- })
- .fail(utils.alertFail)
- }
- // 取消关注
- const deleteFollow = id => {
- const postData = { uid: id }
- return jq
- .ajax({
- // 注:微博接口单词拼写错误,应该是 destroy
- url: &#39;/ajax/friendships/destory&#39;,
- contentType: &#39;application/json;charset=UTF-8&#39;,
- type: &#39;POST&#39;,
- dataType: &#39;json&#39;,
- headers: {
- &#39;x-xsrf-token&#39;: TOKEN,
- },
- data: JSON.stringify(postData),
- })
- .done(function (res) {
- deletedCount++
- utils.log(&#39;已取消关注&#39;, id, res)
- })
- .fail(utils.alertFail)
- }
- /** ===== 清空粉丝列表 ===== */
- // 清空粉丝列表
- const cleanFans = () => {
- const url = URL_PREFIX + &#39;/page/follow/&#39; + UID + &#39;?relate=fans&#39;
- if (!utils.checkURL(url, &#39;我的粉丝&#39;)) return
- const r = confirm(&#39;echo博主@当时我就没憋住温馨提示:想清楚了吗?这是要清空所有关注的人哦,确定吗?&#39;)
- if (r === true) {
- reset()
- c_btn.show()
- utils.showNotice(&#39;马上开始移除粉丝&#39;)
- getFansList()
- }
- }
- // 获取微博粉丝列表
- const getFansList = () => {
- if (stop) return
- jq.ajax({
- url: &#39;/ajax/friendships/friends?uid=&#39; + UID + &#39;&relate=fans&page=1&#39;,
- type: &#39;GET&#39;,
- dataType: &#39;json&#39;,
- })
- .done(function (res) {
- utils.log(&#39;获取微博粉丝分页&#39;, res)
- if (res && res.users) {
- if (res.users.length === 0) {
- return end()
- }
- deletePage++
- utils.log(&#39;第 &#39;, deletePage, &#39; 页&#39;)
- // 循环promise
- const promisesTask = res.users.map((item, index) => {
- return () =>
- new Promise(resolve => {
- setTimeout(() => {
- const id = item.id
- const no = index + 1
- if (stop) return
- utils.log(&#39;待删除粉丝&#39;, no, id)
- utils.showDeleteNotice(FOLLOWERS_COUNT, no)
- deleteFans(id).done(resolve)
- }, Math.random() * 500 + 500)
- })
- })
- utils.serialPromise(promisesTask, () => {
- setTimeout(() => {
- getFansList()
- }, 1000)
- })
- }
- })
- .fail(utils.alertFail)
- }
- // 移除粉丝
- const deleteFans = id => {
- const postData = { uid: id }
- return jq
- .ajax({
- url: &#39;/ajax/profile/destroyFollowers&#39;,
- contentType: &#39;application/json;charset=UTF-8&#39;,
- type: &#39;POST&#39;,
- dataType: &#39;json&#39;,
- headers: {
- &#39;x-xsrf-token&#39;: TOKEN,
- },
- data: JSON.stringify(postData),
- })
- .done(function (res) {
- deletedCount++
- utils.log(&#39;已删除粉丝&#39;, id, res)
- })
- .fail(utils.alertFail)
- }
- /** ===== 清空赞列表 ===== */
- // 清空赞列表
- const cleanLike = () => {
- const url = URL_PREFIX + &#39;/page/like/&#39; + UID
- if (!utils.checkURL(url, &#39;我的赞&#39;)) return
- const r = confirm(&#39;echo博主@当时我就没憋住温馨提示:想清楚了吗?这是要清空所有的赞哦,确定吗?&#39;)
- if (r === true) {
- reset()
- c_btn.show()
- utils.showNotice(&#39;马上开始移除赞&#39;)
- getLikeList()
- }
- }
- // 获取微博赞列表
- const getLikeList = () => {
- if (stop) return
- // 微博好像有bug,第1页的赞被删除后,后面的列表就无法显示,所以暂时不删除第1页数据
- if (deletePage === 0) {
- deletePage = 1
- }
- jq.ajax({
- url: &#39;/ajax/statuses/likelist?uid=&#39; + UID + &#39;&relate=fans&page=1&#39;,
- type: &#39;GET&#39;,
- dataType: &#39;json&#39;,
- })
- .done(function (res) {
- utils.log(&#39;获取微博赞分页&#39;, res)
- if (res && res.data && res.data.list) {
- if (res.data.list.length === 0) {
- return end()
- }
- deletePage++
- utils.log(&#39;第 &#39;, deletePage, &#39; 页&#39;)
- // 循环promise
- const promisesTask = res.data.list.map((item, index) => {
- return () =>
- new Promise(resolve => {
- setTimeout(() => {
- const id = item.id
- const no = index + 1
- if (stop) return
- utils.log(&#39;待删除赞&#39;, no, id)
- utils.showDeleteNotice(null, no)
- deleteLike(id).done(resolve)
- }, Math.random() * 500 + 500)
- })
- })
- utils.serialPromise(promisesTask, () => {
- setTimeout(() => {
- getLikeList()
- }, 1000)
- })
- }
- })
- .fail(utils.alertFail)
- }
- // 移除赞
- const deleteLike = id => {
- const postData = { id: String(id) }
- return jq
- .ajax({
- url: &#39;/ajax/statuses/cancelLike&#39;,
- contentType: &#39;application/json;charset=UTF-8&#39;,
- type: &#39;POST&#39;,
- dataType: &#39;json&#39;,
- headers: {
- &#39;x-xsrf-token&#39;: TOKEN,
- },
- data: JSON.stringify(postData),
- })
- .done(function (res) {
- deletedCount++
- utils.log(&#39;已删除赞&#39;, id, res)
- })
- .fail(utils.alertFail)
- }
- /** ===== 清空收藏列表 ===== */
- // 清空收藏列表
- const cleanFav = () => {
- const url = URL_PREFIX + &#39;/page/fav/&#39; + UID
- if (!utils.checkURL(url, &#39;我的收藏&#39;)) return
- const r = confirm(&#39;echo博主@当时我就没憋住温馨提示:想清楚了吗?这是要清空所有的 收藏 哦,确定吗?&#39;)
- if (r === true) {
- reset()
- c_btn.show()
- utils.showNotice(&#39;马上开始移除收藏&#39;)
- getFavList()
- }
- }
- // 获取微博收藏列表
- const getFavList = () => {
- if (stop) return
- jq.ajax({
- url: &#39;/ajax/favorites/all_fav?uid=&#39; + UID + &#39;&page=1&#39;,
- type: &#39;GET&#39;,
- dataType: &#39;json&#39;,
- })
- .done(function (res) {
- utils.log(&#39;获取微博收藏分页&#39;, res)
- if (res && res.data) {
- if (res.data.length === 0) {
- return end()
- }
- deletePage++
- utils.log(&#39;第 &#39;, deletePage, &#39; 页&#39;)
- // 循环promise
- const promisesTask = res.data.map((item, index) => {
- return () =>
- new Promise(resolve => {
- setTimeout(() => {
- const id = item.id
- const no = index + 1
- if (stop) return
- utils.log(&#39;待删除收藏&#39;, no, id)
- utils.showDeleteNotice(null, no)
- deleteFav(id).done(resolve)
- }, Math.random() * 500 + 500)
- })
- })
- utils.serialPromise(promisesTask, () => {
- setTimeout(() => {
- getFavList()
- }, 1000)
- })
- }
- })
- .fail(utils.alertFail)
- }
- // 移除收藏
- const deleteFav = id => {
- const postData = { id: String(id) }
- return jq
- .ajax({
- url: &#39;/ajax/statuses/destoryFavorites&#39;,
- contentType: &#39;application/json;charset=UTF-8&#39;,
- type: &#39;POST&#39;,
- dataType: &#39;json&#39;,
- headers: {
- &#39;x-xsrf-token&#39;: TOKEN,
- },
- data: JSON.stringify(postData),
- })
- .done(function (res) {
- deletedCount++
- utils.log(&#39;已删除收藏&#39;, id, res)
- })
- .fail(utils.alertFail)
- }
- /** ===== 初始化 ===== */
- // 初始化菜单
- const initMenu = () => {
- // 菜单列表
- const menuList = [
- {
- text: &#39;清空微博&#39;,
- onClick: cleanWeibo,
- },
- {
- text: &#39;清空关注&#39;,
- onClick: cleanFollow,
- },
- {
- text: &#39;清空粉丝&#39;,
- onClick: cleanFans,
- },
- {
- text: &#39;清空收藏&#39;,
- onClick: cleanFav,
- },
- {
- text: &#39;清空赞&#39;,
- onClick: cleanLike,
- },
- {
- text: &#39;by@阿憋&#39;,
- onClick: fold,
- },
- ]
- // 生成菜单
- c_menu.css({
- position: &#39;fixed&#39;,
- top: 80,
- left: 10,
- })
- const hideBtn = jq(&#39;<div>&#39;)
- hideBtn
- .css({
- width: 40,
- height: 20,
- background: &#39;#fff&#39;,
- border: &#39;1px solid #f00&#39;,
- cursor: &#39;pointer&#39;,
- lineHeight: &#39;20px&#39;,
- textAlign: &#39;center&#39;,
- fontSize: 12,
- })
- .text(&#39;收起&#39;)
- .click(() => {
- fold = !fold
- if (fold) {
- hideBtn.text(&#39;阿憋&#39;)
- container.hide()
- } else {
- hideBtn.text(&#39;收起&#39;)
- container.show()
- }
- })
- const container = jq(&#39;<div>&#39;)
- container.css({
- width: 140,
- border: &#39;3px solid #f00&#39;,
- background: &#39;#f60&#39;,
- zIndex: 9999,
- fontSize: 14,
- textAlign: &#39;center&#39;,
- })
- menuList.forEach((item, index) => {
- const div = jq(`<div>${item.text}</div>`)
- div.css({
- cursor: &#39;pointer&#39;,
- padding: &#39;5px 10px&#39;,
- borderTop: index === 0 ? &#39;&#39; : &#39;1px solid #000&#39;,
- })
- div.click(() => {
- if (item.onClick) item.onClick()
- })
- container.append(div)
- })
- c_menu.append(hideBtn)
- c_menu.append(container)
- c_app.append(c_menu)
- }
- // 初始化按钮
- const initBtn = () => {
- // 生成按钮
- c_btn.css({
- display: &#39;none&#39;,
- position: &#39;fixed&#39;,
- top: 70,
- right: 10,
- width: 140,
- height: 25,
- border: &#39;1px solid #0f0&#39;,
- background: &#39;#fff&#39;,
- zIndex: 9999,
- fontSize: 14,
- textAlign: &#39;center&#39;,
- cursor: &#39;pointer&#39;,
- })
- c_btn.text(&#39;停止&#39;).click(() => {
- stop = true
- c_btn.hide()
- c_notice.hide()
- utils.log(&#39;已停止操作&#39;)
- })
- c_app.append(c_btn)
- }
- // 初始化提示框
- const initNotice = () => {
- // 生成提示框
- c_notice.css({
- display: &#39;none&#39;,
- position: &#39;fixed&#39;,
- top: 100,
- right: 10,
- width: 140,
- border: &#39;1px solid #00f&#39;,
- background: &#39;#fff&#39;,
- zIndex: 9999,
- fontSize: 14,
- textAlign: &#39;center&#39;,
- })
- c_app.append(c_notice)
- }
- // 初始化
- const init = () => {
- reset()
- initMenu()
- initBtn()
- initNotice()
- }
- init()
- })()
复制代码 代码块是上面的 但是你得用到那个插件 插件可以自己搜索引擎搜
或者直接去这文章底部下就好了
<a href="http://link.zhihu.com/?target=https%3A//blog.csdn.net/wangwei490202517/article/details/128366525" data-draft-node="block" data-draft-type="link-card" data-image="http://pic3.zhimg.com/v2-ef42167e4f507a2019f0fb293d33a346_120x160.jpg" data-image-width="497" data-image-height="648" class=" wrap external" target="_blank" rel="nofollow noreferrer">2022年12月最新微博新版批量删除微博博文代码_删除清空微博博文的微博批量删除代码与方法_星爷万岁呀的博客-CSDN博客_批量删除微博代码如有不懂的可以私我 帮你解决 |