Greasy Fork is available in English.
NGA 折叠内容展开后可再次收起
当前为
// ==UserScript==
// @name NGA Re-collapse Button
// @namespace http://greasyfork.icu/zh-CN/scripts/28612-nga-re-collapse-button
// @version 1.0.0.20170815
// @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=11313839
var $Q = jQuery.noConflict();
(function(){
var c = $Q('.collapse_btn');
for(i = 0; c.length > i; i++){
$Q(c[i]).children('button').attr('onclick', $Q(c[i]).children('button').attr('onclick').replace(/^t.+,"/, 'cBtnClick(event,"'));
$Q(c[i]).children('button').css({width:'1.2em', height:'1.2em', padding:'0', outline:'none', 'font-family':'Serif', 'line-height':'1.1em'});
}
var sc = "\
var $Q = jQuery.noConflict();\
function cBtnClick(e, c, n){\
var b = e.target, dB = $Q(b).parent(), dC = dB.next();\
if(dC.html() == ''){\
$Q(b).html('-');\
dC.css({'overflow-y':'hidden','transition':'all 0.5s ease-in-out','-o-transition':'all 0.5s ease-in-out','-moz-transition':'all 0.5s ease-in-out','-webkit-transition':'all 0.5s ease-in-out','-ms-transition':'all 0.5s ease-in-out','max-height':'0px','opacity':'0'});\
dB.css('background', __COLOR.border2);\
ubbcode.collapse.load(dC[0], c, n);\
setTimeout(function(){\
dC.html('<div>' + dC.html() + '</div>');\
dC.css({'max-height':(dC.children().outerHeight(true) + 'px'),'opacity':'1'});\
setTimeout(function(){dC.css({'max-height':'none'});}, 500);\
}, 100);\
return;\
}\
if($Q(b).html() == '+'){\
$Q(b).html('-');\
dB.css('background', __COLOR.border2);\
dC.children().css('display', '');\
dC.css({'max-height':(dC.children().outerHeight(true) + 'px'),'opacity':'1'});\
setTimeout(function(){dC.css({'max-height':'none'});}, 500);\
}\
else{\
$Q(b).html('+');\
dB.css('background', 'none');\
dC.css('max-height', (dC.children().outerHeight(true) + 'px'));\
setTimeout(function(){dC.css({'max-height':'0px','opacity':'0'});}, 10);\
setTimeout(function(){dC.children().css('display', 'none');}, 510);\
}\
}\
";
$Q('<script type="text/javascript" />').html(sc).appendTo('head');
})();