1 | // 1. 使用 chrome 打开 weibo.com (确保你登录了微博) |
2 | // 2. 打开调试窗口,在 console 中贴下面的代码后回车 |
3 | // 3. 如需删除其他微博,请输入一下内容后回车:start(); |
4 |
5 | let mids = []; |
6 | let midIndex = 0; |
7 | let timer = null ; |
8 | let running = false ; |
9 | let http = new XMLHttpRequest(); |
10 |
11 | function cleanNextPage() { |
12 | let url = 'https://weibo.com/p/100505' + $CONFIG[ 'uid' ] + '/home' ; |
13 | http.open( 'GET' , url, true ); |
14 | http.setRequestHeader( 'Content-type' , 'application/x-www-form-urlencoded' ); |
15 | http.send(); |
16 | http.onreadystatechange = function () { |
17 | if (http.readyState != 4 || http.status != 200) { |
18 | return ; |
19 | } |
20 |
21 | let matches = http.responseText.match(/mid=([0-9]+)/g); |
22 | if (matches == null ) { |
23 | stop( '恭喜你,可以重新来过了。如果还有请再执行一遍 ' ); |
24 | return ; |
25 | } |
26 | |
27 | let values = {}; |
28 | matches.forEach( function (match) { |
29 | values[match.substr(4)] = 0; |
30 | }, this ); |
31 |
32 | mids = Object.keys(values); |
33 | timer = setInterval( 'deleteNextWeibo();' , 1000); |
34 |
35 | console.log( '本页有 ' + mids.length + ' 条微博' ); |
36 | } |
37 | } |
38 |
39 | function deleteNextWeibo() { |
40 | if (midIndex >= mids.length) { |
41 | mids = []; |
42 | midIndex = 0; |
43 | clearInterval(timer); |
44 | setTimeout( 'cleanNextPage();' , 1000); |
45 | return ; |
46 | } |
47 |
48 | deleteWeibo(mids[midIndex]); |
49 | midIndex++; |
50 | } |
51 |
52 | function deleteWeibo(mid) { |
53 | http.open( 'POST' , 'https://weibo.com/aj/mblog/del?ajwvr=6' , true ); |
54 | http.setRequestHeader( 'Content-type' , 'application/x-www-form-urlencoded' ); |
55 | http.send( 'mid=' + mid); |
56 | http.onreadystatechange = function () { |
57 | if (http.readyState != 4 || http.status != 200) { |
58 | return ; |
59 | } |
60 |
61 | let json = {} |
62 | try { |
63 | json = JSON.parse(http.responseText); |
64 | } catch (error) { |
65 | return ; |
66 | } |
67 |
68 | if (json.code == 100000) { |
69 | console.log( '删除成功 - ' + mid); |
70 | } |
71 | } |
72 | } |
73 |
74 | function stop(message) { |
75 | clearInterval(timer); |
76 | running = false ; |
77 | console.log(message); |
78 | } |
79 |
80 | function start() { |
81 | if (running) { |
82 | console.log( '进行中...' ); |
83 | return ; |
84 | } |
85 |
86 | console.log( '开始删除' ); |
87 | running = true ; |
88 | mids = []; |
89 | midIndex = 0; |
90 | cleanNextPage(); |
91 | } |
js文件源文件: https://raw.githubusercontent.com/pythias/weibo-start-over/master/weibo-start-over.js
1, 使用 chrome 打开 https://weibo.com 并登录 (https)
2, 打开调试窗口,复制 weibo-start-over.js 中的全部代码, 在 console 中粘贴代码后回车
3, 请在console输入 start()