User:Username/BlockAbuser.js

From Test Wiki
Revision as of 02:11, 21 January 2026 by Username (talk | contribs)
Jump to navigation Jump to search

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.
mw.loader.using( [ 'mediawiki.util' ] ).then( function () {

    // Only run on Special:AbuseFilter
    if ( mw.config.get( 'wgCanonicalSpecialPageName' ) !== 'AbuseFilter' ) {
        return;
    }

    const seenUsers = new Set();

    // Very strict IPv4 / IPv6 detection
    const ipRegex = /^(?:\d{1,3}\.){3}\d{1,3}$|:/;

    // Find all links inside the abuse log table/content
    $( '#mw-content-text a' ).each( function () {
        const $link = $( this );
        const href = $link.attr( 'href' );
        const text = $link.text();

        if ( !href || !text ) {
            return;
        }

        // Only User: links
        if ( !href.includes( '/wiki/User:' ) ) {
            return;
        }