_ _    _ _____  ___   __                       
 __      _(_) | _(_)___ / ( _ ) / /_   ___ ___  _ __ ___  
 \ \ /\ / / | |/ / | |_ \ / _ \| '_ \ / __/ _ \| '_ ` _ \ 
  \ V  V /| |   <| |___) | (_) | (_) | (_| (_) | | | | | |
   \_/\_/ |_|_|\_\_|____/ \___/ \___(_)___\___/|_| |_| |_|

User:The Earwig/copy-section-link.js

In today's world, User:The Earwig/copy-section-link.js has become a topic of increasing interest to a wide spectrum of people. Its relevance ranges from the personal to the professional sphere, and impacts various areas of daily life. With the advancement of technology and globalization, User:The Earwig/copy-section-link.js has gained even greater importance, generating debates, research and developments that have transformed the way we perceive and approach this topic. In this article, we will explore different perspectives and approaches related to User:The Earwig/copy-section-link.js, in order to delve into its relevance and implications in today's world.
// Fixed version of ]
// <nowiki>
$.when(
    $.ready,
    mw.loader.using(  )
).then( function () {
    $( ".mw-heading" ).each( function () {
        var popup = null;
        var heading = $(this.children).filter("h1, h2, h3, h4, h5, h6").first(); 
        var target = $(this.children).filter(".mw-editsection").first();
        if (target.length === 0) {
        	target = heading;
        }
        target.after($( "<a>", { "class": "copy-section-link-pilcrow" } )
                .text( "¶" )
                .click( function () {
                    if( popup === null ) {
                        var hash = heading.attr( "id" );
                        var oldid = mw.util.getParamValue( "oldid" );
                        var popupContent;
                        function makeContent( pageName, id ) {
                            var wikitext = (pageName + "#" + hash).replace( /_/g, " " );
                            if( !window.copySectionLinkNoSquareBrackets ) {
                               wikitext = ']';
                            }
                            return $( '<p>', { "class": "copy-section-link-content" } ).append(
                                $( "<code>", { "id": "copy-section-wikilink" + id } ).text( wikitext ),
                                $( "<button>" )
                                    .text( "Copy" )
                                    .css( { "padding": "0.5em", "cursor": "pointer", "margin-left": "0.5em" } )
                                    .click( function () {
                                        var textField = $( this ).prev();
                                        try {
                                            navigator.clipboard.writeText( textField.text() );
                                        } catch( e ) {
                                            textField.select();
                                            document.execCommand( "copy" );
                                        }
                                    } ),
                                $( "<br>" ),
                                $( "<a>" )
                                	.attr( "href", mw.util.getUrl( pageName ) + "#" + encodeURIComponent( hash ) )
                                	.text( "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' ), 'normal' )
                            } );
                            var permalinkPanel = new OO.ui.TabPanelLayout( 'permalink', {
                                label: 'Permalink',
                                $content: makeContent( 'Special:Permalink/' + mw.config.get( 'wgCurRevisionId' ), 'permalink' )
                            } );
                            index = new OO.ui.IndexLayout();
                            index.addTabPanels(  );
                            popupContent = index.$element;
                        }
                        popup = new OO.ui.PopupWidget( {
                            $content: popupContent,
                            $floatableContainer: $( this ),
                            padded: true,
                            width: 400,
                            height: 190,
                            align: 'forwards',
                        } );
                        $( this ).after( 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( ".mw-heading .copy-section-link-pilcrow" +
                        "{ display: none; margin-left: 1em; }" +
                    ".mw-heading:hover .copy-section-link-pilcrow" +
                        "{ display: inline; }" +
                    ".mw-heading .copy-section-link-pilcrow + .oo-ui-widget" +
                        "{ font-weight: normal; }" );
} );
// </nowiki>