- 首先,登錄pc端的微博頁面,并切換到自己微博列表的第一頁(url 應該是
https://weibo.com/YOURNAME/profile...這樣的形式 )
- 在 chrome 瀏覽器調試工具的 console 命令行( chrome如何打開控制臺-百度經驗
)中,貼入以下代碼:
const delay = 6180; // 間隔時間
const onlyForward = true; // 僅刪轉發(fā)
const ajwvr = 6;
const cfg = window.$CONFIG;
let pagebar = 0;
function getQuery() {
const { protocol, host, pathname, search } = document.location;
const query = search.substr(1).split('&').reduce((obj, item) => {
const [key, value] = item.split('=');
obj[key] = value;
return obj;
}, Object.create(null));
return { ...document.location, query: { page: 1, profile_type: 1, ...query } };
}
function doDel() {
const { protocol, host, pathname, search, query } = getQuery();
var list = document.querySelectorAll('.WB_cardwrap.WB_feed_type');
var nonselfList = onlyForward
? [].filter.call(list, ele => ele.querySelector('.WB_expand'))
: list;
if (!nonselfList.length) {
// console.log(query, '沒有', document.querySelector('.page.next'));
return Promise.resolve(null);
}
var promises = nonselfList.map(ele => fetch(`${protocol}//${host}/aj/mblog/del?ajwvr=${ajwvr}`, {
"headers": {
"accept": "*/*",
"accept-language": "zh-CN,zh;q=0.9,en;q=0.8,zh-TW;q=0.7",
"cache-control": "no-cache",
"content-type": "application/x-www-form-urlencoded",
"pragma": "no-cache",
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
"sec-fetch-site": "same-origin",
"x-requested-with": "XMLHttpRequest"
},
"referrer": `${protocol}//${host}${pathname}?profile_ftype=${query.profile_ftype}&is_all=1`,
"referrerPolicy": "no-referrer-when-downgrade",
"body": "mid=" + ele.getAttribute('mid'),
"method": "POST",
"mode": "cors",
"credentials": "include"
}));
return Promise.all(promises);
}
function getMore() {
const { protocol, host, pathname, search, query } = getQuery();
const url = `${protocol}//${host}/p/aj/v6/mblog/mbloglist?ajwvr=${ajwvr}&domain=${cfg.domain}&is_search=0&visible=0&is_all=1&is_tag=0&profile_ftype=${query.profile_ftype}&page=${query.page}&pagebar=${pagebar++}&pl_name=Pl_Official_MyProfileFeed__20&id=${cfg.page_id}&script_uri=${pathname}&feed_type=0&pre_page=${query.page}&domain_op=${cfg.domain}&__rnd=${Date.now()}`;
fetch(url)
.then(res=>res.json())
.then(json=>{
const $lst = document.querySelector('[node-type=feed_list]');
if (pagebar === 0) {
$lst.innerHTML = json.data;
} else {
$lst.insertAdjacentHTML('beforeEnd', json.data);
}
})
.then(checkPage);
}
function checkPage() {
if (pagebar <= 1) {
getMore();
return;
}
doDel()
.then((resArr) => {
if (!resArr || !resArr.length || resArr.some(res => res.status >= 300)) {
if (document.querySelector('.page.next')) {
console.log('next page', resArr, '崴');
setTimeout(() => document.querySelector('.page.next:last-of-type').click(), 500);
setTimeout(checkPage, delay * 2);
} else {
getMore();
}
return;
}
pagebar = 0;
console.log('next page', resArr);
setTimeout(() => document.querySelector('.page.next').click(), 500);
setTimeout(checkPage, delay);
});
}
checkPage();
- 如果連續(xù)刪除的已發(fā)微博數量較多,官方為防止操作過于頻繁,每隔一段時間就會刪除失敗,這時只要等待即可,腳本會繼續(xù)執(zhí)行
- 該腳本還很原始,如果條數多,刪除速度會很慢,請耐心使用
- 刪到最后一頁后,可能需要手動翻回首頁重復若干次
最后編輯于 :
?著作權歸作者所有,轉載或內容合作請聯系作者
【社區(qū)內容提示】社區(qū)部分內容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發(fā)布,文章內容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。