// ==UserScript==
// @name 巴哈姆特黑名單、關鍵字過濾文章留言
// @namespace https://home.gamer.com.tw/moontai0724
// @version 2.3.1
// @description 在巴哈姆將黑名單、關鍵字過濾文章留言,在頂端列可以開關過濾器(一次性)
// @author moontai0724
// @match https://forum.gamer.com.tw/B.php*
// @match https://forum.gamer.com.tw/Bo.php*
// @match https://forum.gamer.com.tw/C.php*
// @match https://forum.gamer.com.tw/Co.php*
// @match https://forum.gamer.com.tw/search.php*
// @grant GM_xmlhttpRequest
// @connect home.gamer.com.tw
// @require https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js
// @supportURL https://home.gamer.com.tw/moontai0724
// @downloadURL none
// ==/UserScript==
(function () {
'use strict';
if (!localStorage.getItem("BLH_Setting")) localStorage.setItem("BLH_Setting", JSON.stringify({
switch: {
keywordPostFliter: true,
keywordCommentFliter: true,
blacklistPostFliter: true,
blacklistCommentFliter: true,
contentLengthPostFliter: false,
contentLengthCommentFliter: false,
},
lengthLimit: {
contentLengthPostLimit: 2,
contentLengthCommentLimit: 2
},
data: {
forceShowList: [],
forceHideList: [],
blockKeywords: [],
postBlockKeywords: [],
commentBlockKeywords: []
}
}));
var setting = JSON.parse(localStorage.getItem("BLH_Setting"));
// 加入隱藏切換
jQuery('head').append('');
jQuery('.BH-menuE').append('
') ? data.response.split('
')[1].replace('
', '').split(',') : [])))
});
});
}
function openSettingWindow() {
// black background
let BLH_SW_Background = document.createElement("div");
BLH_SW_Background.id = "BLH_SW_Background";
BLH_SW_Background.setAttribute("onmousedown", "javascript:if(!jQuery(this).hasClass('mouseenter')) jQuery('#BLH_SW_Background').remove();");
BLH_SW_Background.style = "background-color: rgba(0, 0, 0, 0.5); z-index: 95; position: fixed; top: 0px; bottom: 0px; left: 0px; right: 0px; width: 100%; height: 100%; padding-top: 35px;" +
" border: 1px solid #a7c7c8;" +
" display: flex; align-items: center; justify-content: center;" +
" -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box;";
document.body.appendChild(BLH_SW_Background);
// window case
let BLH_SW_Case = document.createElement("div");
BLH_SW_Case.id = "BLH_SW_Case";
BLH_SW_Case.setAttribute("onmouseenter", "javascipt:jQuery('#BLH_SW_Background').addClass('mouseenter');");
BLH_SW_Case.setAttribute("onmouseleave", "javascipt:jQuery('#BLH_SW_Background').removeClass('mouseenter');");
BLH_SW_Case.style = "position: absolute; height: 80%; width: 90%; overflow: hidden;" +
" display: flex; align-item: stretch; flex-direction: column;" +
" background-color: #FFFFFF; border: 1px solid #a7c7c8;";
document.getElementById("BLH_SW_Background").appendChild(BLH_SW_Case);
// title
let BLH_SW_Title = document.createElement("div");
BLH_SW_Title.setAttribute("style", "display: flex; align-items: center; justify-content: center; width: 100%; min-height: 35px;" +
" background-color: #E5F7F8; color: #484b4b;" +
" font-size: 22px; font-weight: bold; font-family: '微軟正黑體', 'Microsoft JhengHei', '黑體-繁', '蘋果儷中黑', 'sans-serif';");
BLH_SW_Title.innerHTML = "過濾器設定";
document.getElementById("BLH_SW_Case").appendChild(BLH_SW_Title);
// content
let BLH_SW_Content = document.createElement("div");
BLH_SW_Content.id = "BLH_SW_Content";
BLH_SW_Content.setAttribute("style", "display: flex; align-items: center; justify-content: center; flex-flow: row wrap; flex-grow: 1; overflow: auto; padding: 10px;" +
" background-color: #FFFFFF;" +
" word-break: break-all; font-size: 16px; line-height: 150%; text-align: center; font-family: 微軟正黑體, Microsoft JhengHei, 黑體-繁, 蘋果儷中黑, sans-serif;" +
" -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box;");
document.getElementById("BLH_SW_Case").appendChild(BLH_SW_Content);
// bottom element
let BLH_SW_BottomArea = document.createElement("div");
BLH_SW_BottomArea.id = "BLH_SW_BottomArea";
BLH_SW_BottomArea.style = "display: flex; align-items: center; justify-content: center;" +
" background-color: #E5F7F8;" +
" width: 100%; min-height: 35px;";
document.getElementById('BLH_SW_Case').appendChild(BLH_SW_BottomArea);
// close button
let BLH_SW_CloseButton = document.createElement('button');
BLH_SW_CloseButton.innerHTML = '完成';
BLH_SW_CloseButton.setAttribute("onclick", "jQuery('#BLH_SW_Background').remove();");
document.getElementById('BLH_SW_BottomArea').appendChild(BLH_SW_CloseButton);
// content
jQuery('#BLH_SW_Content').append(`
切換
黑名單過濾
黑名單文章過濾:
黑名單留言過濾:
關鍵字過濾
關鍵字文章過濾:
關鍵字留言過濾:
字數過濾
文章字數過濾:
留言字數過濾:
字數過濾
文章字數下限:
留言字數下限:
關鍵字封鎖(不分大小寫)
當設定在全域變數中,下方就不需再設定同樣的字詞(系統會體醒已在全域過濾清單中有)。
當文章與留言都有相同的變數,會自動改到全域變數中。
全域過濾關鍵字(文章與留言皆會過濾)
ID封鎖(不分大小寫)
黑名單會自動獲取已經被黑名單的列表,但若要手動添加,可於上方參數進行添加。
可以添加強制顯示、強制隱藏,這兩個參數會優先於黑名單列表。
ID只能在強制顯示與強制隱藏其中一個清單內,不會有重複(輸入時會被提醒)。
輸入的ID不分大小寫。
`);
let setting = JSON.parse(localStorage.getItem("BLH_Setting"));
for (let key in setting.switch) (document.getElementById(key).innerHTML = (setting.switch[key] ? '開' : '關'), document.getElementById(key).parentNode.style.color = setting.switch[key] ? 'olive' : 'crimson');
for (let key in setting.lengthLimit) document.getElementById(key).innerHTML = setting.lengthLimit[key];
for (let key in setting.data) {
for (let i = 0; i < setting.data[key].length; i++) {
jQuery('#' + key).append(`
` + setting.data[key][i] + `
`);
}
}
}
jQuery('body').append('');
})();