Greasy Fork

Greasy Fork is available in English.

css-巴哈姆特開關廣場聊天室

BAHA Chatroom Switch

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         css-巴哈姆特開關廣場聊天室
// @namespace    minorainy
// @version      1.0.1
// @author       minorainy(MinoRaiNy)
// @homepage     https://home.gamer.com.tw/homeindex.php?owner=r831113
// @match        https://forum.gamer.com.tw/B.php*
// @match        https://forum.gamer.com.tw/C.php*
// @match        https://forum.gamer.com.tw/Co.php*
// @grant        none
// @description  BAHA Chatroom Switch
// ==/UserScript==

(function() {
    "use strict";
    var _defaultmode = "hide";
    var _ShowBlackList = [];
    var _HideWhiteList = [];
    var _HideSideChat = false;
    var _searchpart = location.search.split("&");
    var _searchpart2 = _searchpart[0].split("=");
    var _bsn = _searchpart2[1];

    if(location.pathname == "/B.php" && _defaultmode == "hide" && _HideWhiteList.indexOf(_bsn) == -1 || location.pathname == "/B.php" && _defaultmode == "show" && _ShowBlackList.indexOf(_bsn) != -1) {
        var _creatediv = document.createElement("div");
        _creatediv.id ="toggle_button";
        _creatediv.setAttribute("align", "center");
        document.getElementById("chatRoom").insertAdjacentHTML('beforebegin',_creatediv.outerHTML);
        let changed = false
        let interval = setInterval(() => {
            console.log(document.getElementById('chatRoom'))
            if (document.getElementById('chatRoom').style.height != "0px") {
                changed = true
                document.getElementById("chatRoom").style.height = "0px";   
            }
        }, 500)
        _createButton("show_chat_button", "開啟廣場聊天室", "toggle_button");
        let button = document.getElementById("show_chat_button")
        document.getElementById("show_chat_button").onclick = function() {
            clearInterval(interval)
            if(document.getElementById("chatRoom").style.height =="0px") {
                button.innerHTML = "關閉廣場聊天室";
                var _removechatroom = document.getElementById("chatRoom").style.height = "450px";
                var _removeaccogrouplist = document.getElementsByClassName("BH-rbox BH-list1 FM-rbox16");
                for(var x=_removeaccogrouplist.length-1;x>=0;x--) {
                    if(_removeaccogrouplist[x] && _removeaccogrouplist[x].parentElement) {
                    }
                }
                var _removeaccogroup = document.getElementsByTagName("h5");
                for(var i=_removeaccogroup.length-1;i>=0;i--) {
                    if(_removeaccogroup[i] && _removeaccogroup[i].parentElement && _removeaccogroup[i].innerHTML == "相關群組") {
                        _removeaccogroup[i].parentElement.removeChild(_removeaccogroup[i]);
                    }
                }
            } else {
                var _createchatroom = document.createElement("div");
                _createchatroom.id ="chatRoom";
                _createchatroom.setAttribute("style", "margin-bottom:10px;");
                document.getElementById("chatRoom").style.height = "0px";
                button.innerHTML = "開啟廣場聊天室";

                var im_forum = new BAHA_IM_FORUM('forum',{bsn:_bsn});
            }
        };
    }

    if(_HideSideChat === true) {
        var element = document.getElementById("btn_quick");
    }
})();
function _createButton(_id, _text, _place) {
    var _create = document.createElement("BUTTON");
    _create.id = _id;
    _create.appendChild(document.createTextNode(_text));
    document.getElementById(_place).appendChild(_create);
}