Jump to content
This is a wiki for a reason. Anyone can contribute. If you see something that is inaccurate or can be improved, don't ask that it be fixed--just improve it.
[ Disclaimer, Create new user --- Wiki markup help, Install P99 ]

MediaWiki:MOTD.js

From p99 Backup
Revision as of 21:29, 25 March 2023 by imported>Loramin (Created page with "function getRandomQuote (items) { return Math.floor(Math.random() * items.length); } $.get('https://wiki.project1999.com/MediaWiki:Quotes.json').then(html => { var raw =...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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.
function getRandomQuote (items) {
  return Math.floor(Math.random() * items.length);
}

$.get('https://wiki.project1999.com/MediaWiki:Quotes.json').then(html => {

  var raw = html
    .split('<pre class="mw-code mw-js" dir="ltr">')[1]
    .split('/pre>')[0]
    .trim()
    .replaceAll('&quot;', '"');
  
  var messages = JSON.parse(raw);
  console.log(getRandomQuote(messages));
};