weibo_clean

clean timeline of weibo

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

ستحتاج إلى تثبيت إضافة مثل Stylus لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتتمكن من تثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

(لدي بالفعل مثبت أنماط للمستخدم، دعني أقم بتثبيته!)

// ==UserScript==
// @name        weibo_clean
// @name:zh-CN  清净微博
// @description  clean timeline of weibo
// @description:zh-cn  清净的微博首页
// @match        https://weibo.com/*
// @version     2
// @run-at       document-start
// @namespace   https://weibo.com/
// @icon         https://weibo.com/favicon.ico
// ==/UserScript==

(
  function (){
    var mainpage_by_time = true;
    var ban_hotsearch = true;
    var ban_interest = true;
    const api_name_unread = "/ajax/feed/unreadfriendstimeline";
    const api_name_friendtimeline = "/ajax/feed/friendstimeline";
    const api_name_log = "/ajax/log/";
    const api_cards = "https://weibo.com/ajax/side/cards";
    var _xmlhttprequest = window.XMLHttpRequest;
    class weibo_httprequest extends _xmlhttprequest{
      get responseText(){
        var x = super.responseText;
        if ((ban_hotsearch || ban_interest) && this.responseURL == api_cards){
          var obj = JSON.parse(x);
          if (obj.ok == 1){
              var data = obj.data, p;
              if (ban_hotsearch){
                p = data.findIndex((card) => card.cardid == "1001_hot_search");
                if (p > -1) data.splice(p, 1);
              }
              if (ban_interest){
                p = data.findIndex((card) => card.cardid == "1001_interested");
                if (p > -1) data.splice(p, 1);
              }
              x = JSON.stringify(obj);
          }
        }
        return x;
      }
      open(){
        var url = arguments[1];
        if (url.startsWith(api_name_unread)) {
          arguments[1] = url.replace(api_name_unread, api_name_friendtimeline);
        }
        if (url.startsWith(api_name_log)){
          //this.abort();
          return;
        }
        super.open(...arguments);
      }
    }

    window.XMLHttpRequest = weibo_httprequest;
  }
)();