微博拉黑所有点赞用户

批量拉黑微博点赞用户

目前為 2019-01-29 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         微博拉黑所有点赞用户
// @namespace    http://yenkn.com/
// @version      0.1
// @description  批量拉黑微博点赞用户
// @author       Yenkn
// @match        *://weibo.com/*
// @require      https://cdn.bootcss.com/xhook/1.4.9/xhook.min.js
// @run-at       document-start
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    window.blockAll = async () => {
  const users = document.querySelectorAll('ul[node-type="commentLikeList"] li[uid]');
  const uids = Array.from(users).map(x => x.attributes.uid.value);

  for(const uid of uids) {
    const res = await fetch('https://weibo.com/aj/filter/block?ajwvr=6', {
      method: 'POST',
      body: `uid=${uid}&filter_type=1&status=1&interact=1&follow=1`,
      headers: {
        'Content-Type': 'application/x-www-form-urlencoded',
      }
    })
    const data = await res.json()
    const item = document.querySelector(`li[uid="${uid}"]`)
    item.style.height = 'auto'
    item.style.lineHeight = 'inherit'
    item.appendChild(document.createTextNode(data.msg))
  }
}

xhook.after(function(request, response) {
  if(request.url.indexOf('/aj/like/object/big') !== -1) {
    response.text = response.text.replace('<\\/ul>','<\\/ul><div><a href=\\"javascript:blockAll();\\">拉黑本页全部<\\/a><\\/div>');
  }
});
})();