User:Hat600/script/sectionlink.js

维基百科,自由的百科全书

注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google ChromeFirefoxMicrosoft EdgeSafari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。

;(function($){
    $('.mw-headline').each(function(i){
        name1 = $(this).attr('id');
        ht = $(this).text();
        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,'.');
        $(this).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('<', '&lt;').replace('>', '&gt;').replace('"', '&quot;').replace("'", "&apos;") + '" />');
    });
})(jQuery);