User:PetraMagna/momotalk-choice.js

From Blue Archive Wiki
Jump to navigation Jump to search

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.
let momotalk_options = function() {

	function defer(method) {
	    if (window.jQuery) {
	        method();
	    } else {
	        setTimeout(function() { defer(method) }, 50);
	    }
	}
	
	function momotalk_main(method) {
		$(document).ready(function() {
			const title_split = mw.config.get('wgTitle').toLowerCase().split("/");
			if (mw.config.get('wgNamespaceNumber') === 0 && title_split.length === 2 && title_split[1] === 'momotalk') {
				console.log("MomoTalk init.");
			} else {
				console.log("Not MomoTalk page. Exit.");
			}
		});
	}
	
	defer(momotalk_main);
};

momotalk_options();