User:Dinoguy1000/common.js
Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: hold down Ctrl and click the Refresh or Reload button. Firefox: hold down ⇧ Shift while clicking Reload (or press Ctrl+⇧ Shift+R). Google Chrome and Safari users can just click the Reload button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
console.log('User:Dinoguy1000/common.js last updated at 17:59, 2 February 2024 (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: '⤭'
} );
} ).after( ' ' );
$( '#mw-content-text a.mw-redirect' ).after( function() {
return $( '<a>', {
href: this.href + '?redirect=no',
title: 'View this redirect',
text: '↛'
} );
} ).after( ' ' );
$( '#mw-content-text a.new' ).after( function() {
return $( '<a>', {
href: '/wiki/Special:WhatLinksHere/' + this.title,
title: 'View incoming links',
text: '🔗',
} );
} ).after( ' ' );
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-tb', dgconf.wgServer + '/api.php?action=query&list=categorymembers&cmtitle=Category:' + dgconf.wgTitle + '&cmsort=timestamp&cmdir=desc&cmlimit=50',
'Recent category additions', 'ca-recentcategoryadditions',
'View the most recent 50 additions to this category', '');
}
});
// [[wikipedia:User:Ingenuity/AbuseFilterContribs]]
mw.loader.load( 'https://en.wikipedia.org/w/index.php?title=User:Ingenuity/AbuseFilterContribs.js&action=raw&ctype=text/javascript' );
// [[wikipedia:User:Jackmcbarn/advancedtemplatesandbox.js]]
mw.loader.load( 'https://en.wikipedia.org/w/index.php?title=User:Jackmcbarn/advancedtemplatesandbox.js&action=raw&ctype=text/javascript' );