Created
October 29, 2016 15:44
-
-
Save awn-git/ab2c309891ba836a865fc87a71ba2999 to your computer and use it in GitHub Desktop.
別タブ常駐型ほぼ完全自動アク禁ブックマークレット
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
////////////////////////////////////////////////////////////////////////// | |
// | |
//@title 別タブ常駐型ほぼ完全自動アク禁ブックマークレット | |
//@include http://*.open2ch.net | |
//@private | |
// | |
//作った人: Awn | |
// | |
//改定履歴 | |
//-20161011: とりあえず作ってみた。 | |
//-20161012: 細かい修正。 | |
//-20161012: スレ主の投稿は自動アク禁の対象から除外。 | |
//-20161012: localStorageにまだNG文字列が格納されていない場合、読込ボタンを押下してもlocalStorageからの読込は実行しない。 | |
//-20161012: ボタンの名前を変更(保存ボタン->適用ボタン)し、コメントもちょいちょい変更。 | |
//-20161012: 初回起動時、localStorageにNG文字列が格納されている場合、変数とテキストエリアににそれらを退避する。 | |
//-20161012: 見分けをつけるため、ブックマークレット実行タブのbodyのbgcolorを変える。 | |
//-20161012: 適用ボタンを押した時の見た目を変更(★の色が変わる)。 | |
// | |
//諸注意 | |
//-ご利用は自己責任でお願いします。 | |
//-ブックマークレットは予告なく修正または廃止されることがあります。 | |
//-悪用は厳禁です。 | |
//-改造改良改悪はご自由にどうぞ。 | |
// | |
////////////////////////////////////////////////////////////////////////// | |
//初回起動時の設定 | |
if(document.getElementById("NGNAMES_sv") === null){ | |
//変数 | |
var ngwords = [];//NGワード格納用の配列 | |
var ngnames = [];//NGネーム格納用の配列 | |
var lastnum = 1001;//最終書き込みのレス番号(仮の初期値:1001) | |
var surenusi = "red";//スレ主判定 | |
//UI | |
$("body").append("<hr><b id='NGWORDS_tglicon' style='color:black'>★</b><b style='color:red'>↓NGワード↓</b> <button type='button' id='NGWORDS_sv'>適用</button> <button type='button' id='NGWORDS_rd'>読込</button><br><textarea rows=5 cols=56 id='NGWORDS_AREA'></textarea>"); | |
$("body").append("<hr><b id='NGNAMES_tglicon' style='color:black'>★</b><b style='color:red'>↓NGネーム↓</b> <button type='button' id='NGNAMES_sv'>適用</button> <button type='button' id='NGNAMES_rd'>読込</button><br><textarea rows=5 cols=56 id='NGNAMES_AREA'></textarea>"); | |
//背景色変更 | |
$("body").attr("bgcolor","#e6e6fa");//#e6e6faはlavenderの色 | |
//localStorageのNG文字列を変数とテキストエリアに退避する | |
ngwords = JSON.parse(getStorage("NGWORDS")); | |
if(ngwords !== null){$("#NGWORDS_AREA").val(ngwords.join("\n"));} | |
ngnames = JSON.parse(getStorage("NGNAMES")); | |
if(ngnames !== null){$("#NGNAMES_AREA").val(ngnames.join("\n"));} | |
} | |
//[読込]を押した時の挙動 | |
$("#NGWORDS_rd").click(function(){ | |
ngwords = JSON.parse(getStorage("NGWORDS")); | |
if(ngwords !== null){$("#NGWORDS_AREA").val(ngwords.join("\n"));} | |
}); | |
$("#NGNAMES_rd").click(function(){ | |
ngnames = JSON.parse(getStorage("NGNAMES")); | |
if(ngnames !== null){$("#NGNAMES_AREA").val(ngnames.join("\n"));} | |
}); | |
//[適用]を押した時の挙動 | |
$("#NGWORDS_sv") | |
.click(function(){ | |
ngwords = $("#NGWORDS_AREA").val().split("\n"); | |
ngwords = ngwords.filter(function(e){return e !=="";}); | |
setStorage("NGWORDS",JSON.stringify(ngwords));}) | |
.toggle( | |
function(){$("#NGWORDS_tglicon").css("color","white");}, | |
function(){$("#NGWORDS_tglicon").css("color","black");}) | |
; | |
$("#NGNAMES_sv") | |
.click(function(){ | |
ngnames = $("#NGNAMES_AREA").val().split("\n"); | |
ngnames = ngnames.filter(function(e){return e !=="";}); | |
setStorage("NGNAMES",JSON.stringify(ngnames));}) | |
.toggle( | |
function(){$("#NGNAMES_tglicon").css("color","white");}, | |
function(){$("#NGNAMES_tglicon").css("color","black");}) | |
; | |
///////////////////////////////////// | |
// | |
// 自動アク禁処理 | |
// | |
///////////////////////////////////// | |
//新着レスが自動表示される度に実行 | |
$(document).ajaxComplete(function(){ | |
detectNGs(); | |
}); | |
//NG検出関数 | |
function detectNGs(){ | |
//最終書き込みのレス番号の取得 | |
lastnum = $("dl.hide:last > dd > ares").attr("num"); | |
//スレ主チェック | |
surenusi = $("dl.hide:last > dt > font > font").attr("color"); | |
//スレ主でない書き込みの場合、自動アク禁判定を実行する | |
if( surenusi !== "red"){ | |
//NGワードを見つけたら、該当レス番号をアク禁する | |
if(ngwords !== null ){ | |
$.each(ngwords,function(i,elm){ | |
if($("dl.hide:last > dd").is(":contains("+elm+')')){$("#MESSAGE").val("!aku"+lastnum);$("#submit_button").click();}; | |
}); | |
} | |
//NGネームを見つけたら、該当レス番号をアク禁する | |
if(ngnames !== null){ | |
$.each(ngnames,function(i,elm){ | |
if($("dl.hide:last > dt").is(":contains("+elm+')')){$("#MESSAGE").val("!aku"+lastnum);$("#submit_button").click();}; | |
}); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment