Jump to content

MediaWiki:Common.js

From Systemicwiki contributors
Revision as of 23:54, 26 September 2026 by Dsi.ionescu (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
$( function () {
    if ( mw.config.get( 'wgAction' ) !== 'history' ) {
        return;
    }

    document.querySelectorAll( '#pagehistory li' ).forEach( function ( row ) {
        var links = Array.from( row.querySelectorAll( 'a' ) );

        var approve = links.find( function ( link ) {
            return /^(approve|Approve this version)$/i.test(
                link.textContent.trim()
            );
        } );

        var talk = links.find( function ( link ) {
            return link.textContent.trim().toLowerCase() === 'talk';
        } );

        if ( !approve || !talk ) {
            return;
        }

        var url = new URL( talk.href, window.location.href );
        url.searchParams.set( 'action', 'edit' );
        url.searchParams.set( 'section', 'new' );
        url.searchParams.set(
            'preloadtitle',
            'Review of ' + mw.config.get( 'wgPageName' ).replaceAll( '_', ' ' )
        );

        var request = document.createElement( 'a' );
        request.href = url.toString();
        request.textContent = 'Request changes or suggest wording';

        row.append( ' · ', request );
    } );
} );