User:Jon Harald Søby/jsonredirect.js

From Wikidata
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)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
/* Automatically redirects you to [[Special:EntitySchema/<item>.json]] (or any other supported format)
 * when you add .json to the current item's URL.
 *
 * To use, add the following to your common.js:
 * mw.loader.load( 'https://www.wikidata.org/w/index.php?title=User:Jon_Harald_S%C3%B8by/jsonredirect.js&action=raw&ctype=text/javascript' );
 */
( function (mw) {
	var title = mw.config.get( 'wgTitle' ),
		ns = mw.config.get( 'wgNamespaceNumber' );
	if ( [0,120,146].indexOf(ns) !== -1 && title.includes(".") ) {
		window.location.replace("https://www.wikidata.org/entity/" + title);
	}
} ( mediaWiki ) );