Widget:TalkToc:修订间差异

H萌娘,万物皆可H的百科全书!
跳到导航 跳到搜索
imported>=海豚=
无编辑摘要
imported>=海豚=
无编辑摘要
(未显示同一用户的1个中间版本)
第2行: 第2行:
window.RLQ = window.RLQ || [];
window.RLQ = window.RLQ || [];
window.RLQ.push(function() {
window.RLQ.push(function() {
    mw.hook('wikipage.content').add(function() {
   if (location.hostname.includes("m.hmoegirl.com")) return;
      if (!mw.config.get('talkTocLoaded')) {
    mw.loader.using(["oojs-ui"]).then(function() {
        mw.config.set('talkTocLoaded', window.setInterval(function() {
      if (!mw.config.get('talkTocLoaded', false)) {
         if (mw.config.get('talkTocStop')) return;
        mw.config.set('talkTocLoaded', true);
         if (!$('#talkTocBox')[0]) {
       if (!$('#talkTocBox')[0]) {
           console.debug('widgetTalkToc', 'initing');
         if (localStorage.getItem('widgetTalkToc') === 'disable') {
            var $toc = $('#toc'),
            $('body').addClass('widgetTalkTocDisable');
             $tocBox, $level2, $li, $svdDcs, $title, $toggle, $tocText,
           $('.toctitle').after('<' + 'div style="text-align: center;">[<' + 'a class="enableWidgetTalkToc">启用讨论页面整理工具<' + '/a>]<' + '/div>');
             appendToggleButton;
            $('.enableWidgetTalkToc').on('click', function() {
               $('#talkTocBox').fadeIn();
              localStorage.setItem('widgetTalkToc', 'enable');
               $('#tocBox').fadeOut();
              $(this).text(' 启用成功!刷新页面中……');
               localStorage.setItem('wgTocStyle', 'table');
             setTimeout(location.reload.bind(location), 150);
           /* 预处理 */
           //备份目录
           $toc.after($toc.clone().hide().attr('id', 'tocClone'));
           //标记存档讨论串
            $('.saveNotice').each(function() {
              var prevHeadline = $(this).prev('h2');
              if (prevHeadline[0]) $toc.find('a[href="#' + prevHeadline.find('.mw-headline')[0].id + '"]').parent().addClass("savedDiscussion hiddenDiscussion");
            });
            });
            //整理标题列表
            return;
           $toc.append("<ol style='margin-left: 1.7em;'></ol>").after('<div id="tocBox"></div>');
         }
            $toc.children('ul').children().appendTo($toc.find('ol'));
 
            $toc.find(".toclevel-1 > a > .tocnumber").remove();
         $('body').addClass('widgetTalkTocEnable');
            $toc.appendTo("#tocBox");
         var toclist = ['tocBox', 'talkTocBox', 'toc'],
            bgcolor = $('body').css('background-color'),
           $toc = $('#toc'),
            titlereg = {},
            $tocBox, $level2, $li, $svdDcs, $title, $toggle, $tocText,
           appendToggleButton;


            /* 定义变量 */
         /* 预处理 */
           $tocBox = $('#tocBox');
         //备份目录
           $level2 = $toc.find('.toclevel-2').hide();
         $toc.after($toc.clone().hide().attr('id', 'tocClone'));
           $li = $toc.find('ol > li');
         //整理讨论串
           $svdDcs = $toc.find('.savedDiscussion');
         $('#mw-content-text > .mw-parser-output > h2').each(function() {
           $title = $toc.find('#toctitle').css("margin-right", "1em").append('<span id="toctoggle"></span>');
           var head = $(this);
           $toggle = $title.append('<div id="toggle"></div>').find('#toggle');
           var container = $('<' + 'div/>');
           $tocText = $title.after('<div id="tocText"></div>').parents('#toc').find('#tocText');
           container.addClass('discussionContainer');
           appendToggleButton = function($Obj, $set, shTx, hiTx, fun) {
           head.addClass('discussionHead');
             if (!$Obj[0]) return false;
           head.before(container);
             $set.append($('<a/>', {
           head.nextUntil('h2').not('h2').appendTo(container);
               text: function() {
           head.prependTo(container);
                 if ($Obj.is(':visible')) return hiTx;
            if (container.find('.saveNotice')[0] && head.nextUntil(".saveNotice").length === 0) {
                 else return shTx;
             $toc.find('a[href="#' + head.find('.mw-headline')[0].id.replace(/"/g, '\\\"') + '"]').parent().addClass("savedDiscussion hiddenDiscussion");
               },
             container.addClass('savedDiscussion');
               'class': 'toggleButton',
           } else if (window.CSS && CSS.supports && CSS.supports('position', 'sticky')) {
               href: 'javascript:void(0);',
             head.css({
               bind: {
               position: 'sticky',
                 click: function() {
               top: 0,
                   if ($Obj.is(':visible')) {
               'background-color': bgcolor,
                     $Obj.fadeOut();
               'z-index': 2
                     $(this).text(shTx);
             });
                   } else {
             container.css('position', 'relative');
                     $Obj.fadeIn();
           }
                     $(this).text(hiTx);
         });
                   }
 
         // Temporary padding fix for Microsoft Edge
         // TODO: Report this issue to Edge team
         if (/Edge/.test(navigator.userAgent)) {
           $('.discussionContainer').css('padding-top', '10px');
         }
 
         //整理标题列表
         $toc.append("<" + "ol style='margin-left: 1.7em;'><" + "/ol>").after('<' + 'div id="tocBox"><' + '/div>');
         $toc.children('ul').children().appendTo($toc.find('ol'));
         $toc.find(".toclevel-1 > a > .tocnumber").remove();
         $toc.appendTo("#tocBox");
 
         /* 定义变量 */
         $tocBox = $('#tocBox');
         $level2 = $toc.find('.toclevel-2').hide();
         $li = $toc.find('ol > li');
         $svdDcs = $toc.find('.savedDiscussion');
         $title = $toc.find('.toctitle').css("margin-right", "1em").append('<' + 'span id="toctoggle"><' + '/span>');
         $toggle = $title.append('<' + 'div id="toggle"><' + '/div>').find('#toggle');
         $tocText = $title.after('<' + 'div id="tocText"><' + '/div>').parents('#toc').find('#tocText');
         appendToggleButton = function($Obj, $set, shTx, hiTx, fun) {
           if (!$Obj[0]) return false;
           $set.append($('<' + 'a/>', {
             text: function() {
               if ($Obj.is(':visible')) return hiTx;
               else return shTx;
             },
             'class': 'toggleButton',
             href: 'javascript:void(0);',
             bind: {
               click: function() {
                 if ($Obj.is(':visible')) {
                   $Obj.hide();
                   $(this).text(shTx);
                 } else {
                   $Obj.show();
                   $(this).text(hiTx);
                  }
                  }
                }
                }
              }));
              }
             if (typeof fun == 'function') fun();
           }));
           };
           if (typeof fun == 'function') fun();
         };


           /* 业务处理*/
         /* 业务处理*/
           //添加存档讨论串标题toggle按钮
         //添加存档讨论串标题toggle按钮
           if ($svdDcs[0]) {
         if ($svdDcs[0]) {
             $toggle.append($('<a/>', {
           $toggle.append($('<' + 'a/>', {
               text: '显示已被存档标题',
             text: '显示已被存档标题',
               'class': 'toggleButton',
             'class': 'toggleButton',
               href: 'javascript:void(0);',
             href: 'javascript:void(0);',
               bind: {
             on: {
                 click: function() {
               click: function() {
                   if ($svdDcs.hasClass('hiddenDiscussion')) {
                 if ($svdDcs.hasClass('hiddenDiscussion')) {
                     $svdDcs.removeClass('hiddenDiscussion');
                   $svdDcs.removeClass('hiddenDiscussion');
                     $(this).text('隐藏已被存档标题');
                   $(this).text('隐藏已被存档标题');
                   } else {
                 } else {
                     $svdDcs.addClass('hiddenDiscussion');
                   $svdDcs.addClass('hiddenDiscussion');
                     $(this).text('显示已被存档标题');
                   $(this).text('显示已被存档标题');
                   }
                  }
                  }
                }
                }
              }));
              }
             $tocText.append("<div class='tocText'>(有下划线标题是已被存档标题)</div>");
           }));
           }
           $tocText.append("<" + "div class='tocText'>(有下划线标题是已被存档标题)<" + "/div>");
           //添加二三四五级标题toggle按钮和标题数量
         }
           appendToggleButton($level2, $toggle, '显示段落', '隐藏段落', function() {
         //添加二三四五级标题toggle按钮和标题数量
             $tocText.append("<div class='tocText'>(中括号内数字是该大段下小段数量)</div>");
         appendToggleButton($level2, $toggle, '显示段落', '隐藏段落', function() {
             $toc.find('.toclevel-1').each(function() {
           $tocText.append("<" + "div class='tocText'>(中括号内数字是该大段下小段数量)<" + "/div>");
               var subtitleLength = $(this).find('.toctext').length - 1;
           $toc.find('.toclevel-1').each(function() {
               if (subtitleLength) $(this).children('a').after('[' + subtitleLength + ']');
             var subtitleLength = $(this).find('.toctext').length - 1;
             });
             if (subtitleLength) $(this).children('a').after('[' + subtitleLength + ']');
            });
            });
           //添加整体toggle按钮
         });
           appendToggleButton($toc.find('ol'), $title.find('#toctoggle'), '显示', '隐藏');
         //添加整体toggle按钮
           $('#toc').addClass('noOrigin');
         appendToggleButton($toc.find('ol'), $title.find('#toctoggle'), '显示', '隐藏');
           $('.saveNotice').each(function() {
         $('#toc').addClass('noOrigin');
             $(this).prev('h2').addClass('savedNotice');
         /*
           });
         $('.saveNotice').each(function() {
           $('#mw-content-text > h2:first').before('<div id="talkTocBox"><table></table></div>');
           $(this).prev('h2').addClass('savedNotice');
           var self = $('#talkTocBox table'),
         });*/
             heads = $('#mw-content-text > h2'),
         var containers = $('.discussionContainer');
             a = $('<a/>').text('显示已存档讨论串标题');
         containers.first().before('<' + 'div id="talkTocBox"><' + 'table><' + '/table><' + '/div>');
           self.append('<caption/>').find('caption').append(mw.config.get('wgTitle') + '现有讨论串').append(' [').append(a).append(']<br>').append('(有下划线标题是已被存档讨论串标题)')
         var self = $('#talkTocBox table'),
             .end().append('<tbody/>');
           a = $('<' + 'a/>').text('显示已存档讨论串标题');
           heads.not('.savedNotice').each(function(i) {
         self.append('<' + 'caption/>').find('caption').append(mw.config.get('wgTitle') + '现有讨论串').append(' [').append(a).append(']<' + 'br>').append('(有下划线标题是已被存档讨论串标题)')
             if (i % 4 === 0) self.find('tbody:last').append('<tr/>');
           .end().append('<' + 'tbody/>');
             var content = $(this).nextUntil('h2');
         containers.not('.savedDiscussion').each(function(i) {
             content.find('a').each(function() {
           if (i % 4 === 0) self.find('tbody:last').append('<' + 'tr/>');
               try {
           var that = $(this);
                 var href = $(this)[0].href;
           /* var content = that.children().not('h2');
                 if (!href) return;
           content.find('a').each(function() {
                 var link = new mw.Uri(href);
             try {
                 if (link.host !== 'zh.moegirl.org') this.userNameErrorReason = "link.host !== 'zh.moegirl.org'";
               var href = $(this)[0].href;
                 else if (/^\/api\.php/i.test(link.path)) this.userNameErrorReason = "!!/^\\/api\\.php/i.test(link.path)";
               if (!href) return;
                 else if (!link.query.title && /\.php$/i.test(link.path)) this.userNameErrorReason = "!!(!link.query.title && /\\.php$/i.test(link.path))";
               var link = new mw.Uri(href);
                 else {
               if (link.host !== 'www.moegirl.com') this.userNameErrorReason = "link.host !== 'www.moegirl.com'";
                   var t = link.query.title || decodeURIComponent(link.path.substring(1));
               else if (/^\/api\.php/i.test(link.path)) this.userNameErrorReason = "!!/^\\/api\\.php/i.test(link.path)";
                   if (/^user([ _]talk)?:[^\/]+$/i.test(t)) $(this).data('userName', t.replace(/^user([ _]talk)?:/i, '')).addClass('userTalkPage');
               else if (!link.query.title && /\.php$/i.test(link.path)) this.userNameErrorReason = "!!(!link.query.title && /\\.php$/i.test(link.path))";
                   else this.userNameErrorReason = "!!/^user([ _]talk)?:[^\\/]+$/i.test(t)";
               else {
                 }
                 var t = link.query.title || decodeURIComponent(link.path.substring(1));
               } catch (e) {
                 if (/^user([ _]talk)?:[^\/]+$/i.test(t)) $(this).data('userName', t.replace(/^user([ _]talk)?:/i, '')).addClass('userTalkPage');
                 return;
                 else this.userNameErrorReason = "!!/^user([ _]talk)?:[^\\/]+$/i.test(t)";
                }
                }
              });
              } catch (e) {
             content.find('.userTalkPage').each(function() {
                return;
               var parent = $(this).closest('dd, p').clone();
              }
               var now = Date.now() + (Math.random() + '').substring(2);
               parent.find('.userTalkPage').text(now);
               var regExec = RegExp(now + '.{0,20}(\\d{4}年([1-9]|1[0-2])月([1-9]|[12]\\d|3[01])日\\s{0,10}\\([一二三四五六日]\\)\\s{0,10}([01]\\d|2[0-3]):[0-5]\\d\\s{0,10}(\\([A-Z]{3}\\))?)').exec(parent.text());
               if (!regExec) {
                 this.userNameErrorReason = 'Too far away from timestamp';
                 $(this).removeClass('userTalkPage');
               } else $(this).data('userTalkTime', regExec[1]);
             });
             var userTalkPage = [];
             content.find('.userTalkPage').each(function() {
                var timestamp = $(this).data('userTalkTime').replace(/ \([A-Z]{3,4}\)$/, ''),
                 date = new Date(),
                 time = timestamp.replace(/\([日一二三四五六]\)/g, '').split(/[年月日\s\(\)\:]+/).map(function(n) {
                   return +n;
                 });
               if (!time || !time[4]) return $(this).removeClass('.userTalkPage');
               date.setFullYear(time[0]);
               date.setMonth(time[1] - 1);
               date.setDate(time[2]);
               date.setHours(time[3]);
               date.setMinutes(time[4]);
               userTalkPage.push([$(this).data('userName'), timestamp, date.getTime()]);
             });
             if (!userTalkPage[0]) userTalkPage.push(['Unsigned user/Nonstandard sign', 'Unknown Time']);
             else userTalkPage.sort(function(a, b) {
               return a[2] - b[2]
              });
             var firstName = userTalkPage[0],
               lastName = userTalkPage[userTalkPage.length - 1];
             self.find('tr:last').append('<td></td>')
               .find('td:last').append($('<a/>').attr('href', '#' + $(this).children('.mw-headline').attr('id')).append($(this).children('.mw-headline').clone().find('a').replaceWith(function() {
                 return $(this).text();
               }).end().html()))
               .append(
                 $('<div/>').addClass('signInfo').append('话题发起:' + (firstName[0] === 'Unsigned user/Nonstandard sign' ? 'Unsigned user/Nonstandard sign' : '<a href="/User_talk:' + firstName[0] + '" title="' + firstName[0] + '的讨论页" target="_blank">' + firstName[0].replace(/_/g, ' ') + '</a>'))
                 .append('<br>最后回复:' + (lastName[0] === 'Unsigned user/Nonstandard sign' ? 'Unsigned user/Nonstandard sign' : '<a href="/User_talk:' + lastName[0] + '" title="' + lastName[0] + '的讨论页" target="_blank">' + lastName[0].replace(/_/g, ' ') + '</a>') + '(' + lastName[1] + ')')
               );
            });
            });
            if ($('.signInfo').filter(function() {
            content.find('.userTalkPage').each(function() {
               return $(this).text().indexOf('Unsigned user/Nonstandard sign') !== -1;
             var parent = $(this).closest(containers).clone();
              }).length * 2 > $('.signInfo').length) $('.signInfo').hide().attr('data-hidden', 'true');
              var now = Date.now() + (Math.random() + '').substring(2);
           self.append('<tbody class="hr"><tr><td colspan="4"> </td></tr></tbody>').append('<tbody/>').find('tbody').not(':first').hide();
             parent.find('.userTalkPage').text(now);
           heads.filter('.savedNotice').each(function(i) {
             var regExec = RegExp(now + '(.*)(\\d{4}年([1-9]|1[0-2]) ([1-9]|[12]\\d|3[01])日\\s{0,10}\\([一二三四五六日]\\)\\s{0,10}([01]\\d|2[0-3]):[0-5]\\d\\s{0,10}(\\([A-Z]{3}\\))?)').exec(parent.text());
             if (i % 4 === 0) self.find('tbody:last').append('<tr/>');
              if (!regExec || regExec[1].length > 20) {
              self.find('tr:last').append('<td><a class="savedTitle" href="#' + $(this).children('.mw-headline').attr('id') + '">' + $(this).clone().children('.mw-headline').children('.mw-headline-number').remove().end().prepend(heads.index(this) + 1 + ' ').text() + '</a></td>');
               this.userNameErrorReason = 'Too far away from timestamp (' + (regExec ? regExec[1].length : 'null') + ')';
               this.userNameErrorRegExec = regExec;
               $(this).removeClass('userTalkPage');
             } else $(this).data('userTalkTime', regExec[2]);
            });
            });
            a.on('click', function() {
            var userTalkPage = [];
              self.find('tbody').not(':first').fadeToggle();
           content.find('.userTalkPage').each(function() {
              $(this).text($(this).text() === ' 显示已存档讨论串标题' ? ' 隐藏已存档讨论串标题' : ' 显示已存档讨论串标题');
              var timestamp = $(this).data('userTalkTime').replace(/ \([A-Z]{3,4}\)$|\([日一二三四五六]\)/g, ''),
               date = new Date(),
               time = timestamp.split(/[年月日\s\(\)\:]+/).map(function(n) {
                 return +n;
               });
              if (!time || !time[4]) return $(this).removeClass('.userTalkPage')[0].userNameErrorReason = 'Error Timestamp(' + timestamp + ')';
             date.setFullYear(time[0]);
             date.setMonth(time[1] - 1);
             date.setDate(time[2]);
             date.setHours(time[3]);
             date.setMinutes(time[4]);
             userTalkPage.push([$(this).data('userName'), timestamp, date.getTime()]);
            });
            });
            self.find('tbody').not('.hr').each(function() {
            if (!userTalkPage[0]) userTalkPage.push(['Unsigned user/Nonstandard sign', 'Unknown Time']);
             var that = $(this).find('tr:last');
           else userTalkPage.sort(function(a, b) {
             switch (that.find("td").length) {
             return a[2] - b[2]
               case 3:
                 that.append("<td>&#32;</td>");
                 break;
               case 2:
                 that.append("<td>&#32;</td><td>&#32;</td>");
                 break;
               case 1:
                 that.append("<td>&#32;</td><td>&#32;</td><td>&#32;</td>");
             }
            });
            });
            $('#talkTocBox caption').append('<br>[').append($('<a/>').addClass('cbutton')).append(']');
            var firstName = userTalkPage[0],
            $('#tocText').append('<br>[').append($('<a/>').addClass('cbutton')).append(']');
             lastName = userTalkPage[userTalkPage.length - 1];
           $('.cbutton').on('click', function() {
           titlereg[that.find('.mw-headline:first').attr('id')] = that;*/
              if (!localStorage.wgTocStyle || localStorage.wgTocStyle !== 'list') {
           self.find('tr:last').append('<' + 'td><' + '/td>')
               $('#talkTocBox').fadeOut();
             .find('td:last').append(
               $('#tocBox').fadeIn();
               $('<' + 'a/>').attr('href', '#' + that.find('.mw-headline:first').attr('id').replace(/"/g, "&quot;")).append(that.find('.mw-headline:first').clone().find('a').replaceWith(function() {
               localStorage.setItem('wgTocStyle', 'list');
                 return $(this).text();
               $('.cbutton').text('点击切换至表格格式');
               }).end().html())
             } else {
             );
               $('#talkTocBox').fadeIn();
            /* .append(
               $('#tocBox').fadeOut();
             $('<' + 'div/>').addClass('signInfo').append('话题发起:' + (firstName[0] === 'Unsigned user/Nonstandard sign' ? 'Unsigned user/Nonstandard sign' : '<' + 'a href="/User_talk:' + firstName[0] + '" title="' + firstName[0] + '的讨论页" target="_blank">' + firstName[0].replace(/_/g, ' ') + '<' + '/a>'))
               localStorage.setItem('wgTocStyle', 'table');
             .append('<' + 'br>最后回复:' + (lastName[0] === 'Unsigned user/Nonstandard sign' ? 'Unsigned user/Nonstandard sign' : '<' + 'a href="/User_talk:' + lastName[0] + '" title="' + lastName[0] + '的讨论页" target="_blank">' + lastName[0].replace(/_/g, ' ') + '<' + '/a>') + '(' + lastName[1] + ')')
               $('.cbutton').text(' 点击切换至列表格式');
           ); */
             }
         });
           });
         /* if ($('.signInfo').filter(function() {
          } else if ($('.signInfo').attr('data-hidden') === 'true') {
              return $(this).text().indexOf('Unsigned user/Nonstandard sign') !== -1;
           console.debug('widgetTalkToc', 'sign exec error');
           }).length * 2 > $('.signInfo').length) $('.signInfo').hide(); */
            $('.savedDiscussion, .hiddenDiscussion, .savedNotice, .userTalkPage').removeClass('savedDiscussion hiddenDiscussion savedNotice userTalkPage');
         self.append('<' + 'tbody class="hr"><' + 'tr><' + 'td colspan="4"> <' + '/td><' + '/tr><' + '/tbody>').append('<' + 'tbody/>').find('tbody').not(':first').hide();
            $('#tocBox, #talkTocBox').remove();
         containers.filter('.savedDiscussion').each(function(i) {
           $('#tocClone').attr('id', 'toc').removeAttr('style');
           if (i % 4 === 0) self.find('tbody:last').append('<' + 'tr/>');
          } else {
           self.find('tr:last').append('<' + 'td><' + 'a class="savedTitle" href="#' + $(this).find('.mw-headline:first').attr('id').replace(/"/g, "&quot;") + '">' + $(this).clone().find('.mw-headline:first').children('.mw-headline-number').remove().end().prepend(containers.index(this) + 1 + ' ').text() + '<' + '/a><' + '/td>');
           var boxs = $('#tocBox, #talkTocBox');
         });
           if (boxs.is(':hidden') && boxs.is(':visible')) return;
          a.on('click', function() {
           self.find('tbody').not(':first').fadeToggle();
           $(this).text($(this).text() === ' 显示已存档讨论串标题' ? '隐藏已存档讨论串标题' : '显示已存档讨论串标题');
         });
         self.find('tbody').not('.hr').each(function() {
            var that = $(this).find('tr:last');
            that.append(("<" + "td>&#32;<" + "/td>").repeat(4 - that.find("td").length));
         });
         $('#talkTocBox caption').append('<' + 'br>[').append($('<' + 'a/>').addClass('cbutton')).append(']');
          $('#tocText').append('<' + 'br>[').append($('<' + 'a/>').addClass('cbutton')).append(']');
         $('.cbutton').on('click', function() {
            if (!localStorage.wgTocStyle || localStorage.wgTocStyle !== 'list') {
            if (!localStorage.wgTocStyle || localStorage.wgTocStyle !== 'list') {
              $('#talkTocBox').fadeIn();
              $('#talkTocBox').hide();
             $('#tocBox').show();
             localStorage.setItem('wgTocStyle', 'list');
             $('.cbutton').text('点击切换至表格格式');
             $(toclist.filter(function(l) {
               return l !== "tocBox";
             }).map(function(l) {
               return 'a[href="#' + l + '"]';
             }).join(', ')).attr("href", "#tocBox");
           } else {
             $('#talkTocBox').show();
             $('#tocBox').hide();
             localStorage.setItem('wgTocStyle', 'table');
              $('.cbutton').text('点击切换至列表格式');
              $('.cbutton').text('点击切换至列表格式');
            } else {
             $(toclist.filter(function(l) {
             $('#tocBox').fadeIn();
               return l !== "talkTocBox";
             $('.cbutton').text('点击切换至表格格式');
             }).map(function(l) {
               return 'a[href="#' + l + '"]';
             }).join(', ')).attr("href", "#talkTocBox");
           }
         });
         if (!localStorage.wgTocStyle || localStorage.wgTocStyle !== 'list') {
           $('#talkTocBox').show();
           $('.cbutton').text('点击切换至列表格式');
           $(toclist.filter(function(l) {
             return l !== "talkTocBox";
           }).map(function(l) {
             return 'a[href="#' + l + '"]';
            }).join(', ')).attr("href", "#talkTocBox");
         } else {
           $('#tocBox').show();
           $('.cbutton').text('点击切换至表格格式');
           $(toclist.filter(function(l) {
             return l !== "tocBox";
           }).map(function(l) {
             return 'a[href="#' + l + '"]';
           }).join(', ')).attr("href", "#tocBox");
         }
         $('.cbutton').parent().append(' [<' + 'a class="disableWidgetTalkToc">禁用讨论页面整理工具<' + '/a>]');
         $('.disableWidgetTalkToc').on('click', function() {
           localStorage.setItem('widgetTalkToc', 'disable');
           $(this).text('禁用成功!刷新页面中……');
           setTimeout(location.reload.bind(location), 150);
         });
         $tocBox.css({
           position: 'relative',
           'z-index': 10
         });
         $(window).on('hashchange', function(e) {
           try {
             var hash = location.hash.substring(1);
             var target = $('[id="' + decodeURIComponent(hash).replace(/"/g, '\\\"') + '"]');
             if (target[0]) {
               var scrollTop = target.offset().top;
               if (target.closest('.discussionHead').length === 0) {
                 var parent = target.closest('h1, h2, h3, h4, h5, h6');
                 if (parent.length > 0) {
                   scrollTop -= parent.outerHeight(true) - parent.height();
                   var h = parent.prevAll('h1, h2, h3, h4, h5, h6').filter(function() {
                     return $(this).css('position') === 'sticky';
                   });
                   if (h.length > 0) scrollTop -= h.outerHeight();
                 }
               } else scrollTop = target.closest('.discussionContainer').offset().top;
               setTimeout(function() {
                 $('html,body').animate({
                   scrollTop: scrollTop
                 }, 0);
               }, 1);
               return false;
             }
           } catch (e) {
             return;
           }
         }).trigger('hashchange');
         const g = ["sysop", "patroller"];
         if (mw.config.get("wgUserGroups").filter(n => g.includes(n)).length === 0) {
           switch (mw.config.get("wgArticleId")) {
             case 256948:
             case 17801:
               $("#right-navigation").addClass("no-need-to-edit-whole-page").find("#p-views > ul").append('<li id="ca-no-need-to-edit-whole-page-notice" class="collapsible"><span><a href="javascript:void(0);">请勿编辑全文</a></span></li>').find("#ca-no-need-to-edit-whole-page-notice a").on("click", function() {
                 var messageDialog = new OO.ui.MessageDialog();
                 var windowManager = new OO.ui.WindowManager();
                 $("body").append(windowManager.$element);
                 windowManager.addWindows([messageDialog]);
                 messageDialog.title.$label.html("萌娘百科提醒您<br>公共讨论页无需编辑全文");
                 messageDialog.message.$label.html("<br>提问求助区、讨论版属于公共讨论页,一般来说无须编辑全文,故我们隐藏了入口。<hr>您可以点击下方标题旁的<b>【编辑】链接</b>来编辑对应段落,也可以点击右上方<b>【添加话题】链接</b>来新增话题。");
                 windowManager.openWindow(messageDialog, {
                   actions: [{
                     action: 'accept',
                     label: '我知道了',
                     flags: 'primary'
                   }]
                 });
               });
               break;
            }
            }
          }
          }
        }, 730));
        }
      }
      }
    });
    });
});
});
</script><style>
</script><style>
#tocBox {
/* <pre> */
.widgetTalkTocEnable #tocBox {
    max-width: 37%;
    max-width: 37%;
    min-width: 300px;
    min-width: 300px;
    float: left;
    float: left;
}
}
#toc.noOrigin {
.widgetTalkTocEnable #toc.noOrigin {
    display: table;
    display: table;
}
}
div.toc#toc {
.widgetTalkTocEnable div.toc#toc {
    min-width: 300px;
    min-width: 300px;
    box-sizing: border-box;
    box-sizing: border-box;
第237行: 第342行:
    padding-left: 1em;
    padding-left: 1em;
}
}
div.toc#toc div#toctitle h2 {
.widgetTalkTocEnable div.toc#toc div.toctitle h2 {
    margin-right: 1em;
    margin-right: 1em;
}
}
div.toc.noOrigin#toc .toctoggle {
.widgetTalkTocEnable div.toc.noOrigin#toc .toctoggle {
    display: none;
    display: none;
}
}
div#toc.toc #toctoggle,
.widgetTalkTocEnable div#toc.toc #toctoggle,
div#toc.toc #toggle {
.widgetTalkTocEnable div#toc.toc #toggle {
    font-size: 94%;
    font-size: 94%;
    -webkit-user-select: none;
    -webkit-user-select: none;
