User:Pathoschild/Scripts/debug.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)
- Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
/**
* This script prints a report to the console about the current page context,
* the browser version, and the loaded scripts maintained by Pathoschild.
*
* To use it:
* 1. Enter this command in your JavaScript console:
* mw.loader.load('https://meta.wikimedia.org/w/index.php?title=User:Pathoschild/Scripts/debug.js&action=raw&ctype=text/javascript')
* 2. Copy the output in a message to [[User talk:Pathoschild]] with a
* description of the issue you're having.
*/
$(function() {
"use strict";
// get page context
var context = mw.config.get();
context = {
userName: context.wgUserName,
skin: context.skin,
userLanguage: context.wgUserLanguage,
url: location.href,
browser: navigator.userAgent
};
// get enabled features from user preferences
var enabledFeatures = {};
$.each(mw.user.options.get(), function(key, value) {
var relevant =
key.startsWith('gadget-') // enabled gadgets
|| key.startsWith('use') // enabled features
|| key.startsWith('show') // enabled UI / beta features
|| key == 'skin';
if(relevant)
enabledFeatures[key] = value;
});
// get loaded Pathoschild scripts
var scripts = {
loaded: Object.keys(pathoschild),
data: pathoschild
};
// get TemplateScript sidebars
var sidebars = {};
$('.portal[id^="p-templatescript"]').each(function(i, sidebar) {
sidebar = $(sidebar);
sidebars[sidebar.attr('id')] = {
header: sidebar.find('h3').text(),
items: sidebar.find('li').map(function() { return $(this).text(); }).get()
};
});
scripts.templatescriptSidebars = sidebars;
// print report
var metadata = { context: context, enabledFeatures: enabledFeatures, pathoschild: scripts };
console.log('<source lang="javascript" style="max-height:300px; overflow:auto;">\n' + JSON.stringify(metadata, null, 3) + '\n<source>');
});