Github搜索净化

搜索时屏蔽github上的用户CiroSantilli和wumaoland等人的仓库

目前為 2023-12-15 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name Github搜索净化
// @namespace https://github.com/danicastarr
// @version 1.0.4
// @description 搜索时屏蔽github上的用户CiroSantilli和wumaoland等人的仓库
// @license GPLv3
// @author DanicaStar
// @include http*://github.com/search*
// @run-at document-end
// ==/UserScript==
(function (){
// Github更新时可能会发生变化,需要手动更改!
// cardClass为外面的圆角矩形,就是项目的卡片
// nameTextClass为仓库名
const cardClass = 'div.Box-sc-g0xbh4-0.hKtuLA'
const nameTextClass = 'span.Text-sc-17v1xeu-0.qaOIC.search-match'
let ban = ['cirosantilli', 'wumaoland', 'codin-stuffs', 'cheezcharmer', 'Dimples1337', 'Dujltqzv', 'gege-circle', 'PCL/', 'zhaohmng-outlook-com', 'zaohmeing', 'Daravai1234', 'candice531033938', 'jk-ice-cream', 'sky8964', 'pxvr-official', 'zpc1314521', 'jjzhang166', 'panbinibn'];

function run() {
  let cards = document.querySelectorAll(cardClass);
  cards.forEach((el) => {
    let nameNode = el.querySelectorAll(nameTextClass)[0].innerHTML;
    ban.forEach((person) => {
      if (nameNode.includes(person)) {
        el.remove()
      }
    })
  })
}

// 首次运行
run()

// github 路由更新时
function pageChange(url) {
  // 保证时机
  setTimeout(() => {
    run()
  }, 1000)
}


// 重写 history event
let _wr = function(type) {

  let orig = history[type];
  return function() {

    let rv = orig.apply(this, arguments);

    let e = new Event(type);
    e.arguments = arguments;

    window.dispatchEvent(e);
    return rv;
  }
}

// 重写方法
history.pushState = _wr('pushState');
//监听
window.addEventListener('pushState', function(e) {
  pageChange(location.href);
})


})();