User:Jonas.keutel/ConstraintReport.js

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)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
/**********************************************************************************
***********************************************************************************
**                                                                               **
**  How To use:                                                                  **
**   Add the following to your common.js [[Special:MyPage/common.js]]:           **
**   importScript( 'User:Jonas.keutel/ConstraintReport.js' );                    **
**                                                                               **
**  About:                                                                       **
**    This tool will add a small link to entity's pages that will lead to the  	 **
**    ConstrainReport special page for thie current entity                       **
**                                                                               **
***********************************************************************************
**********************************************************************************/

( function ( mw, $ ) {
	'use strict';

	console.log('ConstraintReport');

	/**
	 * Check if we're viewing an entity
	 */
	var entityId = mw.config.get( 'wbEntityId' );
	if ( !entityId ) {
		return;
	}

	/**
	 * showLink
	 */
	function showLink() {
		var cr = "<a href=\"https://www.wikidata.org/wiki/Special:ConstraintReport/" + entityId + "\" style=\"color: green; position: absolute; right: 0; top: -2.6em; font-size: 125%\" class=\"wikibase-toolbar-item wikibase-toolbar wikibase-toolbar-container\">Check against constraints</a>";
		$(".wikibase-entitytermsview-heading-description ").append(cr);
		
		var gnd = "<a href=\"http://wikidataquality.wmflabs.org/w/index.php/Special:CrossCheck/" + entityId + "\" style=\"color: green; position: absolute; right: 0; top: -1.3em; font-size: 75%\" class=\"wikibase-toolbar-item wikibase-toolbar wikibase-toolbar-container\">And against GND (on labs)</a>";
		$(".wikibase-entitytermsview-heading-description ").append(gnd);
	}

	$( document ).ready( showLink );
} ( mediaWiki, jQuery ) );