fofa-filter

fofa过滤器

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         fofa-filter
// @namespace    http://tampermonkey.net/
// @version      0.5
// @description  fofa过滤器
// @author       Wuuconix
// @match        https://fofa.info/result*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=fofa.info
// @grant        none
// @license      MIT
// ==/UserScript==

setTimeout(() => {
  const div = document.querySelector("div.el-autocomplete")
  div.insertAdjacentElement("afterend", button)
  button.addEventListener("click", () => {
    let qbase64 = A2B(new URL(location.href).searchParams.get("qbase64"))
    const titleNodes = document.querySelectorAll("p.hsxa-two-line") //doms having title information
    const hostNodes = document.querySelectorAll("span.hsxa-host > a") //doms having host information
    const length = titleNodes.length
    const existMap = new Set() //judge if the title exist already
    for (let i = 0; i < length; i++) {
      const title = titleNodes[i].textContent.trim()
      if (title == "") { //title if empty, use host to filter
        const host = hostNodes[i].textContent.trim()
        qbase64 += `&&host!="${host}"`
      } else if (!existMap.has(title)) { //title is fresh, filter it
        qbase64 += `&&title!="${title}"`
        existMap.add(title)
      }
    }
    qbase64 = B2A(qbase64)
    const url = new URL(location.href)
    url.searchParams.set("qbase64", qbase64)
    location.replace(url.href)
  })
}, 1000)

const style = document.createElement("style")
style.innerHTML = `
.conix-button {
  position: absolute;
  margin-left: -5px;
  height: 50px;
  padding: 0 10px;
  white-space: nowrap;
  font-size: xx-large;
  background-color: transparent;
  border: none;
  transition: transform .5s;
}
.conix-button:hover {
  cursor: pointer;
  transform: rotate(135deg);
}
`
document.head.appendChild(style)

const button = document.createElement("button")
button.className = "conix-button"
button.textContent = "🗡️"
button.title = "Kill What You Have Tested Intelligently"

/**
 * Binary To Ascii (Palin To Base64) supporting Chinese
 * @param {string} str
 * @returns
 */
function B2A(str) {
  return window.btoa(unescape(encodeURIComponent(str)))
}

/**
 * Ascii To Binary (Base64 To Plain) supporting Chinese
 * @param {string} str
 * @returns
 */
function A2B(str) {
  return decodeURIComponent(escape(window.atob(str)));
}