Difference between revisions of "User:Dinoguy1000/common.js"

From Yugipedia
Jump to: navigation, search
(update last updated timestamp too)
m (Requested by Dino.)
Line 1: Line 1:
console.log('17:13, 7 October 2019 (UTC)');
+
console.log('10:29, 8 October 2019 (UTC)');
  
 
const dgconf = mw.config.get([
 
const dgconf = mw.config.get([
Line 48: Line 48:
 
href: '/wiki/Special:RandomInCategory/' + categoryName,
 
href: '/wiki/Special:RandomInCategory/' + categoryName,
 
title: 'Random page in category',
 
title: 'Random page in category',
text: '⤭',
+
text: ' ⤭',
 
} );
 
} );
 
} );
 
} );

Revision as of 10:29, 8 October 2019

console.log('10:29, 8 October 2019 (UTC)');

const dgconf = mw.config.get([
	'wgServer',
	'wgPageName',
	'wgCanonicalNamespace',
	'wgTitle'
	]);
dgconf.link = mw.util.addPortletLink;

/* begin stuff from [[User:Deltaneos/monobook.js]]
*/

// CSS refresh tab
$('#ca-purge').after('<li><a href="#" id="ca-css_refresh" title="Refresh the CSS on this page">css</a></li>');


$('#ca-css_refresh').click(function(ev)
{
	ev.preventDefault();
	var link = document.querySelector('link[href*="only=styles"]');
	if (link !== null)
	{
		link.href += '&ts='+Date.now();
	}
});

/* end copied from [[User:Deltaneos/monobook.js]] */

/* some mw.util.addPortletLink() documentation:

	function mw.util.addPortletLink(
		'HTML ID of the menu box to add the link to',
		'full URL of the link's target page[1]',
		'text to be displayed for the link',
		'HTML ID for the inserted link',
		'tooltip description to be displayed when hovering over the link',
		'keyboard shortcut for the link' );

	[1] This can be a literal URL, or JS variables such as wgServer can be used to enhance the code's portability.
		A little bit of cleverness can be used to generate dynamic URLs as well; for instance,
		"wgServer + '/index.php?title=Special:Log&page=' + wgPageName" will link to the current page's logs.
*/
$( function() {
	// Courtesy of Becasita =D
	$( '#catlinks li a' ).after( function( i, categoryName ) {
		return $( '<a>', {
			href: '/wiki/Special:RandomInCategory/' + categoryName,
			title: 'Random page in category',
			text: ' ⤭',
		} );
	} );

	if( dgconf.wgCanonicalNamespace != 'Special' ) {
		dgconf.link( 'p-tb', dgconf.wgServer + '/index.php?title=Special:Log&page=' + dgconf.wgPageName, 'Page logs', 'ca-viewlogs',
									'View the logs for this page, such as renames, deletions, and protections', '' );
	}

	if( dgconf.wgCanonicalNamespace == 'Category' ) {
		dgconf.link( 'p-tb', dgconf.wgServer + '/wiki/Special:RandomInCategory/' + dgconf.wgTitle, 'Random page in category', 'ca-randomincat',
									'View a random page or file in this category', '' );
	}

/*
	dgconf.link( 'p-random', dgconf.wgServer + '/wiki/Special:RandomInCategory/All cards',	'Card (all)',	'ca-randomcardall',		'View a random card (from all cards)',	'' );
	dgconf.link( 'p-random', dgconf.wgServer + '/wiki/Special:Random/Template',				'Template',		'ca-randomtemplate',	'View a random template',				'' );
	dgconf.link( 'p-random', dgconf.wgServer + '/wiki/Special:Random/Module',				'Module',		'ca-randommodule',		'View a random module',					'' );
	dgconf.link( 'p-random', dgconf.wgServer + '/wiki/Special:Random/Category',				'Category',		'ca-randomcategory',	'View a random category',				'' );
	dgconf.link( 'p-random', dgconf.wgServer + '/wiki/Special:Random/File',					'File',			'ca-randomfile',		'View a random file',					'' );
	dgconf.link( 'p-random', dgconf.wgServer + '/wiki/Special:Random/Property',				'Property',		'ca-randomproperty',	'View a random property',				'' );
	dgconf.link( 'p-random', dgconf.wgServer + '/wiki/Special:Random/Forum',				'Forum',		'ca-randomforum',		'View a random forum',					'' );
*/
});