注意:在保存之后,您可能需要清除浏览器缓存才能看到所作出的变更的影响。
?_=1
来访问最新页面。https://zh.moegirl.org.cn/User:AnnAngela/js/watchlist-log.js?_=1
// <pre> /* global mediaWiki */ $(() => { if (mw.config.get("wgCanonicalSpecialPageName") !== "Watchlist") { return; } function containAny(...arguments) { for (let index in arguments) { const obj = arguments[index], text = obj.text, matchWholeWordOnly = obj.matchWholeWordOnly || false, list = obj.list, length = list.length; for (let idx = 0; idx < length; idx++) { if (matchWholeWordOnly === true ? text === list[idx] : text.includes(list[idx])) { return true; } } } } var dayFlag = +localStorage.getItem('AnnTools-watch-log-dayFlag') || -1, lengthFlag = +localStorage.getItem('AnnTools-watch-log-lengthFlag') || -1, myUserName = mw.config.get('wgUserName'), nowDay, logLength; $('.mw-special-Watchlist .mw-changeslist li').each(function() { if (// $(this).find('.botedit')[0] || //机器人编辑 containAny({ text: decodeURIComponent($(this).find('.mw-changeslist-line-inner a')[0].href), //日志页面 list: ['/Special:日志'], }, { text: $(this).find('.comment').text(), //编辑摘要内容标明为特殊操作 list: ['文本替换 - '], }, { text: $(this).find('.mw-tag-markers').text(), //有特殊编辑标签 list: [ 'Welcome to MoegirlPedia', '快速存档讨论串' ], }, { text: $(this).find('.mw-title').text(), //页面名称表明为重要页面 list: [ 'Template:人物信息', 'Template:用户信息', 'Template:歌曲信息', 'Template:音游曲信息', 'Template:Navbox', 'Template:用户 萌娘百科的苦力', 'Template:声优信息', ], matchWholeWordOnly: true, //不包含子页面 }, { text: $(this).find('.mw-title').text(), //页面名称表明为重要页面 list: [ '萌娘百科:', 'MediaWiki:', '/存档/' ], }) ) { $(this).addClass('mw-watchlist-log'); if ($(this).find('.mw-userlink').text() === myUserName) { $(this).addClass('mw-watchlist-my-log'); } } }); if ($('.mw-watchlist-log')[0]) { $(document.head).append('<style>.mw-special-Watchlist .mw-watchlist-log{border:1px dashed #aaa;background-color:#f9f9f9}.mw-special-Watchlist .mw-changeslist h3 span,.mw-special-Watchlist .mw-changeslist h4 span{float:right;cursor:pointer;color:#0645ad;font-weight:normal}.mw-special-Watchlist .mw-changeslist h3 span:before,.mw-special-Watchlist .mw-changeslist h4 span:before{content:"[";color:black}.mw-special-Watchlist .mw-changeslist h3 span:after,.mw-special-Watchlist .mw-changeslist h4 span:after{content:"]";color:black}</style>'); $('.mw-special-Watchlist .mw-changeslist li a').removeAttr('tabindex'); $('.mw-special-Watchlist .mw-changeslist .special').each(function() { var self = $(this), time = self.prev().text(); self.attr('data-time', time); if (self.find('.mw-watchlist-log')[0]) { if (!$('.mw-special-Watchlist .mw-changeslist')[1]) { $('.mw-special-Watchlist .mw-changeslist').before('<div class="mw-changeslist"/>'); } if (!$('.mw-special-Watchlist .mw-changeslist:first h4[data-time="' + time + '"]')[0]) { $('.mw-special-Watchlist .mw-changeslist:first').append('<h4 data-time="' + time + '">' + time + '</h4><ul data-time="' + time + '"/>'); } self.find('.mw-watchlist-log').attr('class', 'mw-watchlist-log').appendTo('.mw-special-Watchlist .mw-changeslist:first ul[data-time="' + time + '"]').find('.mw-rollback-link').remove(); } }); $('.mw-special-Watchlist .mw-changeslist').each(function(index) { if (index !== 0) { $(this).prepend('<h3>页面</h3>'); } else { var self = $(this); self.prepend('<h3>日志</h3>'); self.find('h3').append($('<span>', { attr: { 'data-hidden': 'true', }, click: function() { if ($(this).attr('data-hidden') === 'true') { $(this).attr('data-hidden', 'false').text('隐藏'); self.find('ul').each(function() { if ($(this).is(':hidden')) $(this).show().prev().find('span').text('隐藏'); }); } else { $(this).attr('data-hidden', 'true').text('显示'); self.find('ul').each(function() { if (!$(this).is(':hidden')) $(this).hide().prev().find('span').text('显示'); }); } }, text: '显示', })); self.find('h4').each(function(index) { var needHidden = false; if (index === 0) { nowDay = +$(this).attr('data-time').split(/[\D]/g)[2]; logLength = $('.mw-changeslist ul:first li:not(.mw-watchlist-my-log)').length; if (dayFlag && dayFlag === nowDay && lengthFlag >= logLength) needHidden = true; localStorage.setItem('AnnTools-watch-log-dayFlag', nowDay); localStorage.setItem('AnnTools-watch-log-lengthFlag', logLength); } else { needHidden = true; } var next = $(this).next(); $(this).append($('<span>', { click: function() { if (next.is(":hidden")) { next.show(); $(this).text('隐藏'); } else { next.hide(); $(this).text('显示'); } }, text: function() { if (needHidden) { next.hide(); return '显示'; } else { next.show(); return '隐藏'; } }, })); }); } }); var redirectLink = {}; $('.mw-changeslist:first li').each(function() { if ($(this).find('a:first').attr('href') === "/Special:%E6%97%A5%E5%BF%97/move" && $(this).text().includes("不留重定向")) { $(this).children('a.new').not('.mw-userlink').each(function() { var title = mw.util.getParamValue('title', decodeURI(this.href)); if (Object.keys(redirectLink).indexOf(title) === -1) redirectLink[title] = $(this).next('a').attr('href'); }); } }); $('.mw-changeslist:last a.new[href*="title="]').each(function() { var title = new URL(this.href).searchParams.get("title"); if (Object.keys(redirectLink).indexOf(title) !== -1) $(this).attr({ href: redirectLink[title], title: title + '(已被重定向至 ' + decodeURIComponent(redirectLink[title].substring(1)) + ' )', }).removeClass('new').after($('<sup/>', { text: '[重定向]', css: { 'font-size': 'smaller', 'vertical-align': 'super', color: '#0645ad', cursor: 'pointer', }, title: '(已被重定向至 ' + decodeURIComponent(redirectLink[title].substring(1)) + ' )', }).on('click', function() { alert('本页面已从\n ' + title + '\n重定向到\n ' + decodeURIComponent(redirectLink[title].substring(1))); })); }); } var talkpageList = {}; $(".mw-changeslist:last li").each(function() { var self = $(this); var title = self.find(".mw-title").text().trim(); if (title.startsWith("萌娘百科 talk:讨论版/")) { if (!Array.isArray(talkpageList[title])) { talkpageList[title] = []; } var date = Array.from(self.closest("ul").prev("h4").text().match(/\d{4}(?=年)|\d{1,2}(?=月)|\d{1,2}(?=日)/g) || []); if (date.length !== 3) { date = []; } talkpageList[title].push([date, this]); } }); if (Object.keys(talkpageList).length > 0) { var talkpage = $("<div/>"); talkpage.addClass("mw-changeslist"); talkpage.append("<h3>讨论版</h3>"); Object.keys(talkpageList).forEach(function(title) { var head = $("<h4/>"); head.text(title) talkpage.append(head); var ul = $("<ul/>"); talkpage.append(ul); var nowYear = new Date().getFullYear() + ""; var yearFlag = talkpageList[title].filter(function(c) { var date = c[0]; return date.length === 3 && date[0] !== nowYear; }).length > 0; talkpageList[title].forEach(function(c) { var date = c[0], ele = c[1]; if (date.length === 3) { var node = $(ele).find(".mw-changeslist-date"); node.prepend(date[1] + "/" + date[2] + " "); if (yearFlag) { node.prepend(date[0] + "/"); } } ul.append(ele); }); var needHidden = ul.find(".mw-changeslist-line-watched").length === 0; var readLine = ul.find(".mw-changeslist-line-not-watched"); head.append($('<span>', { click: function() { if (ul.is(":hidden")) { ul.show(); $(this).text('隐藏'); } else { ul.hide(); $(this).text('显示'); } }, text: function() { if (needHidden) { ul.hide(); return '显示'; } else { ul.show(); return '隐藏'; } }, })); if (readLine.length > 0) { head.append($('<span>', { click: function() { if (readLine.is(":hidden")) { readLine.show(); $(this).text('隐藏已读'); } else { readLine.hide(); $(this).text('显示已读'); } }, text: function() { readLine.hide(); return '显示已读'; }, })); } }); $(".mw-changeslist:last").before(talkpage); } $(".mw-changeslist").each(function() { var self = $(this); self.css("position", "relative"); var h3 = self.find("h3"); h3.css({ top: 0, left: 0, position: "sticky", "background-color": "white", "z-index": "9999" }); self.find("h4").each(function() { var self = $(this); var next = self.next(); var div = $("<div/>"); div.css("position", "relative"); self.before(div); div.append(self).append(next); self.css({ top: h3.outerHeight(), left: 0, position: "sticky", "background-color": "white", "z-index": "9998" }); }); }); }) // </pre>