User:Base/CNBannerEditpreview.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.
/**
 * A script making it possible to preview CN banner while editing it, without saving the edit
 * It is a very makeshift thing made in order to make a certain modifications to the banner without much time to spare,
 * so you are to understand that it's just a variant for a better this than nothing case rather than a good thing to enjoy usage of.
 * Some limitations and todos are listed below
 * 
 * Does not expand messages like {{{text}}} but changes {{{banner}}} into current page title
 * TODO: manage script tags
 * TODO: manage style tags in a prettier way
 * TODO: make some button or whatever so this shall not to be run from the browser's scratchpad
 * TODO: find out whether it's a square-wheeled bicycle
*/
//ss for silly script
var sstext = $("#mw-input-wpbanner-body").val().replace(/\{\{\{banner}}}/g, $("#firstHeading").text());
var ssstyle = sstext.split("/style>");
$("head").append(ssstyle[0]+"/style>");

$("#siteNotice").html(ssstyle[1]);