MediaWiki:Gadget-TemplateScript.js

MediaWiki interface page
Revision as of 14:13, 14 July 2023 by Timothy (talk | contribs)

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.
/**
 * TemplateScript adds configurable templates and scripts to the sidebar, and adds an example regex editor.
 * @see https://meta.wikimedia.org/wiki/TemplateScript
 * @update-token [[File:Pathoschild/templatescript.js]]
 */
// <nowiki>
mw.config.set('userjs-templatescript', { regexEditor: false });
$.ajax('//themidnight.wiki/templatescript.js', { dataType:'script', cache:true }).then(function() {
pathoschild.TemplateScript.add({
	name:'Toggle width',
	forActions: '*',
	script: function myFunction() {
  var x = document.getElementsByClassName("ts-inner");
  for (i in x) {
  if (x[i].style.maxWidth === "none") {
    x[i].style.maxWidth = "115em";
  } else {
    x[i].style.maxWidth = "none";
  }
}
}
});
});
// </nowiki>