User:NguoiDungKhongDinhDanh/copy-section-link.js

// Script by Enterprisey. Backlink: User:Enterprisey/copy-section-link.js // $.when(   $.ready,    mw.loader.using( [ "mediawiki.util", "oojs-ui-core", "oojs-ui-widgets" ] ) ).then( function  {    $( "span.mw-headline" ).each( function  { var popup = null; $( this ).append( " ", $( " " ).append( $( "", { "class": "copy-section-link-pilcrow" } ) .text( "¶" ) .click( function {                    if( popup === null ) {                        var hash = "#" + $( this ).parent.parent.attr( "id" ).replace( /external)");                        }

var generalCss = { 'font-size': '0.9rem', 'font-family': 'sans-serif' };

var index; if( oldid ) { popupContent = makeContent( "Special:Permalink/" + oldid ); popupContent.css( generalCss ); popupContent.css( { 'padding-top': '0.5em', 'font-weight': 'normal' } ); } else { var normalPanel = new OO.ui.TabPanelLayout( 'normal', {                               label: 'Link',                                $content: makeContent( mw.config.get( 'wgPageName' ) )                            } ); var permalinkPanel = new OO.ui.TabPanelLayout( 'permalink', {                               label: 'Permalink',                                $content: makeContent( 'Special:Permalink/' + mw.config.get( 'wgCurRevisionId' ) )                            } ); index = new OO.ui.IndexLayout; index.addTabPanels( [ normalPanel, permalinkPanel ] ); popupContent = index.$element; }                       popup = new OO.ui.PopupWidget( {                            $content: popupContent,                            padded: true,                            width: 400,                            height: 185,                            align: 'forwards',                        } ); $( this ).parent.append( popup.$element ); if( index ) { index.$menu.find( 'span.oo-ui-labelElement-label' ).css( generalCss ); index.$content.css( generalCss ); }

popup.toggle( true ); } else { popup.toggle; }               } ) ) );    } );    mw.util.addCSS( "h2 .copy-section-link-pilcrow," +                    "h3 .copy-section-link-pilcrow," +                    "h4 .copy-section-link-pilcrow," +                    "h5 .copy-section-link-pilcrow," +                    "h6 .copy-section-link-pilcrow" +                        "{ display: none }" +                    "h2:hover .copy-section-link-pilcrow," +                    "h3:hover .copy-section-link-pilcrow," +                    "h4:hover .copy-section-link-pilcrow," +                    "h5:hover .copy-section-link-pilcrow," +                    "h6:hover .copy-section-link-pilcrow" +                        "{ display: inline }" ); } ); //