2023年政策修订增补工作正在进行中,欢迎参与!
User:BearBin/js/SidebarEnhance.js
< User:BearBin | js
注意:在保存之后,您可能需要清除浏览器缓存才能看到所作出的变更的影响。
- Firefox/Safari:按住“Shift”的同时单击“刷新”,或按“Ctrl-F5”或“Ctrl-R”(Mac为“⌘-R”)
- Google Chrome:按“Ctrl-Shift-R”(Mac为“⌘-Shift-R”)
- Internet Explorer:按住“Ctrl”的同时单击“刷新”,或按“Ctrl-F5”
- Opera:在“工具→首选项”中清除缓存
- 如果您已登录但该页面出现未登录状态,请尝试在地址栏的地址最后添加代码
?_=1
来访问最新页面。 - 添加代码后的本页地址如下:
-{R|https://moegirl.icu/User:BearBin/js/SidebarEnhance.js?_=1}-
var _addText = '{{Documentation|content=* 工具介绍见[[User:BearBin/js#SidebarEnhance]]。\n* 源代码见[https://github.com/BearBin1215/MoegirlPedia/blob/master/src/gadgets/SidebarEnhance GitHub]。}}';
// <nowiki>
(()=>{"use strict";const e=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)};const t="object"==typeof global&&global&&global.Object===Object&&global;var n="object"==typeof self&&self&&self.Object===Object&&self;const o=t||n||Function("return this")();const r=function(){return o.Date.now()};var i=/\s/;const a=function(e){for(var t=e.length;t--&&i.test(e.charAt(t)););return t};var c=/^\s+/;const l=function(e){return e?e.slice(0,a(e)+1).replace(c,""):e};const s=o.Symbol;var d=Object.prototype,u=d.hasOwnProperty,f=d.toString,m=s?s.toStringTag:void 0;const p=function(e){var t=u.call(e,m),n=e[m];try{e[m]=void 0;var o=!0}catch(e){}var r=f.call(e);return o&&(t?e[m]=n:delete e[m]),r};var v=Object.prototype.toString;const b=function(e){return v.call(e)};var g=s?s.toStringTag:void 0;const h=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":g&&g in Object(e)?p(e):b(e)};const w=function(e){return null!=e&&"object"==typeof e};const y=function(e){return"symbol"==typeof e||w(e)&&"[object Symbol]"==h(e)};var k=/^[-+]0x[0-9a-f]+$/i,j=/^0b[01]+$/i,x=/^0o[0-7]+$/i,T=parseInt;const E=function(t){if("number"==typeof t)return t;if(y(t))return NaN;if(e(t)){var n="function"==typeof t.valueOf?t.valueOf():t;t=e(n)?n+"":n}if("string"!=typeof t)return 0===t?t:+t;t=l(t);var o=j.test(t);return o||x.test(t)?T(t.slice(2),o?2:8):k.test(t)?NaN:+t};var O=Math.max,S=Math.min;const L=function(t,n,o){var i,a,c,l,s,d,u=0,f=!1,m=!1,p=!0;if("function"!=typeof t)throw new TypeError("Expected a function");function v(e){var n=i,o=a;return i=a=void 0,u=e,l=t.apply(o,n)}function b(e){var t=e-d;return void 0===d||t>=n||t<0||m&&e-u>=c}function g(){var e=r();if(b(e))return h(e);s=setTimeout(g,function(e){var t=n-(e-d);return m?S(t,c-(e-u)):t}(e))}function h(e){return s=void 0,p&&i?v(e):(i=a=void 0,l)}function w(){var e=r(),t=b(e);if(i=arguments,a=this,d=e,t){if(void 0===s)return function(e){return u=e,s=setTimeout(g,n),f?v(e):l}(d);if(m)return clearTimeout(s),s=setTimeout(g,n),v(d)}return void 0===s&&(s=setTimeout(g,n)),l}return n=E(n)||0,e(o)&&(f=!!o.leading,c=(m="maxWait"in o)?O(E(o.maxWait)||0,n):c,p="trailing"in o?!!o.trailing:p),w.cancel=function(){void 0!==s&&clearTimeout(s),u=0,i=d=a=s=void 0},w.flush=function(){return void 0===s?l:h(r())},w};const N=function(t,n,o){var r=!0,i=!0;if("function"!=typeof t)throw new TypeError("Expected a function");return e(o)&&(r="leading"in o?!!o.leading:r,i="trailing"in o?!!o.trailing:i),L(t,n,{leading:r,maxWait:n,trailing:i})};$((()=>{mw.loader.addStyleTag("#mw-panel .portal[role=navigation]{padding-bottom:.5em}#mw-panel .portal h3{border-radius:4px;cursor:pointer;display:flex;justify-content:space-between;margin:0;padding:.2em .5em;transition:background-color .2s ease-in-out;-webkit-user-select:none;-moz-user-select:none;user-select:none}#mw-panel .portal h3:hover{background-color:hsla(60,1%,75%,.3)}#mw-panel .portal .folder-icon{height:18px;transition:transform .2s ease-in-out}#mw-panel .portal .body-folded .folder-icon{transform:rotate(-90deg)}#mw-panel .sidebar-enhance-stickywrapper{position:sticky;top:0}.artwork-main .n-card-header__main,.moe-card:not(#moe-article) h2,.moe-card:not(#moe-article) h3{cursor:pointer}.sidebar-enchance-title .n-collapse-item-arrow{float:right}.sidebar-enchance-title .n-collapse-item-arrow svg{transform:rotate(90deg);transition:transform .2s ease-in-out}.sidebar-enchance-title.body-folded .n-collapse-item-arrow svg{transform:rotate(0)}.vector-pinnable-element .vector-menu .vector-menu-heading{cursor:pointer;justify-content:space-between}.vector-pinnable-element .vector-menu .vector-menu-heading.body-folded .folder-icon{transform:rotate(90deg)}.vector-pinnable-element .folder-icon{transition:transform .2s ease-in-out;width:18px}");const e=(e,t,n)=>{e.addClass("sidebar-enchance-title").append(n);let o=!1;e.on("click",(()=>{o?(t.slideDown(200),e.removeClass("body-folded"),o=!1):(t.slideUp(200),e.addClass("body-folded"),o=!0)}))},t=()=>{document.getElementById("mw-panel").style.height=`${document.body.scrollHeight}px`},n=()=>{document.getElementById("#moe-custom-sidenav-block")&&($(".moe-siderail-sticky").prepend($("#moe-custom-sidenav-block")),window.removeEventListener("scroll",n))};let o='<svg class="folder-icon" fill="#666" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M12 16L6 10H18L12 16Z"></path></svg>';switch(mw.config.get("skin")){case"moeskin":o=$("#moe-sitenotice-container .n-collapse-item-arrow"),e($("#moe-custom-sidenav-block h2"),$("#moe-custom-sidenav-block-list"),o.clone()),e($("#side-toc-container h3"),$("#side-toc-container>.moe-table-of-contents"),o.clone()),e($("#p-sl h3"),$("#p-sl>div>div"),o.clone()),e($(".artwork-main .n-page-header"),$(".artwork-main .n-card__content>div"),o.clone()),n(),window.addEventListener("scroll",n);break;case"vector-2022":$(".vector-pinnable-element .vector-menu").each(((t,n)=>{e($(n).children(".vector-menu-heading"),$(n).children(".vector-menu-content"),o)}));break;default:$("#mw-panel .portal").each(((t,n)=>{e($(n).children("h3"),$(n).children(".body"),o)})),$("#mw-panel").append($('<div class="sidebar-enhance-stickywrapper"/>').append($("#p-tb, #p-sl"))),t(),window.addEventListener("resize",t),window.addEventListener("scroll",N(t,400))}}))})();
// </nowiki>