第252行: 第357行:
    user-select: none;
    user-select: none;
}
}
div#toc.toc .toggleButton:before {
.widgetTalkTocEnable div#toc.toc .toggleButton:before {
    content: "[";
    content: "[";
    color: black;
    color: black;
}
}
div#toc.toc .toggleButton:after {
.widgetTalkTocEnable div#toc.toc .toggleButton:after {
    content: "]";
    content: "]";
    color: black;
    color: black;
}
}
#toc .toggleButton:first-child {
.widgetTalkTocEnable #toc .toggleButton:first-child {
    margin-right: 0.5em;
    margin-right: 0.5em;
}
}
div#toc.toc .toggleButton:last-child {
.widgetTalkTocEnable div#toc.toc .toggleButton:last-child {
    margin-right: 0;
    margin-right: 0;
}
}
div#toc.toc .hiddenDiscussion {
.widgetTalkTocEnable div#toc.toc .hiddenDiscussion {
    visibility: hidden;
    visibility: hidden;
    height: 0;
    height: 0;
    margin: 0;
    margin: 0;
}
}
div.toc#toc li.savedDiscussion a {
.widgetTalkTocEnable div.toc#toc li.savedDiscussion a {
    text-decoration: underline;
    text-decoration: underline;
}
}
#toc div#tocText {
.widgetTalkTocEnable #toc div#tocText {
    text-align:center;
    text-align: center;
}
}
#toc div.tocText {
.widgetTalkTocEnable #toc div.tocText {
    display:inline-block;
    display: inline-block;
}
}
.widgetTalkTocEnable
/* 节操酱的beg */
/* 节操酱的beg */
#content ol,
.widgetTalkTocEnable #content ol,
#content ul {
.widgetTalkTocEnable #content ul {
    margin: 0 !important;
    margin: 0 !important;
    padding: 0.3em 0 0 1.6em !important;
    padding: 0.3em 0 0 1.6em !important;
}
}
#toc .toclevel-1 > ul {
.widgetTalkTocEnable #toc .toclevel-1>ul {
    padding-left: 0!important;
    padding-left: 0 !important;
}
}
.widgetTalkTocEnable
/* 由于节操酱的beg导致分类那边有秘制空白 */
/* 由于节操酱的beg导致分类那边有秘制空白 */
#content #catlinks ol,
.widgetTalkTocEnable #content #catlinks ol,
#content #catlinks ul {
.widgetTalkTocEnable #content #catlinks ul {
    padding: 0 !important;
    padding: 0 !important;
}
}
第299行: 第406行:
    display: none;
    display: none;
}
}
#talkTocBox td {
.widgetTalkTocDisable #toc {
   display: table;
}
.widgetTalkTocEnable #talkTocBox td {
    text-align: center;
    text-align: center;
    border: 1px solid #a7d7f9;
    border: 1px solid #a7d7f9;
