NGA Recommend Search Button

NGA 增加搜索精华主题按钮

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==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);
    });
})();