User:Hamish/sectionlink.js
外观
注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google Chrome、Firefox、Microsoft Edge及Safari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。
// Adapted from User:Hat600/script/sectionlink.js
(function($) {
$('.mw-heading').each(function(i) {
var $heading = $(this).find('h1, h2, h3, h4, h5, h6').first();
if ($heading.length === 0) {
return;
}
var name1 = $heading.attr('id');
var ht = $heading.text();
var grou = ht.match(/[\.A-F0-9]+/g);
if (grou !== null) {
$.each(grou, function() {
arr = this.replace(/\./g, '>');
name1 = name1.replace(this, arr);
});
}
name1 = name1.replace(/\.([A-F0-9][A-F0-9])/g, '%$1').replace(/>/g, '.');
$heading.before('<input class="sectionlink" type="text" readonly="readonly" style="background-color:transparent; border: 1px solid #808080; float: right; font-size: 70%;" size="5" onfocus="this.select()" value="' + mw.config.get('wgPageName') + '#' + decodeURIComponent(name1).replace('<', '<').replace('>', '>').replace('"', '"').replace("'", ''') + '" />');
$heading.before('<input class="sectionlink" type="text" readonly="readonly" style="background-color:transparent; border: 1px solid #808080; float: right; font-size: 70%;" size="5" onfocus="this.select()" value="' + 'Special:Permalink/' + mw.config.get('wgCurRevisionId') + '#' + decodeURIComponent(name1).replace('<', '<').replace('>', '>').replace('"', '"').replace("'", ''') + '" />');
});
})(jQuery);