ميدياويكى:Gadget-Direct-link-to-Commons.js
ملحوظه: بعد التسييف، ممكن تحتاج تفضى كاش البراوزر بتاعك عشان تشوف التغييرات اللى عملتها، بالطريقه دى:
- فايرفوكس وسفارى: دوس ⇧ Shift مع Reload او Ctrl-F5 او Ctrl-R (اللى هو: Command-R على ماكنتوش)
- جوجل كروم: دوس Ctrl-Shift-R (اللى هو: Command-Shift-R على ماكنتوش)
- انترنت اكسبلورر: دوس Ctrl مع Refresh فى نفس الوقت، او Ctrl-F5
- كونكرر: دوس Reload او F5
- اوبرا: فضى الكاش من Tools → Preferences
if ( mw.config.get( 'wgNamespaceNumber', 0 ) >= 0 ) {
mw.hook( 'wikipage.content' ).add( function ( $content ) {
var
uploadBaseRe = /^\/\/upload\.wikimedia\.org\/wikipedia\/commons/,
localBasePath = new RegExp( '^' + mw.RegExp.escape( mw.util.getUrl( mw.config.get( 'wgFormattedNamespaces' )['6'] + ':' ) ) ),
localBaseScript = new RegExp( '^' + mw.RegExp.escape( mw.util.wikiScript() + '?title=' + mw.util.wikiUrlencode( mw.config.get( 'wgFormattedNamespaces' )['6'] + ':' ) ) ),
commonsBasePath = '//commons.wikimedia.org/wiki/File:',
commonsBaseScript = '//commons.wikimedia.org/w/index.php?title=File:';
$content.find( 'a.image' ).attr( 'href', function ( i, currVal ) {
if ( uploadBaseRe.test( $( this ).find( 'img' ).attr( 'src' ) ) ) {
return currVal
.replace( localBasePath, commonsBasePath )
.replace( localBaseScript, commonsBaseScript );
}
} );
} );
}