User:ZilentFyld/thabs.js

var pageName = mw.config.get('wgPageName'); var pageTitle = mw.config.get('wgTitle'); var indexUrl = mw.util.wikiScript('index'); var apiUrl = mw.util.wikiScript('api'); $(document).ready(function {	var $thSection = $('h2:contains("Thai")').nextUntil('h2');	$thSection.find('.abstract-noun-form-of').each(function { var word = $(this).text; var kankwam = word.match(/(การ|ความ)/); var reading = $thSection.find('.th-reading').text; var prefix = { 'การ':'กาน-', 'ความ':'คฺวาม-' };		var pagetext = ''; pagetext += '==Thai==\n\n===Etymology==='; pagetext += '\n\n'; pagetext += '\n===Pronunciation==='; pagetext += '\n\n'; pagetext += '\n===Noun===\n\n'; pagetext += '\n# '; var button = $(' * ').click(=>{			$(this).fadeOut;			$.post(apiUrl, { 'action': 'edit', 'title': word, 'summary': 'สร้างหน้าอาการนาม', 'createonly': '1', 'appendtext': pagetext, 'token': mw.user.tokens.get('editToken'), 'format': 'xml' },=>{				$(this).removeClass('new').attr('href', (i,val) => {					return val.replace('&action=edit&redlink=1', '');				}).fadeIn; });		});		$(this).after(button); }); });