第305行: 第415行:
    padding: 0 1em;
    padding: 0 1em;
}
}
#talkTocBox .hr td {
.widgetTalkTocEnable #talkTocBox .hr td {
    width: 100%;
    width: 100%;
}
}
#talkTocBox table {
.widgetTalkTocEnable #talkTocBox table {
    border-collapse: collapse;
    border-collapse: collapse;
    margin-bottom: 1em;
    margin-bottom: 1em;
    width: 100%;
    width: 100%;
}
}
#talkTocBox a {
.widgetTalkTocEnable #talkTocBox a {
    cursor: pointer;
    cursor: pointer;
}
}
#talkTocBox .savedTitle {
.widgetTalkTocEnable #talkTocBox .savedTitle {
    text-decoration: underline;
    text-decoration: underline;
}
}
.cbutton {
.widgetTalkTocEnable .cbutton {
    cursor: pointer;
    cursor: pointer;
}
}
.signInfo {
   display: none !important;
}
#right-navigation.no-need-to-edit-whole-page ul {
   display: flex;
}
#right-navigation.no-need-to-edit-whole-page ul>li {
   order: 999;
}
#right-navigation.no-need-to-edit-whole-page ul>li#ca-view {
   order: 1;
}
#right-navigation.no-need-to-edit-whole-page ul>li#ca-no-need-to-edit-whole-page-notice {
   order: 2;
   font-style: italic;
}
#right-navigation.no-need-to-edit-whole-page ul>li#ca-no-need-to-edit-whole-page-notice a,
#right-navigation.no-need-to-edit-whole-page ul>li#ca-no-need-to-edit-whole-page-notice a:visited {
   color: #222;
   text-decoration: none;
}
#right-navigation.no-need-to-edit-whole-page ul>li#Wikiplus-Edit-TopBtn,
#right-navigation.no-need-to-edit-whole-page ul>li#ca-edit,
#right-navigation.no-need-to-edit-whole-page ul>li#ca-editTopSection {
   display: none;
}
.cloaked-element.transparent-shield {
   z-index: 9999999;
}
/* </pre> */
</style><!--{/if}--></includeonly>
</style><!--{/if}--></includeonly>

2020年3月27日 (五) 10:21的版本