MCBBS Emoticon Add

愉快的和朋友在论坛斗图吧!

目前為 2020-02-28 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         MCBBS Emoticon Add
// @namespace    http://fang.blog.miri.site
// @version      Beta 2.2.3
// @description  愉快的和朋友在论坛斗图吧!
// @author       Mr_Fang
// @match        https://*.mcbbs.net/*
// @grant        none
// ==/UserScript==

(function() {
    var storage = window.localStorage;
    //如果快捷键冲突可以在最下面修改
    
    //阿方太菜了,不知道为什么这个菜单与MCBBS Extender不兼容
    var usermenu = document.getElementsByClassName("user_info_menu_btn")[0];
    usermenu.innerHTML = usermenu.innerHTML + '<li><a id="mbea_setting">Emoticon Add 设置</a></li>';

    document.getElementById('mbea_setting').addEventListener('click',function(){
        showDialog('<style>.alert_right {background-image: none;padding-right: 0px;padding-left: 0px;}</style><div class=""><b>按规定格式添加即可</b> - 点击确定保存<hr><textarea id="input_setting" style="width: 340px;" rows="20">' + storage.getItem('mbea_setting') + '</textarea>保存后刷新即可生效</div>',
                   'right',
                   '<div style="line-height:30px;"><img src="https://s2.ax1x.com/2020/02/25/3twNzq.png" width="20px"> 设置 - MCBBS Emoticon Add</div>',
                   function() {
            storage["mbea_setting"] = document.getElementById("input_setting").value;
        }
                  );
    })

    var list = "";
    var setting = "";

    setting = "[" + storage.getItem('mbea_setting') + "]";


    //阿方很菜的,不会批量替换,预计下个版本直接批量替换
    console.log(setting);
    console.log(setting.split('\n').length);
    for(var l=0;l<setting.split('\n').length;l++){
        setting = setting.replace('![',"['");
        setting = setting.replace('](',"','");
        setting = setting.replace(')\n',"'],\n");
        //console.log(setting);
    }
    setting = setting.replace(')',"']");

    var arrayList = eval("(" + setting + ")");
    console.log(arrayList);

    for(var i=0;i<arrayList.length;i++){
        list = list + '<img src="' + arrayList[i][1] + '" height="42px"> <font color="gray" size="2">' + arrayList[i][0] + '</font> <button style="float: right;" class="pn pnc" onclick="setCopy(\'[img]' + arrayList[i][1] + '[/img]\');hideMenu(\'fwin_dialog\', \'dialog\')"><strong>复制</strong></button><br>';
    };


    document.onkeydown = function(e) {
        var keyCode = e.keyCode;
        var shiftKey = e.shiftKey;
        var ctrlKey = e.ctrlKey;

        if(ctrlKey && shiftKey && keyCode == 69) {
             showDialog('<style>.alert_right {background-image: none;padding-right: 5px;padding-left: 5px;}</style><b>点击复制按钮即可复制BBCode</b> - 点击确定退出<hr><div class="" style="max-height: 350px;overflow-y: auto;">' + list + '</div>',
                        'right',
                        '<div style="line-height:30px;"><img src="https://s2.ax1x.com/2020/02/25/3twNzq.png" width="20px"> 插入表情 - MCBBS Emoticon Add</div>'
                       );
        }


    };

})();