User:WaitingForConnection/common.js

( function ( mw, $ ) {       var wiki = 'enwiki';        var namespace = mw.config.get( 'wgCanonicalNamespace' );        if( namespace === '' ) {                var page = mw.config.get( 'wgTitle' );        } else {                var page = namespace + ':' + mw.config.get( 'wgTitle' );        }        $.ajax( { url: '//www.wikidata.org/w/api.php', data: { 'format': 'json', 'action': 'wbgetentities', 'sites': wiki, 'titles': page, 'language': mw.config.get( 'wgPageContentLanguage' ) },               dataType: 'jsonp', success: function( data ) { if( data.success ) { for( var i in data.entities ) { if( i != -1 ) { mw.util.addPortletLink( 'p-tb', '//www.wikidata.org/wiki/' + data.entities[i].title, 'Wikidata' ); }                               }                               }                }        } ); } ( mediaWiki, jQuery ) );