网络审查词API

收集的GitHub上的 “那种” 项目并汇总,使用cloudflare worker搭建

地址:https://block-words-api.runoneall.us.kg
指定word字段以使用
示例:https://block-words-api.runoneall.us.kg/?word=qwq

词库更新:https://www.nodeloc.com/d/16422
使用special_list解决误封情况

原始码:

```javascript addEventListener('fetch', event => { event.respondWith(handleRequest(event.request)) })

async function JsonResponse(JsonString) {
return new Response(JSON.stringify(JsonString), {
headers: { ‘content-type’: ‘application/json’ },
})
}

async function handleRequest(request) {

let rep_json = {}
const url = new URL(request.url)
const queryString = url.search
if (!queryString) {
    rep_json['status'] = 'error'
    rep_json['body'] = {
        is_found: false,
        msg: 'no word to found'
    }
    return JsonResponse(rep_json)
}
const queryParams = new URLSearchParams(queryString)
const inputString = queryParams.get('word')
console.log(inputString)
const isSource = queryParams.get("source")
console.log(isSource)

if (inputString === null && isSource === null) {
    rep_json['status'] = 'error'
    rep_json['body'] = {
        is_found: false,
        msg: 'no word to found'
    }
    return JsonResponse(rep_json)
}

if (inputString !== null && isSource === null) {
    const special_list = [
        'bilibili',
        'bilibili.com/video/av',
        'bilibili.com/video/AV'
    ]
    for (let keyword of special_list) {
        if (inputString.includes(keyword)) {
            rep_json['status'] = 'warning'
            rep_json['body'] = {
                is_found: false,
                msg: 'word in white list'
            }
            return JsonResponse(rep_json)
        }
    }
}

const block_words_url = "https://runoneall.serv00.net/Files/block-words.txt"
const block_words_rep_text = (await fetch(block_words_url)).text()
const block_words_text = await block_words_rep_text
if (inputString === null && isSource !== null) {
    return new Response(block_words_text, {headers: { 'content-type': 'text/plain; charset=utf-8' }})
}

const block_words_list = block_words_text.split('\n')
for (let keyword of block_words_list) {
    if (inputString.includes(keyword)) {
        rep_json['status'] = 'success'
        rep_json['body'] = {
            is_found: true,
            originalString: inputString,
            matchedKeyword: keyword
        }
        return JsonResponse(rep_json)
    }
}

rep_json['status'] = 'warning'
rep_json['body'] = {
    is_found: false,
    originalString: inputString,
    msg: 'no matched keyword'
}
return JsonResponse(rep_json)

}
```

自建审查!!!

好东西啊。不知道效果怎么样。

正所谓欲练神功、必先自宫。

@“Xnoob”#p156447 好东西,自建的?我给你打个原创标签?:xhj07:

试了下,很多政治相关词汇都没收录,生产环境不敢用。。。

确实好东西 厉害了

@“James”#p156451

审查我可是专业的,我做过很多不同的言论审查系统

@“小鱼飘飘”#p156457

是的,代码我写的,但违禁词是收集的

@“Yucho”#p156461

没啥好词库,等我再找找,现在只有4000个

建议到海外中文神U/黑产/黄色社区再沉淀一下(

比较新的专有名词好像都没怎么收录(

甚至连现在大陆鉴证圈的一些比较火的新词也没有(

:baishengnv1:

@“知ら無い”#p156506

像我这种用2G网的怎么可能知道嘛(((

@“Xnoob”#p156447 这是实际效果还是就这样的,还是我不会玩

Image description</s>Image description<e>


@“lusky”#p156525 这是个JSON(

`false`是没问题
`true`是有问题

第二个是你输入的内容
第三个是符合的屏蔽项

例如:

Image description![Image description](https://s.rmimg.com/2024-11-17/1731821015-650633-ff6442bc-88ea-41eb-a524-fc4b22de3396.png)

@“lusky”#p156525 应该是这样, 你点一下浏览器上方的</s>美观输出<e>应该会显示的更明了一些

>

@“知ら無い”#p156535 应该是这样, 你点一下浏览器上方的美观输出应该会显示的更明了一些

这个词汇是不是很危险

@“lusky”#p156560

是的,你如果想知道可以Google: “fa lun gong”

源码已放出

>

@“Xnoob”#p156590 是的,你如果想知道可以Google: “fa lun gong”

不我不想知道

@“lusky”#p156605

那就好,那就好:huaji09:

@“Yucho”#p156461

现在可以了(((

https://www.nodeloc.com/d/16422

存在误杀情况,例如“bilibili”因为含有“bi”会判定为存在违禁词