Discuz-tail&replyTools

Discuz Tail & reply tool

目前為 2019-04-02 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name           Discuz-tail&replyTools
// @name:zh-CN     Discuz论坛小尾巴+快捷回复
// @author         Yulei,wycaca
// @namespace      Discuz-tail&replyTools
// @description    Discuz Tail & reply tool
// @description:zh-cn    Discuz小尾巴和快捷回复工具
// @version        1.1
// @create         2013-01-19
// @include        http*/thread*
// @include        http*forum.php?mod=viewthread&tid=*
// @include        http*forum.php?mod=post&action=reply&fid=*
// @include        http*forum.php?mod=post&action=newthread&fid=*
// @copyright      2013+, Yulei
// @copyright      2019+, wycaca
// ==/UserScript==

(function () {
            var _Q = function (d) {
                return document.querySelector(d)
            };
            var w = (typeof unsafeWindow != 'undefined') ? unsafeWindow : window;

            function $(id) {
                return !id ? null : document.getElementById(id);
            }
            //discuz_uid fid tid
            if (w.discuz_uid > 0 || _Q('#um')) { //是否登录,否则退出
                //var inp=document.createElement('input');inp.type="checkbox";inp.id="mUA";inp.checked=true;
                var bar = _Q('.fpd') || _Q('.bar');
                //ptm.appendChild(inp);
                //代码参考:forum.js
                var Psfm = $('postform'),
                    Fps = $('fastpostform');
                var pos = Psfm || Fps;

                //插入尾巴
                function MUA(P) { //Custom 为自定尾巴信息,各喜好修改!
                    var Custom = '[list][/list][float=left]\r\r\r[color=FFFFCC]\
					藏起来的小尾巴,不让你看! \ ';
                    //\r——'+ Gtl +'[/color][/size]         [/float]
                    P.value = w.parseurl(P.value) + Custom;
                }
                var Gtl = w.getcookie("GTL") ? w.getcookie("GTL") : "";

                //截获提交
                function gform(pos) { //fm
                    pos.onsubmit = function () {
                        // if ($('mUA').checked) {
                        MUA(pos.message);
                        // }
                        return w.validate(this);
                    }
                }
                gform(pos);

                //截获快捷键
                if (!window.opera) {
                    w.keyDown = function () {};
                } //非O,USERJS优先权比较低
                function mess(PS) {
                    var fwin = $('fwin_reply');
                    PS.onkeydown = function (event) {
                        if ((event.ctrlKey && event.keyCode == 13 || event.altKey && event.keyCode == 83) || (event.altKey && event.keyCode == 83)) {
                            if (!fwin) {
                                // if ($('mUA').checked) {
                                MUA(PS);
                                // }
                            }
                            if (Psfm) {
                                w.ctlent(event)
                            } else if (fwin) {
                                location.href = "javascript:$('postsubmit').click()";
                            } else {
                                w.seditor_ctlent(event, 'fastpostvalidate($(\'fastpostform\'))')
                            };
                        }
                    }
                }
                //创建选项
                var style = document.createElement("style");
                style.type = "text/css";
                style.textContent = "#mUA{ \
				margin-top:5px;border:1px solid #f6f;color:red;outline:1px solid #f6f;";
                document.head.appendChild(style);
                var Bos = document.createElement("SELECT");
                Bos.id = "mUA";
                Bos.title = "选择自动回复;双击设置";
                var texts = new Array("感谢楼主分享,收下了",
                    "楼主说的对",
                    "大佬牛B,膜拜",
                    "酱油党路过,并水了一帖");
                for (var i = 0; i < texts.length; i++) {
                    var option = document.createElement("option");
                    option.setAttribute("value", i);
                    option.appendChild(document.createTextNode(texts[i]));
                    Bos.appendChild(option);
                }
                Bos.options[0].selected = true;
                //按钮
                var btn = document.createElement("button");
                btn.textContent = "自动回复";
                btn.id = "mUA_btn";
                btn.onclick = addText;

                function addText() {
                    var fpmessage = document.getElementById("fastpostmessage");
                    //快捷回复(最下面那个)
                    if (fpmessage) {
                        fastpostmessage.textContent = Bos.options[Bos.selectedIndex].text;
                    }
                    //独立回复界面
                    else if (document.getElementById("e_iframe").contentWindow) {
                        var e_iframe = document.getElementById("e_iframe").contentWindow.document.body;
                        e_iframe.textContent = Bos.options[Bos.selectedIndex].text;
                    }
                }

                if (bar) {
                    bar.appendChild(Bos);
                    bar.appendChild(btn);
                    mess(pos.message);
                };

                $('mUA').onchange = addText;

                //if(getcookie('fastpostrefresh') == 1) {$('mUA').checked=true;}

                //劫持楼层回复
                var ShowW = w.showWindow;
                w.showWindow = function (k, url, mode, cache, menuv) {
                    setTimeout(function () {
                        var pof = $('postform');
                        _Q('.bar').appendChild(Bos);
                        mess(pof.message);
                        gform(pof);
                    }, 1300);
                    return ShowW(k, url, mode, cache, menuv);
                }

            }

    /* (支持:Opera12;兼容其它C/F;系统DZ)
     *  好尾巴,你值得拥有.
     * 简单成就精彩 -|- by Yulei 本脚本只作学习研究参考用,版权所有 不得滥用、商用、它用,否则追究,后果自负 */
})();