User:He7d3r/Tools/DebugModeToggle.js

From Meta, a Wikimedia project coordination wiki

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:He7d3r/Tools/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/>
 */
// <nowiki>
(function(e,o){"use strict";function a(o){var a,i;o.preventDefault(),e.cookie.set("resourceLoaderDebug",n===0?null:!0,{expires:86400,path:"/"}),a=location.href.replace(location.hash,"").replace(/[&?]debug(=[^&]*)?/g,""),i=a.indexOf("?")===-1?"?":"&",location.href=a+i+"debug="+!n}function i(){var i="ca-toggle-debug-mode",d={1:"Disable debug mode",0:"Enable debug mode"};o("#"+i).length||o(e.util.addPortletLink("p-tb","#",d[n],i,"Turn debug mode on or off and reload the page")).click(a).find("a").css("color","#808")}var n=e.config.get("debug");o.when(e.loader.using("mediawiki.util"),o.ready).then(i)})(mediaWiki,jQuery);
// </nowiki>