User:魔琴/gadgets/listredlinks/index.js
外观
注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google Chrome、Firefox、Microsoft Edge及Safari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。
$(document).ready(function () {
let a = new Set();
$("#mw-content-text a.new").each(function () {
a.add($(this).attr('href'));
});
$("#mw-content-text .ilh-page a.extiw").each(function () {
a.add($(this).attr('data-old-href'));
});
var div = $('<div>').css('padding', '0 0.5em 0.5em 0.5em').css('border', 'solid 1px #000').css('margin', '0.5em');
var p = $('<p>').text('Red links on this page:');
var ul = $('<ul>');
a.forEach(function (item) {
ul.append($('<li>').append($('<a>').addClass('new').attr('href', item).text(decodeURI(item).replace(/^.*title=(.*?)&.*$/, '$1').replace(/_/g, ' '))));
});
$('#bodyContent').append(div.append(p).append(ul));
});