MediaWiki:Gadget-autowelcome.js
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.
1 /**
2 * autowelcome.js - from https://runescape.wiki/w/User:Quarenon/autowelcome.js
3 *
4 * Automatically insert the welcome notice code when editing a new user talk page.
5 *
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 // <nowiki>
22 $(function() {
23 if (mw.config.get('wgCanonicalNamespace') == 'User_talk' &&
24 !mw.config.get('wgTitle').match(/([0-9]{1,3}\.){3}[0-9]{1,3}/) && // don't welcome IPv4
25 !mw.config.get('wgTitle').match(/([0-9A-F]{1,4}:){7}[0-9A-F]{1,4}/) && // don't welcome IPv6
26 mw.config.get('wgAction') == 'edit' &&
27 mw.config.get('wgArticleId') === 0 &&
28 mw.config.get('wgTitle').split('.').length != 4 &&
29 mw.config.get('wgTitle').indexOf('/') == -1 &&
30 !document.getElementsByClassName('mw-logline-block').length
31 ) {
32 $('#wpTextbox1').val((typeof(window.autoWelcomeText) == 'undefined') ? '{{Welcome}}\n\n-- ~~~~' : window.autoWelcomeText);
33 $('#wpSummary,#wpSummaryEnhanced').val((typeof(window.autoWelcomeSummary) == 'undefined') ? 'Welcome!' : window.autoWelcomeSummary);
34 }
35 })
36 // </nowiki>