User:Perhelion/DebugModeToggle.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.
// [[File:User:Perhelion/DebugModeToggle.js]] (workaround for [[phab:T35355]])
/**
 * Add a toggle for debug mode to the sidebar
 * @author: Helder (https://github.com/he7d3r)
 * @license: CC BY-SA 3.0 <https://creativecommons.org/licenses/by-sa/3.0/>
 */
(function (mw, $) {
"use strict";
mw.loader.using( [ 'mediawiki.util' ], function () {
	var d = mw.config.get( "debug" ),
		e = "ca-toggle-debug-mode",
		b = { "true" : "Disable", "false" : "Enable" },
		u = { /*expires : 1,*/ path : "/" },
		g = "#";
	$(g + e).length || $( mw.util.addPortletLink("p-tb", g, b[d] + " debug mode", e,
		"Turn debug mode on or off and reload the page")).on( 'click', function (e) {
		e.preventDefault();
		$.cookie("resourceLoaderDebug", (d ? null : !0), u);
		// window.location.reload(!0);
		u = location.search ? '&' : '?';
		location.href = location.href.replace(location.hash, '').replace(u + 'debug=' + d, '') + u + 'debug=' + !d;
	}).find('a').css('color', '#808');
});
})(mediaWiki, jQuery);