4chan gpt2 checker

2023-01-12, 4:05:24 a.m.

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        4chan gpt2 checker
// @namespace   Violentmonkey Scripts
// @match       https://boards.4channel.org/*
// @grant       none
// @version     0.2
// @author      w w w w
// @license     MIT
// @description 2023-01-12, 4:05:24 a.m.
// ==/UserScript==


(function () {
  const url = "https://openai-openai-detector.hf.space/?";

  [...document.getElementsByClassName("postMessage")].forEach(e => {
    const text = e.innerText.replaceAll(/^>>[0-9]+(?:[ \s]\(OP\)){0,1}$/gm, "").trim()
    if (text.length == 0) return

    const row = document.createElement("span")
    row.style.marginLeft = "0.25em"

    const postinfo = [...e.parentElement.children].filter(e2 => e2.classList.contains("postInfo"))

    if (!postinfo) return

    postinfo[0].insertBefore(row, [...postinfo[0].children].filter(e2 => e2.tagName == "A").at(-1))

    const btn = document.createElement("a")
    btn.style.cursor = "pointer"
    btn.textContent = "Check"
    row.appendChild(btn)

    const result = document.createElement("span")
    row.appendChild(result)

    btn.addEventListener("click", e2 => {
      btn.style.cursor = ""
      fetch(url + encodeURI(text)).then(res => res.json()).then(res => {
        console.log(res)
        result.textContent = `${Math.round(res.fake_probability * 100)}% fake`
        btn.parentElement.removeChild(btn)
      })
      e2.preventDefault()
    })
  })
})()