NGA Recommend Search Button

NGA 增加搜索精华主题按钮

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name         NGA Recommend Search Button
// @namespace    https://greasyfork.org/zh-CN/scripts/33356-nga-recommend-search-button
// @version      0.0.1.20170920
// @icon         http://bbs.nga.cn/favicon.ico
// @description  NGA 增加搜索精华主题按钮
// @author       AgLandy
// @include      /^https?://(bbs\.ngacn\.cc|nga\.178\.com|bbs\.nga\.cn)/.+/
// @grant        none
// @require      http://cdn.bootcss.com/jquery/3.2.1/jquery.min.js
// ==/UserScript==

//发布地址:http://bbs.ngacn.cc/read.php?tid=12485023

var $Q = jQuery.noConflict();

(function() {
    if(!$Q('a[title="搜索"]').length)
        return;
    $Q('a[title="搜索"]').click(function(){
        setTimeout(function(){
            $Q('button:contains("搜索用户")').after('<br><button type="button">搜索精华主题标题</button><br><button type="button">搜索精华主题标题和内容</button>');
            $Q('button:contains("搜索精华")').click(function(){
                var p = $Q(this).parent(), k = p.find(':text')[0], fcs = p.find(':radio:eq(0)')[0], fc = p.find(':radio:eq(1)')[0], fo = p.find('form')[0];
                k.value = k.value.replace(/^\s+|\s+$/g,'');
                if(!k.value)
                    return alert('请输入关键词');
                fo.method = 'post';
                fo.action = '/thread.php?key='+encodeURIComponent(k.value);
                if(fcs.checked)
                    fo.action += '&fid='+commonui.selectForum.get(4, 16).join(',');
                else if(fc.checked)
                    fo.action += '&fid='+commonui.selectForum.get(64).join(',');
                fo.action += '&recommend=1';
                if(/内容/.test(this.innerHTML))
                    fo.action += '&content=1';
                fo.submit();
            });
        },1);
    });
})();