MediaWiki:Gadget-autowelcome.js

From Zeah RSPS - 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.
/**
 * autowelcome.js - from https://runescape.wiki/w/User:Quarenon/autowelcome.js
 *
 * Automatically insert the welcome notice code when editing a new user talk page.
 *
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

// <nowiki>

if (mw.config.get('wgCanonicalNamespace') == 'User_talk' &&
	!mw.config.get('wgTitle').match(/([0-9]{1,3}\.){3}[0-9]{1,3}/) && // don't welcome IPv4
	!mw.config.get('wgTitle').match(/([0-9A-F]{1,4}:){7}[0-9A-F]{1,4}/) && // don't welcome IPv6
	mw.config.get('wgAction') == 'edit' &&
	mw.config.get('wgArticleId') === 0 &&
	mw.config.get('wgTitle').split('.').length != 4 &&
	mw.config.get('wgTitle').indexOf('/') == -1 &&
	!document.getElementsByClassName('mw-logline-block').length) {
		$(function() {
			$('#wpTextbox1').val((typeof(window.autoWelcomeText) == 'undefined') ? '{{Welcome}}\n\n-- ~~~~' : window.autoWelcomeText);
			$('#wpSummary,#wpSummaryEnhanced').val((typeof(window.autoWelcomeSummary) == 'undefined') ? 'Welcome!' : window.autoWelcomeSummary);
		});
}

// </nowiki>