Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(bangumi_sensitive_words_check): 弹出的输入框预先填充敏感词 #81

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 73 additions & 35 deletions liaune/bangumi_sensitive_words_check.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,83 @@
// @name bangumi 敏感词检测
// @namespace https://github.com/bangumi/scripts/tree/master/liaune
// @description 在发表新话题、日志、吐槽时进行敏感词检测
// @version 0.4
// @version 0.4.3
// @author Liaune
// @license Liaune
// @include /^https?://(bgm\.tv|chii\.in|bangumi\.tv)/*
// @grant none
// ==/UserScript==

(function() {
let Sensitive_words = ["手枪","步枪","医院","皮肤病","精神病","香烟","大麻","摇头丸","可卡因","海洛因","冰毒","春药","妓女","嫖娼","援交","找小姐","找小妹","上门服务","特殊服务","商铺","批发","发票","大发","贷款","作弊","代考","代开","办证","毕业证","学位证","窃听器","手槍","步槍","醫院","皮膚病","精神病","香煙","大麻","搖頭丸","可卡因","海洛因","冰毒","春藥","妓女","嫖娼","援交","找小姐","找小妹","上門服務","特殊服務","商鋪","批發","發票","大發","貸款","作弊","代考","代開","辦證","畢業證","學位證","竊聽器"];
function sensitive_check(obj){
obj.on('blur keyup input', function() {
Sensitive_words.forEach( (el) => {
let patt = new RegExp(el,"g");
let text = obj.val();
if(patt.exec(text)){
let r = confirm("发现敏感词:"+el+",是否删除该词?");
if(r){
obj.val(text.replace(el,''));
}
else {
Sensitive_words.splice(Sensitive_words.indexOf(el), 1);
}
}
});
});
}
//发表新话题
if(location.href.match(/new_topic|topic\/\d+\/edit/)){
sensitive_check($("#title"));
sensitive_check($("#content"));
}
//发表新日志
if(location.href.match(/blog\/create|blog\/\d+\/edit/)){
sensitive_check($("#title"));
sensitive_check($("#tpc_content"));
}
//发表新的条目吐槽或讨论
if(location.href.match(/subject\/\d+/)){
sensitive_check($("#title"));
sensitive_check($("#content"));
sensitive_check($("#comment"));
}
let Sensitive_words = [
"白粉",
"办证","辦證",
"毕业证","畢業證",
"冰毒",
"步枪","步槍",
"春药","春藥",
"大发","大發",
"大麻",
"代开","代開",
"代考",
"贷款","貸款",
"发票","發票",
"海洛因",
"妓女",
"精神病",
"可卡因",
"批发","批發",
"皮肤病","皮膚病",
"嫖娼",
"窃听器","竊聽器",
"上门服务","上門服務",
"商铺","商鋪",
"手枪","手槍",
"铁枪","鐵槍",
"钢枪","鋼槍",
"特殊服务","特殊服務",
"騰訊",
"香烟","香煙",
"学位证","學位證",
"摇头丸","搖頭丸",
"医院","醫院",
"隐形眼镜",
"聊天记录",
"援交",
"找小姐",
"找小妹",
"作弊",
"v信"];

function sensitive_check(obj){
obj.on('blur keyup input', function() {
Sensitive_words.forEach( (el) => {
let patt = new RegExp(el,"g");
let text = obj.val();
if(patt.exec(text)){
if (confirm("发现敏感词:"+el+",是否替换?")){
let r = prompt("敏感词:"+el+",替换为:", el);
obj.val(text.replace(el,r));
}
else Sensitive_words.splice(Sensitive_words.indexOf(el),1);
}
});
});
}
//发表新话题
if(location.href.match(/new_topic|topic\/\d+\/edit/)){
sensitive_check($("#title"));
sensitive_check($("#content"));
}
//发表新日志
if(location.href.match(/blog\/create|blog\/\d+\/edit/)){
sensitive_check($("#title"));
sensitive_check($("#tpc_content"));
}
//发表新的条目吐槽或讨论
if(location.href.match(/subject\/\d+/)){
sensitive_check($("#title"));
sensitive_check($("#content"));
sensitive_check($("#comment"));
}
})();