MediaWiki:Gadget-irclogin.js
Megjegyzés: közzététel után frissítened kell a böngésződ gyorsítótárát, hogy lásd a változásokat.
- Firefox / Safari: tartsd lenyomva a Shift gombot és kattints a Frissítés gombra a címsorban, vagy használd a Ctrl–F5 vagy Ctrl–R (Macen ⌘–R) billentyűkombinációt
- Google Chrome: használd a Ctrl–Shift–R (Macen ⌘–Shift–R) billentyűkombinációt
- Internet Explorer / Edge: tartsd nyomva a Ctrl-t, és kattints a Frissítés gombra, vagy nyomj Ctrl–F5-öt
- Opera: Nyomj Ctrl–F5-öt
/**
* This script looks for the element with id "irclogin", and replaces its contents
* with a login form that redirects to the Mibbit IRC gateway
*/
( function () {
if ( mw.config.get( 'wgAction' ) in { edit: 1, submit: 1 } ) {
return;
}
function loadLoginForm( $content ) {
$content.find( '#irclogin' ).empty().append(
$( '<form>' ).attr( {
method: 'get',
action: 'https://web.libera.chat/',
target: '_blank',
name: 'loginform'
} ).append(
$( '<input type="text"> ').attr( {
name: 'nick',
size: 25
} ).val( nickify( mw.config.get('wgUserName') ) ).one( 'focus', clear_text ),
' ', // space between the input field and the button
$( '<input type="submit">').val( 'Belépés' ),
$( '<input type="hidden">').attr( 'name', 'channels' ).val( 'wikipedia-hu' )
)
);
}
function nickify( s ) {
if ( s === null ) {
return 'anon' + Math.floor( Math.random() * 100 );
}
s = s.toLowerCase();
s = s.replace(" ", "_");
s = s.replace(/á/g, 'a');
s = s.replace(/é/g, 'e');
s = s.replace(/í/g, 'i');
s = s.replace(/[óő]/g, 'o');
s = s.replace(/[úű]/g, 'u');
s = s.replace(/[^a-z0-9_-]/g, '');
return s || 'badname' + Math.floor( Math.random() * 100 );
}
function clear_text( e ) {
this.value = '';
}
mw.hook( 'wikipage.content' ).add( loadLoginForm );
} ) ();