Jump to content

User:Alexis Jazz/Factotum-test.js: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
No edit summary
store translation in localStorage
Line 5: Line 5:
Bawl = {};
Bawl = {};
//</nowiki>
//</nowiki>
Bawl.versionDate = '19:34, 9 February 2022 (UTC)';
Bawl.versionDate = '23:45, 9 February 2022 (UTC)';
//<nowiki>
//<nowiki>
Bawl.msgsObj = {};
Bawl.msgsObj = {};
Line 78: Line 78:
'BawlAddSectionToolbar':'Add section (Bawl)',
'BawlAddSectionToolbar':'Add section (Bawl)',
'nopingNotify':'This user doesn\'t want their username to be linked.',
'nopingNotify':'This user doesn\'t want their username to be linked.',
'titlePlaceholder':'',
'replyToTitle':'&#x1F5E8; USER',
'newSectionTitle':'Add section',
'editTitle':'Change comment',
'showNewLinesButton':'Show changed and added content',
'lang':'mul',
};
};
Bawl.msgsObj.en = {
'titlePlaceholder':'Title',
'replyToTitle':'Reply to USER',
'editTitle':'Edit comment',
}
Bawl.msgsObj.es = {'titlePlaceholder':'Asunto'};
Bawl.msgsObj.fr = {'titlePlaceholder':'Sujet'};
Bawl.msgsObj.zh = {'titlePlaceholder':'主题'};
Bawl.msgsObj.ru = {'titlePlaceholder':'Тема'};
Bawl.msgsObj.pt = {'titlePlaceholder':'Assunto'};
Bawl.msgsObj.it = {'titlePlaceholder':'Oggetto'};
Bawl.msgsObj.ja = {'titlePlaceholder':'題名'};
Bawl.msgsObj.pl = {'titlePlaceholder':'Temat'};
Bawl.msgsObj.vi = {'titlePlaceholder':'Đề mục'};
Bawl.msgsObj.sv = {'titlePlaceholder':'Ämne'};
Bawl.msgsObj.uk = {'titlePlaceholder':'Тема'};
Bawl.msgsObj.fa = {'titlePlaceholder':'عنوان'};
Bawl.basicmsgsObj.mul = { //multilingual and default texts, selected using wgUserLanguage. Messages that are required to load the script and open the form
Bawl.basicmsgsObj.mul = { //multilingual and default texts, selected using wgUserLanguage. Messages that are required to load the script and open the form
'BawlUIReplyButton':'  📢  ', //regular spaces are stripped, figure spaces are not
'BawlUIReplyButton':'  📢  ', //regular spaces are stripped, figure spaces are not
Line 84: Line 107:
'BawlUIPreviewButton':'  👁  ',
'BawlUIPreviewButton':'  👁  ',
'BawlUICancelButton':'  🗑️  ',
'BawlUICancelButton':'  🗑️  ',
'titlePlaceholder':'',
'replyToTitle':'&#x1F5E8; USER',
'newSectionTitle':'Add section',
'editTitle':'Edit comment',
'bold':' B ',
'bold':' B ',
'italic':' I ',
'italic':' I ',
'strike':'ABC',
'strike':'ABC',
'showNewLinesButton':'Show changed and added content',
};
};
Bawl.basicmsgsObj.en = {
Bawl.basicmsgsObj.en = {
Line 98: Line 116:
'BawlUIPreviewButton':'Preview',
'BawlUIPreviewButton':'Preview',
'BawlUICancelButton':'Cancel',
'BawlUICancelButton':'Cancel',
'titlePlaceholder':'Title',
'replyToTitle':'Reply to USER',
};
};
Bawl.basicmsgsObj.de = {
Bawl.basicmsgsObj.de = {
Line 106: Line 122:
'BawlUIPreviewButton':'Vorschau zeigen',
'BawlUIPreviewButton':'Vorschau zeigen',
'BawlUICancelButton':'Abbrechen',
'BawlUICancelButton':'Abbrechen',
'titlePlaceholder':'Titel',
'replyToTitle':'Antwort an USER',
'newSectionTitle':'Neuen Abschnitt',
'editTitle':'Kommentar bearbeiten',
'showNewLinesButton':'Geänderte und hinzugefügte Inhalte anzeigen',
};
};
Bawl.basicmsgsObj.es = {
Bawl.basicmsgsObj.es = {
Line 117: Line 128:
'BawlUIPreviewButton':'Previsualización',
'BawlUIPreviewButton':'Previsualización',
'BawlUICancelButton':'Cancelar',
'BawlUICancelButton':'Cancelar',
'titlePlaceholder':'Asunto',
'replyToTitle':'Reply to USER',
'newSectionTitle':'Add section',
'editTitle':'Edit comment',
};
};
Bawl.basicmsgsObj.fr = {
Bawl.basicmsgsObj.fr = {
Line 128: Line 135:
'BawlUICancelButton':'Annuler',
'BawlUICancelButton':'Annuler',
'titlePlaceholder':'Sujet',
'titlePlaceholder':'Sujet',
'replyToTitle':'Reply to USER',
'newSectionTitle':'Add section',
'editTitle':'Edit comment',
};
};
Bawl.basicmsgsObj.zh = {
Bawl.basicmsgsObj.zh = {
Line 138: Line 142:
'BawlUICancelButton':'取消',
'BawlUICancelButton':'取消',
'titlePlaceholder':'主题',
'titlePlaceholder':'主题',
'replyToTitle':'Reply to USER',
'newSectionTitle':'Add section',
'editTitle':'Edit comment',
};
};
Bawl.basicmsgsObj.ru = {
Bawl.basicmsgsObj.ru = {
Line 148: Line 149:
'BawlUICancelButton':'Отмена',
'BawlUICancelButton':'Отмена',
'titlePlaceholder':'Тема',
'titlePlaceholder':'Тема',
'replyToTitle':'Reply to USER',
'newSectionTitle':'Add section',
'editTitle':'Edit comment',
};
};
Bawl.basicmsgsObj.pt = {
Bawl.basicmsgsObj.pt = {
Line 158: Line 156:
'BawlUICancelButton':'Cancelar',
'BawlUICancelButton':'Cancelar',
'titlePlaceholder':'Assunto',
'titlePlaceholder':'Assunto',
'replyToTitle':'Reply to USER',
'newSectionTitle':'Add section',
'editTitle':'Edit comment',
};
};
Bawl.basicmsgsObj.it = {
Bawl.basicmsgsObj.it = {
Line 168: Line 163:
'BawlUICancelButton':'Annulla',
'BawlUICancelButton':'Annulla',
'titlePlaceholder':'Oggetto',
'titlePlaceholder':'Oggetto',
'replyToTitle':'Reply to USER',
'newSectionTitle':'Add section',
'editTitle':'Edit comment',
};
};
Bawl.basicmsgsObj.ja = {
Bawl.basicmsgsObj.ja = {
Line 178: Line 170:
'BawlUICancelButton':'キャンセル',
'BawlUICancelButton':'キャンセル',
'titlePlaceholder':'題名',
'titlePlaceholder':'題名',
'replyToTitle':'Reply to USER',
'newSectionTitle':'Add section',
'editTitle':'Edit comment',
};
};
Bawl.basicmsgsObj.pl = {
Bawl.basicmsgsObj.pl = {
Line 188: Line 177:
'BawlUICancelButton':'Anuluj',
'BawlUICancelButton':'Anuluj',
'titlePlaceholder':'Temat',
'titlePlaceholder':'Temat',
'replyToTitle':'Reply to USER',
'newSectionTitle':'Add section',
'editTitle':'Edit comment',
};
};
Bawl.basicmsgsObj.vi = {
Bawl.basicmsgsObj.vi = {
Line 198: Line 184:
'BawlUICancelButton':'Hủy bỏ',
'BawlUICancelButton':'Hủy bỏ',
'titlePlaceholder':'Đề mục',
'titlePlaceholder':'Đề mục',
'replyToTitle':'Reply to USER',
'newSectionTitle':'Add section',
'editTitle':'Edit comment',
};
};
Bawl.basicmsgsObj.sv = {
Bawl.basicmsgsObj.sv = {
Line 208: Line 191:
'BawlUICancelButton':'Avbryt',
'BawlUICancelButton':'Avbryt',
'titlePlaceholder':'Ämne',
'titlePlaceholder':'Ämne',
'replyToTitle':'Reply to USER',
'newSectionTitle':'Add section',
'editTitle':'Edit comment',
};
};
Bawl.basicmsgsObj.uk = {
Bawl.basicmsgsObj.uk = {
Line 218: Line 198:
'BawlUICancelButton':'Скасувати',
'BawlUICancelButton':'Скасувати',
'titlePlaceholder':'Тема',
'titlePlaceholder':'Тема',
'replyToTitle':'Reply to USER',
'newSectionTitle':'Add section',
'editTitle':'Edit comment',
};
};
Bawl.basicmsgsObj.fa = { //as fa is rtl I have no idea if Bawl will work properly in Farsi
Bawl.basicmsgsObj.fa = { //as fa is rtl I have no idea if Bawl will work properly in Farsi
Line 228: Line 205:
'BawlUICancelButton':'لغو',
'BawlUICancelButton':'لغو',
'titlePlaceholder':'عنوان',
'titlePlaceholder':'عنوان',
'replyToTitle':'Reply to USER',
'newSectionTitle':'Add section',
'editTitle':'Edit comment',
};
};
Bawl.basicmsgsObj.nl = {
Bawl.basicmsgsObj.nl = {
Line 237: Line 211:
'BawlUIPreviewButton':'Voorbeeld',
'BawlUIPreviewButton':'Voorbeeld',
'BawlUICancelButton':'Annuleren',
'BawlUICancelButton':'Annuleren',
'titlePlaceholder':'Titel',
'replyToTitle':'Reply to USER',
'newSectionTitle':'Add section',
'editTitle':'Edit comment',
'showNewLinesButton':'Laat gewijzigde en toegevoegde content zien',
};
};
Bawl.summaryCredit = ' ([[w:en:User:Alexis Jazz/Bawl|Bawl!]])';
Bawl.summaryCredit = ' ([[w:en:User:Alexis Jazz/Bawl|Bawl!]])';
Bawl.summaryCreditDE = ' ([[w:de:Benutzer:Alexis Jazz/Bawl|Bawl!]])';
Bawl.wikiMsgsObj.mul = { //multilingual and default texts. Messages that end up in wikitext or edit summaries. Selected using wgPageContentLanguage
Bawl.wikiMsgsObj.mul = { //multilingual and default texts. Messages that end up in wikitext or edit summaries. Selected using wgPageContentLanguage
'difflinkname':' (diff $7)',
'difflinkname':' (diff $7)',
Line 270: Line 240:
'difflinknameprevnext':' (diff ~$8)',
'difflinknameprevnext':' (diff ~$8)',
'pageHistoryLinkName':'$4 (Versionsgeschichte)',
'pageHistoryLinkName':'$4 (Versionsgeschichte)',
'postCommentSummaryPost':'Antwort an USER ([[w:en:User:Alexis Jazz/Bawl|Bawl!]])' + Bawl.summaryCredit,
'postCommentSummaryPost':'Antwort an USER ([[w:en:User:Alexis Jazz/Bawl|Bawl!]])' + Bawl.summaryCreditDE,
'postSubsectionSummaryPost':'neuen Teilabschnitt: [[#SUBSECTION|SUBSECTION]]' + Bawl.summaryCredit,
'postSubsectionSummaryPost':'neuen Teilabschnitt: [[#SUBSECTION|SUBSECTION]]' + Bawl.summaryCreditDE,
'postCommentSummaryNewSection':'[[#NEWSECTION|→NEWSECTION]]: neuen AbschnittSUMMARY' + Bawl.summaryCredit,
'postCommentSummaryNewSection':'[[#NEWSECTION|→NEWSECTION]]: neuen AbschnittSUMMARY' + Bawl.summaryCreditDE,
'editCommentSummary':'editing comment' + Bawl.summaryCredit,
'editCommentSummary':'Kommentar bearbeiten' + Bawl.summaryCreditDE,
'savePrefsSummary':'Einstellungen speichern' + Bawl.summaryCredit,
'savePrefsSummary':'Einstellungen speichern' + Bawl.summaryCreditDE,
'deletePrefsSummary':'Einstellungen löschen' + Bawl.summaryCredit,
'deletePrefsSummary':'Einstellungen löschen' + Bawl.summaryCreditDE,
};
};
if ( typeof BawlBasicmsgsObj != 'undefined' && BawlBasicmsgsObj[ mw.config.get('wgUserLanguage') ] ) { // BawlBasicmsgsObj could be specified in common.js before Bawl is loaded
if ( typeof BawlBasicmsgsObj != 'undefined' && BawlBasicmsgsObj[ mw.config.get('wgUserLanguage') ] ) { // BawlBasicmsgsObj could be specified in common.js before Bawl is loaded
Line 293: Line 263:
if ( typeof BawlmsgsObj != 'undefined' && BawlmsgsObj[ mw.config.get('wgUserLanguage') ] ) { // BawlmsgsObj could be specified in common.js before Bawl is loaded
if ( typeof BawlmsgsObj != 'undefined' && BawlmsgsObj[ mw.config.get('wgUserLanguage') ] ) { // BawlmsgsObj could be specified in common.js before Bawl is loaded
Bawl.msgs = Object.assign(Bawl.msgsObj.mul, BawlmsgsObj[ mw.config.get('wgUserLanguage') ]);
Bawl.msgs = Object.assign(Bawl.msgsObj.mul, BawlmsgsObj[ mw.config.get('wgUserLanguage') ]);
} else if ( window.localStorage['BawlLang'+mw.config.get('wgUserLanguage')] && JSON.parse(window.localStorage['BawlLang'+mw.config.get('wgUserLanguage')]) && JSON.parse(window.localStorage['BawlLang'+mw.config.get('wgUserLanguage')]).date == Bawl.versionDate && JSON.parse(window.localStorage['BawlLang'+mw.config.get('wgUserLanguage')]).lang == mw.config.get('wgUserLanguage') ) {
Bawl.msgs = Object.assign(Bawl.msgsObj.mul, JSON.parse(window.localStorage['BawlLang'+mw.config.get('wgUserLanguage')]) );
} else {
} else {
Bawl.msgs = Bawl.msgsObj.mul;
Bawl.msgs = Bawl.msgsObj.mul;
Line 970: Line 942:
Bawl.showNewLinesButton = new OO.ui.ButtonWidget( {
Bawl.showNewLinesButton = new OO.ui.ButtonWidget( {
id: 'BawlshowNewLinesButton',
id: 'BawlshowNewLinesButton',
label: Bawl.basicmsgs.showNewLinesButton,
label: Bawl.msgs.showNewLinesButton,
flags: [ 'primary' ],
flags: [ 'primary' ],
} );
} );
Line 1,142: Line 1,114:
classes: [ 'BawlMarginHalfEm',Bawl.BawlUITextInputTitleClass ],
classes: [ 'BawlMarginHalfEm',Bawl.BawlUITextInputTitleClass ],
value: Bawl.preloadTitle,
value: Bawl.preloadTitle,
placeholder: Bawl.basicmsgs.titlePlaceholder,
placeholder: Bawl.msgs.titlePlaceholder,
} );
} );
Bawl.UITextInput = new OO.ui.MultilineTextInputWidget( {
Bawl.UITextInput = new OO.ui.MultilineTextInputWidget( {
Line 2,182: Line 2,154:
}
}
if ( replyLinkParams.type == 'comment' ) {
if ( replyLinkParams.type == 'comment' ) {
Bawl.replyLinkText = '<span title="' + Bawl.basicmsgs.replyToTitle.replace('USER', Bawl.escapeHTML(replyLinkParams.origReplyTo)) + Bawl.replyLinkDebugInfo + '" class="BawlReplyLinkIcon BawlReplyLink">' + Bawl.svgBawlIcon + '</span>';
Bawl.replyLinkText = '<span title="' + Bawl.msgs.replyToTitle.replace('USER', Bawl.escapeHTML(replyLinkParams.origReplyTo)) + Bawl.replyLinkDebugInfo + '" class="BawlReplyLinkIcon BawlReplyLink">' + Bawl.svgBawlIcon + '</span>';
} else if ( replyLinkParams.type == 'heading' ) {
} else if ( replyLinkParams.type == 'heading' ) {
Bawl.replyLinkText = '<span title="' + Bawl.basicmsgs.newSectionTitle + Bawl.replyLinkDebugInfo + '" class="BawlReplyLinkIcon BawlReplyLink">' + Bawl.svgBawlIconNewSection + '</span>';
Bawl.replyLinkText = '<span title="' + Bawl.msgs.newSectionTitle + Bawl.replyLinkDebugInfo + '" class="BawlReplyLinkIcon BawlReplyLink">' + Bawl.svgBawlIconNewSection + '</span>';
} else if ( replyLinkParams.type == 'edit' ) {
} else if ( replyLinkParams.type == 'edit' ) {
Bawl.replyLinkText = '<span title="' + Bawl.basicmsgs.editTitle + Bawl.replyLinkDebugInfo + '" class="BawlReplyLinkIcon BawlReplyLink">' + Bawl.svgBawlIconEdit + '</span>';
Bawl.replyLinkText = '<span title="' + Bawl.msgs.editTitle + Bawl.replyLinkDebugInfo + '" class="BawlReplyLinkIcon BawlReplyLink">' + Bawl.svgBawlIconEdit + '</span>';
}
}
Bawl.replyLinkHTML = document.createElement('span');
Bawl.replyLinkHTML = document.createElement('span');

Revision as of 23:45, 9 February 2022

//<nowiki>
//Bawl is a userscript to add comments to discussions with more features and options than usual. Probably better support too.
//https://en.wikipedia.org/wiki/User:Alexis_Jazz/Bawl (report issues to the talk page)
if ( $('#ca-addsection')[0] || ( $('.ext-discussiontools-init-replylink-buttons')[0] && $('.ext-discussiontools-init-replylink-buttons')[0] ) || ( mw.config.get('wgNamespaceNumber') != -1 && mw.config.get('wgNamespaceNumber') != 2 && ( mw.config.get('wgNamespaceNumber') != 0 || mw.config.get('wgDBname') == 'metawiki' ) && mw.config.get('wgNamespaceNumber') != 6 && mw.config.get('wgNamespaceNumber') != 14 && mw.config.get('wgPageContentModel') == 'wikitext' && mw.config.get('wgAction') == 'view' && mw.config.get('wgDiffNewId') == null && window.location.href.match('veaction=') == null && window.location.href.match('oldid=') == null	) ) {
Bawl = {};
//</nowiki>
Bawl.versionDate = '23:45, 9 February 2022 (UTC)';
//<nowiki>
Bawl.msgsObj = {};
Bawl.basicmsgsObj = {};
Bawl.wikiMsgsObj = {};
Bawl.ToSlink = 'https://foundation.wikimedia.org/wiki/Special:MyLanguage/Terms_of_Use';
Bawl.CCBYSAlink = 'https://creativecommons.org/licenses/by-sa/3.0';
Bawl.CCBY25link = 'https://creativecommons.org/licenses/by/2.5';
Bawl.GFDLlink = 'https://en.wikipedia.org/wiki/Wikipedia:Text_of_the_GNU_Free_Documentation_License';
Bawl.msgsObj.mul = { //multilingual and default texts, selected using wgUserLanguage. Messages that are used beyond the initial opening of the form.
	'UILabelInterface':'Interface',
	'tosNag':'Annoy me with the ToS all the time (you can disable this!)',
	'afterPost':'After posting:',
	'nSecLink':'Insert link to add a new section',
	'replySecLink':'Add reply button at the bottom of sections',
	'secLinks':'Insert links to add subsections',
	'inputBoxTO':'Take over <a href="https://www.mediawiki.org/wiki/Extension:InputBox" target="_new">InputBoxes</a>',
	'editLinks':'Insert links to edit my comments',
	'editNotice':'Show <a href="https://en.wikipedia.org/wiki/Wikipedia:Editnotice" target="_new">editnotices</a>',
	'dateLinksIcon':'Link comments through comment link icon',
	'dateLinks':'Link comments through signature dates (may break other gadgets that insert buttons near comments)',
	'dateLinksLocalTime':'Display signature date in local time (requires above)',
	'wrongUI':'Put buttons on the wrong side like <a href="' + mw.config.get('wgServer') + mw.config.get('wgArticlePath').replace('$1', 'm:Special:MyLanguage/Talk_pages_project/Feature_summary') + '" target="_new">DiscussionTools</a>',
	'livePreview':'Live preview',
	'checkNewComments':'Check for new comments when opening form/preview',
	'limitWidth':'Limit interface width',
	'RLmasq':'Masquerade as reply-link',
	'warnExit':'Warn before leaving the page with an entered comment',
	'UIfontSize':'Interface size:',
	'UILabelEditing':'Editing',
	'autoPing':'Auto-mention',
	'markup':'Enable basic markup toolbar',
	'enableCI':'Enable custom inserts',
	'enableCIThatRun':'Enable custom regular expressions that are automatically applied on preview/publish',
	'rewritun':'Rewrite external URLs to internal ones where possible, clean internal links',
	'markdown':'Convert <a href="https://en.wikipedia.org/wiki/Markdown" target="_new">Markdown</a> markup language (partial implementation)',
	'bbcode':'Convert <a href="https://en.wikipedia.org/wiki/BBCode" target="_new">BBCode</a> markup language',
	'useLocator':'Add invisible comment locator to comments (improves functionality)',
	'sumSnippet':'Add snippet to edit summary',
	'pingText':'Mention format, e.g. "Yo [[User:USER|USER]]! "',
	'UILabelAdvanced':'Advanced',
	'watchlist':'Watchlist setting:',
	'watchlistexpiry':'Watchlist expiration: ',
	'hideThePain':'Hide reply links from DiscussionTools',
	'debug':'Enable test/debug mode',
	'saveTo':'Save settings to:',
	'saveSettings':'Save',
	'resetPreferencesBrowser':'Clear browser preferences',
	'resetPreferencesCommonJS':'Clear account preferences',
	'resetPreferencesGlobalJS':'Clear global account preferences',
	'watchlistexpirydays':'DAYS days',
	'BawlCustomInsertPlaceholder':'fooNUM:<<bar>>',
	'BawlCustomInsertThatRunPlaceholder':'/[Ff]ooNUM/bar/g',
	'UIfontSize0875em':'0.875em',
	'UIfontSizeTiny':'Tiny!',
	'UIfontSizeSmall':'Small',
	'UIfontSizeMedium':'Medium',
	'UIfontSizeLarge':'Large',
	'UIfontSizeHuge':'Huge',
	'reloadafter':'Reload the page (slowest)',
	'linkafter':'Just show a link (fastest)',
	'parsecomment':'Parse comment in place (might be inaccurate)',
	'saveToGlobalJS':'Global account (public)',
	'saveToCommonJS':'Account (public)',
	'saveToBrowser':'This browser',
	'commentPosted':'Comment posted!',
	'commentEdited':'Comment changed!',
	'sectionAdded':'Section added!',
	'commentPostedThankYou':' Thank you for using <a href="https://en.wikipedia.org/wiki/User:Alexis_Jazz/Bawl" target="_new">Bawl!</a>',
	'tosNagText':'<div id="BawlToSNag">By pressing "Reply", you agree to Wikimedia\'s <a href="' + Bawl.ToSlink + '">Terms of Use</a> and agree to irrevocably release your text under the <a href="' + Bawl.CCBYSAlink + '" target="_new">CC BY-SA 3.0 License</a> and <a href="' + Bawl.GFDLlink + '" target="_new">GFDL</a>. You can <a onclick="Bawl.openSettings(\'open\'); window.BawlPreftosNag.scrollIntoView()">disable this nagging message.</a></div>',
	'editNoticeSetting':'<a onclick="Bawl.openSettings(\'open\'); window.editNotice.scrollIntoView()"><span style="color:black; opacity:0.5; font-size:smaller; float:right;">Editnotices can be disabled</span></a>', //todo: insert this
	'BawlAddSectionToolbar':'Add section (Bawl)',
	'nopingNotify':'This user doesn\'t want their username to be linked.',
	'titlePlaceholder':'',
	'replyToTitle':'&#x1F5E8; USER',
	'newSectionTitle':'Add section',
	'editTitle':'Change comment',
	'showNewLinesButton':'Show changed and added content',
	'lang':'mul',
};
Bawl.msgsObj.en = {
	'titlePlaceholder':'Title',
	'replyToTitle':'Reply to USER',
	'editTitle':'Edit comment',
}
Bawl.msgsObj.es = {'titlePlaceholder':'Asunto'};
Bawl.msgsObj.fr = {'titlePlaceholder':'Sujet'};
Bawl.msgsObj.zh = {'titlePlaceholder':'主题'};
Bawl.msgsObj.ru = {'titlePlaceholder':'Тема'};
Bawl.msgsObj.pt = {'titlePlaceholder':'Assunto'};
Bawl.msgsObj.it = {'titlePlaceholder':'Oggetto'};
Bawl.msgsObj.ja = {'titlePlaceholder':'題名'};
Bawl.msgsObj.pl = {'titlePlaceholder':'Temat'};
Bawl.msgsObj.vi = {'titlePlaceholder':'Đề mục'};
Bawl.msgsObj.sv = {'titlePlaceholder':'Ämne'};
Bawl.msgsObj.uk = {'titlePlaceholder':'Тема'};
Bawl.msgsObj.fa = {'titlePlaceholder':'عنوان'};
Bawl.basicmsgsObj.mul = { //multilingual and default texts, selected using wgUserLanguage. Messages that are required to load the script and open the form
	'BawlUIReplyButton':'  📢  ', //regular spaces are stripped, figure spaces are not
	'BawlUIEditButton' : '  🖋️  ',
	'BawlUIPreviewButton':'  👁  ',
	'BawlUICancelButton':'  🗑️  ',
	'bold':' B ',
	'italic':' I ',
	'strike':'ABC',
};
Bawl.basicmsgsObj.en = {
	'BawlUIReplyButton':'Reply',
	'BawlUIEditButton' : 'Submit',
	'BawlUIPreviewButton':'Preview',
	'BawlUICancelButton':'Cancel',
};
Bawl.basicmsgsObj.de = {
	'BawlUIReplyButton':'Antworten',
	'BawlUIEditButton' : 'Bearbeiten',
	'BawlUIPreviewButton':'Vorschau zeigen',
	'BawlUICancelButton':'Abbrechen',
};
Bawl.basicmsgsObj.es = {
	'BawlUIReplyButton':'Responder',
	'BawlUIEditButton' : 'Publicar cambios',
	'BawlUIPreviewButton':'Previsualización',
	'BawlUICancelButton':'Cancelar',
};
Bawl.basicmsgsObj.fr = {
	'BawlUIReplyButton':'Répondre',
	'BawlUIEditButton' : 'Publier vos modifications',
	'BawlUIPreviewButton':'Aperçu',
	'BawlUICancelButton':'Annuler',
	'titlePlaceholder':'Sujet',
};
Bawl.basicmsgsObj.zh = {
	'BawlUIReplyButton':'回复',
	'BawlUIEditButton' : '发布您的更改',
	'BawlUIPreviewButton':'预览',
	'BawlUICancelButton':'取消',
	'titlePlaceholder':'主题',
};
Bawl.basicmsgsObj.ru = {
	'BawlUIReplyButton':'Ответить',
	'BawlUIEditButton' : 'Опубликовать ваши изменения',
	'BawlUIPreviewButton':'Предпросмотр',
	'BawlUICancelButton':'Отмена',
	'titlePlaceholder':'Тема',
};
Bawl.basicmsgsObj.pt = {
	'BawlUIReplyButton':'Responder',
	'BawlUIEditButton' : 'Publicar as suas alterações',
	'BawlUIPreviewButton':'Pré-visualizar',
	'BawlUICancelButton':'Cancelar',
	'titlePlaceholder':'Assunto',
};
Bawl.basicmsgsObj.it = {
	'BawlUIReplyButton':'Rispondi',
	'BawlUIEditButton' : 'Pubblica le tue modifiche',
	'BawlUIPreviewButton':'Anteprima',
	'BawlUICancelButton':'Annulla',
	'titlePlaceholder':'Oggetto',
};
Bawl.basicmsgsObj.ja = {
	'BawlUIReplyButton':'返信',
	'BawlUIEditButton' : 'あなたによる変更を公開',
	'BawlUIPreviewButton':'プレビュー',
	'BawlUICancelButton':'キャンセル',
	'titlePlaceholder':'題名',
};
Bawl.basicmsgsObj.pl = {
	'BawlUIReplyButton':'Odpowiedz',
	'BawlUIEditButton' : 'Opublikuj swoje zmiany',
	'BawlUIPreviewButton':'Podgląd',
	'BawlUICancelButton':'Anuluj',
	'titlePlaceholder':'Temat',
};
Bawl.basicmsgsObj.vi = {
	'BawlUIReplyButton':'Trả lời',
	'BawlUIEditButton' : 'Đăng thay đổi của bạn',
	'BawlUIPreviewButton':'Xem trước',
	'BawlUICancelButton':'Hủy bỏ',
	'titlePlaceholder':'Đề mục',
};
Bawl.basicmsgsObj.sv = {
	'BawlUIReplyButton':'Svara',
	'BawlUIEditButton' : 'Publicera dina ändringar',
	'BawlUIPreviewButton':'Förhandsgranska',
	'BawlUICancelButton':'Avbryt',
	'titlePlaceholder':'Ämne',
};
Bawl.basicmsgsObj.uk = {
	'BawlUIReplyButton':'Відповісти',
	'BawlUIEditButton' : 'Опублікувати ваші зміни',
	'BawlUIPreviewButton':'Попередній перегляд',
	'BawlUICancelButton':'Скасувати',
	'titlePlaceholder':'Тема',
};
Bawl.basicmsgsObj.fa = { //as fa is rtl I have no idea if Bawl will work properly in Farsi
	'BawlUIReplyButton':'پاسخ',
	'BawlUIEditButton' : 'انتشار تغییراتتان',
	'BawlUIPreviewButton':'پیش‌نمایش',
	'BawlUICancelButton':'لغو',
	'titlePlaceholder':'عنوان',
};
Bawl.basicmsgsObj.nl = {
	'BawlUIReplyButton':'Reageren',
	'BawlUIEditButton' : 'Aanpassen',
	'BawlUIPreviewButton':'Voorbeeld',
	'BawlUICancelButton':'Annuleren',
};
Bawl.summaryCredit = ' ([[w:en:User:Alexis Jazz/Bawl|Bawl!]])';
Bawl.summaryCreditDE = ' ([[w:de:Benutzer:Alexis Jazz/Bawl|Bawl!]])';
Bawl.wikiMsgsObj.mul = { //multilingual and default texts. Messages that end up in wikitext or edit summaries. Selected using wgPageContentLanguage
	'difflinkname':' (diff $7)',
	'difflinknameprevnext':' (diff ~$8)',
	'pageHistoryLinkName':'$4 (page history)',
	'postCommentSummaryPost':'replying to USER' + Bawl.summaryCredit,
	'postSubsectionSummaryPost':'new subsection: [[#SUBSECTION|SUBSECTION]]' + Bawl.summaryCredit,
	'postCommentSummaryNewSection':'[[#NEWSECTION|→NEWSECTION]]: new sectionSUMMARY' + Bawl.summaryCredit,
	'editCommentSummary':'editing comment' + Bawl.summaryCredit,
	'savePrefsSummary':'Saving preferences' + Bawl.summaryCredit,
	'deletePrefsSummary':'Clearing preferences' + Bawl.summaryCredit,
};
Bawl.wikiMsgsObj.nl = {
	'difflinkname':' (diff $7)',
	'difflinknameprevnext':' (diff ~$8)',
	'pageHistoryLinkName':'$4 (paginageschiedenis)',
	'postCommentSummaryPost':'reactie op USER' + Bawl.summaryCredit,
	'postSubsectionSummaryPost':'nieuwe subsectie: [[#SUBSECTION|SUBSECTION]]' + Bawl.summaryCredit,
	'postCommentSummaryNewSection':'[[#NEWSECTION|→NEWSECTION]]: nieuw onderwerpSUMMARY' + Bawl.summaryCredit,
	'editCommentSummary':'wijzig reactie' + Bawl.summaryCredit,
	'savePrefsSummary':'Voorkeuren opslaan' + Bawl.summaryCredit,
	'deletePrefsSummary':'Voorkeuren wissen' + Bawl.summaryCredit,
};
Bawl.wikiMsgsObj.de = {
	'difflinkname':' (diff $7)',
	'difflinknameprevnext':' (diff ~$8)',
	'pageHistoryLinkName':'$4 (Versionsgeschichte)',
	'postCommentSummaryPost':'Antwort an USER ([[w:en:User:Alexis Jazz/Bawl|Bawl!]])' + Bawl.summaryCreditDE,
	'postSubsectionSummaryPost':'neuen Teilabschnitt: [[#SUBSECTION|SUBSECTION]]' + Bawl.summaryCreditDE,
	'postCommentSummaryNewSection':'[[#NEWSECTION|→NEWSECTION]]: neuen AbschnittSUMMARY' + Bawl.summaryCreditDE,
	'editCommentSummary':'Kommentar bearbeiten' + Bawl.summaryCreditDE,
	'savePrefsSummary':'Einstellungen speichern' + Bawl.summaryCreditDE,
	'deletePrefsSummary':'Einstellungen löschen' + Bawl.summaryCreditDE,
};
if ( typeof BawlBasicmsgsObj != 'undefined' && BawlBasicmsgsObj[ mw.config.get('wgUserLanguage') ] ) { // BawlBasicmsgsObj could be specified in common.js before Bawl is loaded
	Bawl.basicmsgs = Object.assign(Bawl.basicmsgsObj.mul, BawlBasicmsgsObj[ mw.config.get('wgUserLanguage') ]);
} else if ( Bawl.basicmsgsObj[ mw.config.get('wgUserLanguage') ] ) {
	Bawl.basicmsgs = Object.assign(Bawl.basicmsgsObj.mul, Bawl.basicmsgsObj[ mw.config.get('wgUserLanguage') ]);
} else {
	Bawl.basicmsgs = Bawl.basicmsgsObj.mul;
}
if ( typeof BawlWikiMsgsObj != 'undefined' && BawlWikiMsgsObj[ mw.config.get('wgPageContentLanguage') ] ) { // BawlwikiMsgsObj could be specified in common.js before Bawl is loaded
	Bawl.wikiMsgs = Object.assign(Bawl.wikiMsgsObj.mul, BawlWikiMsgsObj[ mw.config.get('wgPageContentLanguage') ]);
} else if ( Bawl.wikiMsgsObj[ mw.config.get('wgPageContentLanguage') ] ) {
	Bawl.wikiMsgs = Object.assign(Bawl.wikiMsgsObj.mul, Bawl.wikiMsgsObj[ mw.config.get('wgPageContentLanguage') ]);
} else {
	Bawl.wikiMsgs = Bawl.wikiMsgsObj.mul;
}
if ( typeof BawlmsgsObj != 'undefined' && BawlmsgsObj[ mw.config.get('wgUserLanguage') ] ) { // BawlmsgsObj could be specified in common.js before Bawl is loaded
	Bawl.msgs = Object.assign(Bawl.msgsObj.mul, BawlmsgsObj[ mw.config.get('wgUserLanguage') ]);
} else if ( window.localStorage['BawlLang'+mw.config.get('wgUserLanguage')] && JSON.parse(window.localStorage['BawlLang'+mw.config.get('wgUserLanguage')]) && JSON.parse(window.localStorage['BawlLang'+mw.config.get('wgUserLanguage')]).date == Bawl.versionDate && JSON.parse(window.localStorage['BawlLang'+mw.config.get('wgUserLanguage')]).lang == mw.config.get('wgUserLanguage') ) {
	Bawl.msgs = Object.assign(Bawl.msgsObj.mul, JSON.parse(window.localStorage['BawlLang'+mw.config.get('wgUserLanguage')]) );
} else {
	Bawl.msgs = Bawl.msgsObj.mul;
}
if ( ['smurf', 'tlh'].indexOf(mw.config.get('wgUserLanguage')) != -1 ) {
	mw.loader.getScript('https://en.wikipedia.org/enwiki/w/index.php?title=User:Alexis_Jazz/Bawl-lang.js&action=raw&ctype=text/javascript');
}
//default wiki config
Bawl.pingText = '[[' + mw.config.get('wgFormattedNamespaces')[2] + ':USERNAME|]], ';
Bawl.pingTextAnon = '[[' + mw.config.get('wgFormattedNamespaces')[-1] + ':Contributions/USERNAME|USERNAME]], ';
Bawl.commentTextIndentWikiDefault = '*';
Bawl.defaultSectionHeader = '==';
Bawl.newLineTemplate = '<br />';
Bawl.monthNames = mw.config.get('wgMonthNames'); // months as found in signatures
Bawl.timestampFormat = '$6$7$8:$9$10$11'; //just the time without date as date is unpredictable, could cause problems if there are multiple comments at the same time by the same user on the same page, recommended to configure for your wiki. Use "MONTHNAME" to insert the name of the month. Processed by /(0?)([1-3]?)([0-9])\/([0-1][0-9])\/([0-9]{4}), (0?)([1-2]?)([0-9])\:(0?)([0-9]?)([0-9])/
Bawl.endOfCommentLocator = '{{subst:#ifexist:Template:BawlCmt|{{BawlCmt|USERTIME|INNERCONTENT}}|<span id="USERTIME" class="BawlCmt">INNERCONTENT</span>}}';
if ( mw.config.get('wgDBname') == 'enwiki' ) { //overwrite config where needed
	Bawl.wikiTimezone = 'UTC'; //used with new Date().toLocaleString("en-GB", {timeZone: Bawl.wikiTimezone});, toLocaleString takes care of DST so CET/CEST is just CET
	Bawl.pingText = '{{u|USERNAME}}, ';
	Bawl.newLineTemplate = '{{Break}}';
	Bawl.timestampFormat = '$6$7$8:$9$10$11, $2$3 MONTHNAME $5';
} else if ( mw.config.get('wgDBname') == 'dewiki' ) {
	Bawl.monthNames = { 1: 'Jan.', 2: 'Feb.', 3: 'Mär.', 4: 'Apr.', 5: 'Mai', 6: 'Jun.', 7: 'Jul.', 8: 'Aug.', 9: 'Sep.', 10: 'Okt.', 11: 'Nov.', 12: 'Dez.' };
	Bawl.timestampFormat = '$6$7$8:$9$10$11, $2$3. MONTHNAME $5';
	Bawl.wikiTimezone = 'CET';
} else if ( mw.config.get('wgDBname') == 'nlwiktionary' || mw.config.get('wgDBname') == 'nlwiki' ) {
	Bawl.commentTextIndentWikiDefault = ':';
	Bawl.monthNames = { 1: 'jan', 2: 'feb', 3: 'mrt', 4: 'apr', 5: 'mei', 6: 'jun', 7: 'jul', 8: 'aug', 9: 'sep', 10: 'okt', 11: 'nov', 12: 'dec' };
	Bawl.timestampFormat = '$2$3 MONTHNAME $5 $6$7$8:$9$10$11';
	Bawl.wikiTimezone = 'CET';
} else if ( [ 'thwikibooks', 'thwiki', 'thwikisource', 'thwiktionary', 'thwikiquote' ].indexOf(mw.config.get('wgDBname')) != -1 ) {
	Bawl.wikiTimezone = 'Asia/Bangkok';
	Bawl.timestampFormat = '$6$7$8:$9$10$11, $2$3 MONTHNAME'; //Thai solar calendar. Who needs to know what year it is anyway
}
Bawl.languagesAvailableInExternalFile = ['nl','de']; //array of full translations available in Bawl-lang.js
Bawl.pageLoadTimestamp = new Date().toISOString(); //to detect new comments since loading the page
mw.loader.using( [ 'oojs-ui', 'oojs-ui.styles.icons-interactions' ] ).then( function () {
	Bawl.trySectionEdit = true;
	Bawl.editConflictRetries = 10;
	Bawl.defaultSettings = { //default settings
		'UILabelInterface':'LABEL',
		'tosNag': true,
		'afterPost':'parsecomment', //currently reload, link or parsecomment
		'nSecLink': true,
		'replySecLink': true,
		'secLinks': true,
		'inputBoxTO': true,
		'editLinks': true,
		'editNotice': false,
		'dateLinksIcon': true,
		'dateLinks': false,
		'dateLinksLocalTime': false,
		'wrongUI': false,
		'livePreview': false,
		'checkNewComments' : true,
		'limitWidth': false,
		'RLmasq': false,
		'warnExit': true,
		'UIfontSize':'small',
		'UILabelEditing':'LABEL',
		'autoPing': true,
		'markup': true,
		'enableCI': true,
		'enableCIThatRun': true,
		'cI': {}, //examples: /youtu\.be(.)/youtube.com$1watch\?/, '''Keep''', {{AIV|chk}}, {{subst:AfC invite}}
		'cIThatRun': {}, //custom inserts that get automatically executed.
		'rewritun': true,
		'markdown': false,
		'bbcode': false,
		'useLocator': true,
		'sumSnippet': true,
		'pingText': Bawl.pingText,
		'UILabelAdvanced':'LABEL',
		'watchlist':'watch',
		'watchlistexpiry':'90 days',
		'hideThePain': true,
		'debug': false,
		'saveTo':'commonjs',
	};
	Bawl.settings = $.extend( true, {}, Bawl.defaultSettings ); // copy as = only creates a shortcut
	//ensure a concistent look, icons are own work
	Bawl.svgBawlIconData = 'data:image/svg+xml,' + encodeURIComponent('<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="720px" height="720px" viewBox="0 0 720 720"><defs><mask id="cut"><rect fill="#FFF" x="0" y="0" width="720" height="720"/><ellipse fill="#000" cx="870" cy="370" rx="300" ry="400"/></mask></defs><ellipse fill="#8af" cx="700" cy="420" rx="450" ry="280" mask="url(#cut)"/><ellipse fill="#8af" cx="360" cy="310" rx="340" ry="280"/></svg>');
	Bawl.svgBawlIcon = '<img style="height:1em" src="' + Bawl.svgBawlIconData + '">';
	Bawl.svgBawlIconNewSectionData = 'data:image/svg+xml,' + encodeURIComponent('<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="1080px" height="720px" viewBox="0 0 1080 720"><defs><mask id="cut"><rect fill="#FFF" x="0" y="0" width="720" height="720"/><ellipse fill="#000" cx="870" cy="370" rx="300" ry="400"/></mask></defs><ellipse fill="#8af" cx="700" cy="420" rx="450" ry="280" mask="url(#cut)"/><ellipse fill="#8af" cx="360" cy="310" rx="340" ry="280"/><rect fill="#000" x="820" y="0" width="60" height="320"/><rect fill="#000" x="680" y="130" width="320" height="60"/></svg>');
	Bawl.svgBawlIconNewSection = '<img style="height:1em" src="' + Bawl.svgBawlIconNewSectionData + '">';
	Bawl.svgBawlIconEditData = 'data:image/svg+xml,' + encodeURIComponent('<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="720px" height="720px" viewBox="0 0 720 720"><g transform="rotate(40)"><g transform="translate(530 200) scale(1 1.5) rotate(45)"><rect fill="#8bf" x="0" y="0" width="127" height="127"/></g><rect fill="#8af" x="440" y="-365" width="180" height="700"/><rect fill="#79e" x="460" y="-230" width="40" height="520"/><rect fill="#67e" x="440" y="-365" width="180" height="100"/></g></svg>');
	Bawl.svgBawlIconEdit = '<img style="height:1em" src="' + Bawl.svgBawlIconEditData + '">';
	Bawl.tosNagContainer = document.createElement('div');
	Bawl.tosNagContainer.id = 'BawltosNagContainer';
	if ( mw.config.get('wgServer').match(/beta\.wmflabs/) ) { Bawl.metawikiAPI = 'https://meta.wikimedia.beta.wmflabs.org/enwiki/w/api.php' } else { Bawl.metawikiAPI = 'https://meta.wikimedia.org/enwiki/w/api.php' }
	Bawl.dbg = function(errortext) {
		if ( Bawl.settings.debug == true ) {
			if ( typeof errortext == "string" || typeof errortext == "number" ) {
				console.log('Bawl: ' + errortext);
			} else {
				console.log(errortext);
			}
		}
	};
	Bawl.loadSettings = function() {
		if ( window.BawlGlobalPrefs ) { //first try to load preferences from global.js
			Bawl.dbg('settings loaded from global.js');
		}
		if ( window.BawlPrefs ) {	//no matter if we got any, overwrite with settings from common.js if there are any
			Bawl.dbg('settings loaded from common.js');
		}
		if ( window.localStorage.Bawl && window.localStorage.Bawl.match(/^\{/) ) { //and finally overwrite with the settings from a cookie if present
			Bawl.dbg('load settings from localStorage');
			Bawl.browserSettings = JSON.parse(window.localStorage.Bawl);
			Bawl.settings = Object.assign(Bawl.settings, Bawl.browserSettings);
		} else if ( window.BawlPrefs && typeof window.BawlPrefs == 'object' ) {
			Bawl.settings = Object.assign(Bawl.settings, window.BawlPrefs);
		} else if ( window.BawlGlobalPrefs && typeof window.BawlGlobalPrefs == 'object' ) {
			Bawl.settings = Object.assign(Bawl.settings, window.BawlGlobalPrefs);
		}
	};
	Bawl.loadSettings();
	if ( Bawl.wikiTimezone ) { //timezone was in wikiconfig above
		Bawl.wikiTimezone = Bawl.wikiTimezone;
	} else if ( typeof BawlTZ == 'string' ) { //timezone specified in common.js or something. allows overriding localStorage, useful if a wiki changes timezone
		Bawl.wikiTimezone = BawlTZ;
	} else if ( window.localStorage.BawlTZ ) {
		Bawl.wikiTimezone = window.localStorage.BawlTZ;
		Bawl.settings.wikiTZ = window.localStorage.BawlTZ;
	} else if ( Bawl.settings.wikiTZ ) {
		Bawl.wikiTimezone = Bawl.settings.wikiTZ;
	} else {
		var api = new mw.Api();
		api.get( {
			format: 'json', action: 'query', meta: 'siteinfo', siprop: 'general'
		} ).done( function ( data ) {
			window.localStorage.setItem('BawlTZ', data.query.general.timezone);
			Bawl.settings.wikiTZ = data.query.general.timezone;
			Bawl.wikiTimezone = data.query.general.timezone;
		} );
	}
	Bawl.reloadForm = function() {
		Bawl.loadSettings();
		Bawl.cancelReply(); //clear form entirely
		Bawl.openReplyForm(Bawl.replyLinkParamsOpened); //force reloading everything
		window.BawlUITextInput.scrollIntoView();
	};
	Bawl.disableForm = function(setdisableform) {
		Bawl.UITextInputTitle.setReadOnly(setdisableform);
		Bawl.UITextInput.setReadOnly(setdisableform);
		Bawl.UIReplyButton.setDisabled(setdisableform);
		Bawl.UIPreviewButton.setDisabled(setdisableform);
		Bawl.UICancelButton.setDisabled(setdisableform);
		Bawl.UISettingsButton.setDisabled(setdisableform);
		if ( Bawl.saveSettingsButton ) {
			Bawl.saveSettingsButton.setDisabled(setdisableform);
			Bawl.resetPreferencesButton.setDisabled(setdisableform);
			Bawl.cancelSettingsButton.setDisabled(setdisableform);
		}
	};
	Bawl.getWikitextFromExport = function(text) {
		if ( text.match(/[^]*<text bytes[^>]*>([^]*)<\/text>[^]*/) ) {
			return text.replace(/[^]*<text bytes[^>]*>([^]*)<\/text>[^]*/, '$1').replace(/\&lt\;/g, '<').replace(/\&gt\;/g, '>').replace(/\&amp\;/g, '&');
		} else {
			return '';
		}
	};
	Bawl.extractUsernames = function(text) {
		Bawl.extractUsernamesPingTextRegExp = new RegExp('(' + Bawl.escapeRegExp(Bawl.pingText).replace('USERNAME', '([^\\]\\}]*)') + '|\\[\\[User:[^\\|\\]]*|\\[\\[' + mw.config.get('wgFormattedNamespaces')[2] + ':[^\\|\\]]*|\{\{[Pp]ing\\|[^}]*|\{\{[Rr]eply to\\|[^}]*)', 'g');
		Bawl.extractedUsernames = text.match(Bawl.extractUsernamesPingTextRegExp);
		Bawl.extractedUsernamesClean = [];
		if ( Bawl.extractedUsernames ) {
			for (int = 0; int < Bawl.extractedUsernames.length; int++) {
				Bawl.cleanUserPing = new RegExp('(\\[\\[:?[Uu]ser:|\\[\\[:?' + mw.config.get('wgFormattedNamespaces')[2] + ':|\{\{[Pp]ing\\||\{\{[Rr]eply to\\||\\|\\]\\])', 'g');
				Bawl.extractedUsernamesClean[int] = Bawl.extractedUsernames[int].replace(Bawl.cleanUserPing, '');
			}
		}
	return Bawl.extractedUsernamesClean;
	}
	Bawl.changePreferences = function(params, actionToPerform) {
		if ( params.title == 'User:' + mw.config.get('wgUserName') + '/global.js' ) {
			Bawl.dbg('selecting mw.ForeignApi for ' + params.title + ' on metawiki');
			var apiMeta = new mw.ForeignApi( Bawl.metawikiAPI );
			api = apiMeta;
			Bawl.prefsVarName = 'window.BawlGlobalPrefs';
		} else {
			var api = new mw.Api();
			Bawl.prefsVarName = 'window.BawlPrefs';
			Bawl.dbg('selecting mw.Api for ' + params.title + ' on this wiki');
		}
		api.get( {
			action: 'query', export: 'true', format: 'json', titles: params.title,
		} ).done( function ( data ) {
			Bawl.dbg(data);
			Bawl.newSettingsCommonJS = Bawl.prefsVarName + ' = ' + Bawl.encodedPrefs + '; //Preferences for [[w:en:User:Alexis Jazz/Bawl]]';
			if ( data.query.export["*"].match(/[^]*<text bytes[^>]*>([^]*)<\/text>[^]*/) ) {
				Bawl.commonJSwikitext = Bawl.getWikitextFromExport(data.query.export["*"]);
				Bawl.commonJSwikitextRegExp = new RegExp('^' + Bawl.escapeRegExp(Bawl.prefsVarName) + '.*(\n?)', 'm');
				if ( actionToPerform == 'delete' ) {
					Bawl.newCommonJSwikitext = Bawl.commonJSwikitext.replace(Bawl.commonJSwikitextRegExp, '');
					Bawl.dbg('removing ' + Bawl.prefsVarName + ' from ' + params.title );
				} else if ( Bawl.commonJSwikitext.match(Bawl.commonJSwikitextRegExp) ) {
					Bawl.newCommonJSwikitext = Bawl.commonJSwikitext.replace(Bawl.commonJSwikitextRegExp, Bawl.newSettingsCommonJS + '$1');
					Bawl.dbg('updating existing ' + Bawl.prefsVarName + ' in ' + params.title);
				} else if ( Bawl.commonJSwikitext.match(/.*Bawl\.js.*/) ) {
					Bawl.newCommonJSwikitext = Bawl.commonJSwikitext.replace(/(.*Bawl\.js.*)/, Bawl.newSettingsCommonJS + '\n$1');
					Bawl.dbg('prepending ' + Bawl.prefsVarName + ' before Bawl.js line in ' + params.title);
				} else {
					Bawl.newCommonJSwikitext = Bawl.commonJSwikitext + '\n' + Bawl.newSettingsCommonJS;
					Bawl.dbg('appending ' + Bawl.prefsVarName + ' to ' + params.title);
				}
			} else if ( data.query.export["*"] ) { //common.js no exist but we did get a response from our export request
				Bawl.dbg(Bawl.prefsVarName + ' no exist');
				Bawl.newCommonJSwikitext = Bawl.newSettingsCommonJS;
			}
			if ( typeof Bawl.newCommonJSwikitext == 'string' ) { //always true, but aditional error handling may be added later
				if ( actionToPerform	== 'delete' ) {
					Bawl.prefsSummary = Bawl.wikiMsgs.deletePrefsSummary;
				} else {
					Bawl.prefsSummary = Bawl.wikiMsgs.savePrefsSummary;
				}
				api.postWithEditToken( {
					format: 'json', title: params.title, action: 'edit', summary: Bawl.prefsSummary, text: Bawl.newCommonJSwikitext,
				} ).done( function ( data ) {
					Bawl.dbg( data );
					if ( data.edit && data.edit.result == 'Success' ) {
						if ( actionToPerform == 'delete' ) {
							Bawl.dbg('cleared prefences to ' + Bawl.prefsVarName + ' successfully');
						} else {
							Bawl.dbg('saved prefences to ' + Bawl.prefsVarName + ' successfully');
						}
						Bawl.reloadForm();
					}
				} );
			} //end Bawl.newCommonJSwikitext
		} ); //end data function
	};
	Bawl.saveSettings = function() {
		Bawl.disableForm(true); //disable buttons so you can't double click
		$(document.getElementById('saveSettingsButton')).addClass('BawlPendingBlink');
		Bawl.dbg('Saving settings..');
		Bawl.prefCount = Object.keys(Bawl.defaultSettings).length;
		for (prefint = 0; prefint < Bawl.prefCount; prefint++) {
			Bawl.processKey = Object.keys(Bawl.defaultSettings)[prefint];
			Bawl.dbg('process element for saving ' + (prefint + 1) + '/' + Bawl.prefCount + ': ' + Bawl.processKey);
			if ( Bawl.settingElement[ Bawl.processKey ] && typeof Bawl.settingElement[ Bawl.processKey ].isSelected == 'function' ) {
				Bawl.settings[ Bawl.processKey ] = Bawl.settingElement[ Bawl.processKey ].isSelected();
			} else if ( Bawl.settingElement[ Bawl.processKey ] && typeof Bawl.settingElement[ Bawl.processKey ].getValue == 'function' ) {
				Bawl.settings[ Bawl.processKey ] = Bawl.settingElement[ Bawl.processKey ].getValue();
			}
		}
		for (int = 0; int < 30; int++) {
			if ( Bawl.customInsertTextInput[int].getValue() != '' ) {
				Bawl.settings.cI[int] = Bawl.customInsertTextInput[int].getValue();
			} else {
				delete Bawl.settings.cI[int];
			}
			if ( Bawl.customInsertThatRunTextInput[int].getValue() != '' ) {
				Bawl.settings.cIThatRun[int] = Bawl.customInsertThatRunTextInput[int].getValue();
			} else {
				delete Bawl.settings.cIThatRun[int];
			}
		}
		if ( window.BawlGlobalPrefs ) { window.BawlGlobalPrefs = Bawl.settingsToSave } //refreshing this would otherwise require a page reload
		if ( window.BawlPrefs ) { window.BawlPrefs = Bawl.settingsToSave }
		Bawl.prefCount = Object.keys(Bawl.defaultSettings).length;
		Bawl.settingsToSave = $.extend( true, {}, Bawl.settings );
		Bawl.dbg('compacting preferences');
		for (prefint = 0; prefint < Bawl.prefCount; prefint++) { //compacting settings by removing values that match defaults
			Bawl.processKey = Object.keys(Bawl.defaultSettings)[prefint];
			Bawl.dbg('checking ' + prefint + '/' + Bawl.prefCount + ': ' + Bawl.processKey);
			if ( ( typeof Bawl.settingsToSave[Bawl.processKey] == "boolean" || typeof Bawl.settingsToSave[Bawl.processKey] == "string" ) && Bawl.settingsToSave[Bawl.processKey] == Bawl.defaultSettings[Bawl.processKey] ) {
				Bawl.dbg('removing ' + Bawl.processKey + ' from settings to save, same as default');
				delete Bawl.settingsToSave[Bawl.processKey];
			} else {
				Bawl.dbg(Bawl.processKey + ': ' + Bawl.settingsToSave[Bawl.processKey] + ' does not match ' + Bawl.defaultSettings[Bawl.processKey]);
			}
		}
		Bawl.dbg('finished compacting preferences');
		if ( Bawl.settings.saveTo == 'globaljs' ) { // timezone is project-specific and should never be saved to the global account
			delete Bawl.settingsToSave.wikiTZ;
		}
		Bawl.encodedPrefs = JSON.stringify(Bawl.settingsToSave); //store object as a base64 encoded JSON. encodeURIComponent because btoa only supports Latin1
		if ( Bawl.settings.saveTo == 'browser' ) {
			Bawl.dbg('saving settings to localStorage');
			window.localStorage.setItem('Bawl', Bawl.encodedPrefs)
			Bawl.reloadForm();
		} else if ( Bawl.settings.saveTo == 'commonjs' ) {
			Bawl.dbg('saving settings to common.js, getting current common.js');
			Bawl.resetPreferences('browser'); //removing localStorage so that won't override common.js
			Bawl.changePreferencesParams = { 'title':'User:' + mw.config.get('wgUserName') + '/common.js' };
			Bawl.changePreferences(Bawl.changePreferencesParams);
		} else if ( Bawl.settings.saveTo == 'globaljs' ) {
			Bawl.resetPreferences('browser'); //removing localStorage so that won't override global.js
			Bawl.resetPreferences('commonjs'); //removing settings from common.js so they won't override global.js
			Bawl.dbg('saving settings to global.js on metawiki, getting current global.js');
			Bawl.changePreferencesParams = { 'title':'User:' + mw.config.get('wgUserName') + '/global.js' }; // Bawl.changePreferences automatically switches to metawiki based on page title
			Bawl.changePreferences(Bawl.changePreferencesParams);
		} // end globaljs
	};
	Bawl.resetPreferences = function(preftype) {
		if ( ! preftype ) { // the reset/delete preferences button was pressed
			Bawl.disableForm(true);
			$(document.getElementById('resetPreferencesButton')).addClass('BawlPendingBlink');
		}
		if ( (preftype && preftype == 'browser') || ( ! preftype && Bawl.settingElement.saveTo.getValue() == 'browser' )) {
			localStorage.removeItem('Bawl');
			Bawl.dbg('bye localStorage item');
			if ( ! preftype ) {
				Bawl.reloadForm();
			}
		} else if ( (preftype && preftype == 'commonjs') || ( ! preftype && Bawl.settingElement.saveTo.getValue() == 'commonjs' )) {
			Bawl.dbg('removing settings from common.js');
			Bawl.changePreferencesParams = { 'title':'User:' + mw.config.get('wgUserName') + '/common.js' };
			Bawl.changePreferences(Bawl.changePreferencesParams, 'delete');
		} else if ( (preftype && preftype == 'globaljs') || ( ! preftype && Bawl.settingElement.saveTo.getValue() == 'globaljs' )) {
			Bawl.dbg('removing settings from global.js');
			Bawl.changePreferencesParams = { 'title':'User:' + mw.config.get('wgUserName') + '/global.js' };
			Bawl.changePreferences(Bawl.changePreferencesParams, 'delete');
		}
	};
	Bawl.addScrewedLink = function(errorDescription) {
		$('#BawlReplyForm').prepend('<b>Looks like Alexis Jazz screwed up. (' + errorDescription + ') <a href="https://en.wikipedia.org/enwiki/w/index.php?title=User_talk:Alexis_Jazz/Bawl&action=edit&section=new&preloadtitle=You%20messed%20up!%20(' + encodeURIComponent(errorDescription) + ')&preload=User_talk:Alexis%20Jazz/Bawl/preload">Go bawl at \'em here.</a><br/>');
	};
	Bawl.toggleTosNag = function() {
		if ( ! document.getElementById('BawlToSNag') && Bawl.settingElement.tosNag.isSelected() ) {
			$('#BawltosNagContainer').append(Bawl.msgs.tosNagText);
		} else if ( Bawl.settingElement.tosNag.isSelected() == true ) {
			$('#BawlToSNag').removeClass('BawlNoDisplay');
		} else if ( Bawl.settingElement.tosNag.isSelected() == false ){
			$('#BawlToSNag').addClass('BawlNoDisplay');
		}
	};
	Bawl.fastCSSTrans = '0.1s';
	Bawl.slowCSSTrans = '4.0s';
	mw.util.addCSS('.BawlReplyButton { font-size:0.5em; font }\
	.BawlReplyLink:hover { text-decoration:none;background-color:#EEEEFF; }\
	.BawlReplyLink:active { text-decoration:none;background-color:#EEEEFF; }\
	.BawlReplyLinkIcon { margin-left:0.6em; margin-right:0.6em}\
	.BawlNoDisplay { display:none !important }\
	.BawlYesDisplay { display:inline !important }\
	.BawlMarginHalfEm { margin-bottom: 0.5em; }\
	.BawlMarginHalfEmTop { margin-top:0.5em; }\
	.BawlPreviewBox { background:#FAFAFA;padding:0.1em 1em 0.1em 1em;border:thin dashed gray; }\
	.BawlFloatRight { float:right; }\
	.BawlForm { padding:0.5em 0.5em 0em 0.5em;margin:0em 0em 0em 1.5em;font-size:' + Bawl.settings.UIfontSize + ';font-family:sans-serif; font-weight:normal }\
	.BawlLimitWidth { max-width:50em; }\
	.BawlUnsetLimitWidth { max-width:unset !important; }\
	.BawlSettings { background:#FEFEFF;padding:0.1em 0.5em 0.1em 0.5em;border:thin solid lightgray; }\
	.BawlDropDownMenu { max-width:30em; }\
	.BawlOOuiFieldLayout { margin-top:0.5em !important; margin-bottom:0.75em; }\
	.BawlOOuiFieldLayout::after { clear:none; }\
	.BawlStatusTransred { background:#FFBBBB; transition: all	' + Bawl.fastCSSTrans + '	ease-in; -o-transition: all	' + Bawl.fastCSSTrans + '	ease-in; -webkit-transition: all	' + Bawl.fastCSSTrans + '	ease-in; }\
	.BawlStatusTransgreen { background:#BBFFBB; transition: all	' + Bawl.fastCSSTrans + '	ease-in; -o-transition: all	' + Bawl.fastCSSTrans + '	ease-in; -webkit-transition: all	' + Bawl.fastCSSTrans + '	ease-in; }\
	.BawlStatusTransblue { background:#BBBBFF; transition: all	' + Bawl.fastCSSTrans + '	ease-in; -o-transition: all	' + Bawl.fastCSSTrans + '	ease-in; -webkit-transition: all	' + Bawl.fastCSSTrans + '	ease-in; }\
	.BawlStatusTranscyan { background:#BBFFFF; transition: all	' + Bawl.fastCSSTrans + '	ease-in; -o-transition: all	' + Bawl.fastCSSTrans + '	ease-in; -webkit-transition: all	' + Bawl.fastCSSTrans + '	ease-in; }\
	.BawlStatusTranspurple { background:#FFBBFF; transition: all	' + Bawl.fastCSSTrans + '	ease-in; -o-transition: all	' + Bawl.fastCSSTrans + '	ease-in; -webkit-transition: all	' + Bawl.fastCSSTrans + '	ease-in; }\
	.BawlStatusTransyellow { background:#FFFFBB; transition: all	' + Bawl.fastCSSTrans + '	ease-in; -o-transition: all	' + Bawl.fastCSSTrans + '	ease-in; -webkit-transition: all	' + Bawl.fastCSSTrans + '	ease-in; }\
	.BawlStatusTranswhiteSlow { background:#FFFFFF; transition: all ' + Bawl.slowCSSTrans + ' ease-in; -o-transition: all ' + Bawl.slowCSSTrans + ' ease-in; -webkit-transition: all ' + Bawl.slowCSSTrans + ' ease-in; }\
	.BawlShakeIt { animation: shake 0.12s; animation-iteration-count: 3;} @keyframes shake { 0% { margin:-0.1em 0em 0.6em 0em; } 9% { margin:-0.2em 0em 0.7em 0em; } 18% { margin:-0.3em 0em 0.8em 0em; } 27% { margin:-0.2em 0em 0.7em 0em; } 36% { margin:-0.1em 0em 0.6em 0em; } 45% { margin:0em 0em 0.5em 0em; } 54% { margin:0.1em 0em 0.4em 0em; } 63% { margin:0.2em 0em 0.3em 0em; } 72% { margin:0.3em 0em 0.2em 0em; } 81% { margin:0.2em 0em 0.3em 0em; } 90% { margin:0.1em 0em 0.4em 0em; } 100% { margin:0em 0em 0.5em 0em; } }\
	.BawlSmallerText { font-size: 70%; }\
	.BawlSettingsSectionLabel { font-size: bigger; font-weight: bold; }\
	.BawlEditNoticeDiv { max-height:12em; overflow:auto; }\
	@keyframes BawlBlinker { 50% { opacity: 0.5; } }\
	.BawlPendingBlink { animation: BawlBlinker 1s linear infinite; }\
	.BawlLeftRightMargin { margin-left: 0.5em; margin-right: 0.5em; }\
	.BawlMarkupBold { font-weight: bold; }\
	.BawlMarkupItalic { font-weight: normal; font-style: italic; }\
	.BawlPreviewAfterPost { margin-left: 0.5em; font-family:sans-serif; font-weight: normal; font-size: medium;}\
	.BawlAnonSectReply { font-size:medium;font-weight:normal;line-height:1.3;text-align:center;border:thin solid #ccc;padding:0.2em 3em 0.2em 3em;background:aliceblue; }\
	.BawlNoMaxWidth { max-width:none; }');
	Bawl.replyLink = {};
	Bawl.formDataset = {};
	Bawl.pageRevisionSinceLastCheck = {};
	Bawl.apiUrl = mw.util.wikiScript( 'api' );
	Bawl.doAPICall = function( params, situation, callback ) {
		var api = new mw.Api();
		api.postWithEditToken( params ).done( function ( apiResponse ) {
				if (params.action == 'parse' && situation == 'previewposted' ) {
					Bawl.dbg('Got parsed comment:' + apiResponse.parse.text);
					if ( ! Bawl.PreviewAfterPostID ) {
						Bawl.PreviewAfterPostID = '';
					}
					if ( document.getElementById(Bawl.PreviousPreviewAfterPostID) ) { // This code is no longer reachable because type=edit will always reload (or link), never parse. Technically updates to comments that were just posted could be parsed in-place, but replacing individual comments in-place wouldn't work outside of that because MediaWiki doesn't wrap individual comments in their own container, well not in a practical way anyway.
						Bawl.dbg('replacing existing parsed comment');
						document.getElementById(Bawl.PreviousPreviewAfterPostID).outerHTML = '<div class="BawlPreviewAfterPost" id="' + Bawl.PreviousPreviewAfterPostID + '">' + apiResponse.parse.text.replace(/(<\/span>)(\n<\/p>\n<!-- \nNewPP)/m, '$1<span id="Bawlpreviewlinks"><a href="' + Bawl.newCommentID + '" class="BawlReplyLink">&nbsp;&#x1F517;&nbsp;</a></div>$2') + '</span></div>';
					} else { // this is reachable though
						Bawl.postedCommentParsed = apiResponse.parse.text;
					}
					if ( Bawl.postCommentSuccess == true ) { //if the parsing takes longer than the actual posting (unlikely) we'll insert it here. otherwise below
						Bawl.dbg('preview parsing took longer than editing (this is rare), insert parsed preview with HTML element ID ' + Bawl.PreviewAfterPostID);
						$('#thanksForUsing')[0].outerHTML = '<div class="BawlPreviewAfterPost" id="' + Bawl.PreviewAfterPostID + '">' + Bawl.postedCommentParsed.replace(/(<\/span>)(\n<\/p>\n<!-- \nNewPP)/m, '$1<span id="Bawlpreviewlinks"><a href="' + Bawl.newCommentID + '" class="BawlReplyLink">&nbsp;&#x1F517;&nbsp;</a></div>$2') + '</span></div>';
						Bawl.dbg('add edit link to posted comment with ID ' + Bawl.previewPostedParams.id);
						Bawl.addReplyLinkTo(Bawl.previewPostedParams); //adds edit link
					}
				} else if (params.action == 'parse' && situation == 'preview' ) {
					Bawl.dbg('Loading preview');
					$(document.getElementsByClassName('BawlPreviewBox'))[0].innerHTML = apiResponse.parse.text;
				} else if (params.action == 'parse' && situation == 'editnotice' ) {
					Bawl.dbg('Loading editnotice');
					$('#BawlEditNotice').append(apiResponse.parse.text);
				} else if ( ( apiResponse.error && apiResponse.error.code == 'editconflict' ) || ( apiResponse.edit.result == 'Success' && ! apiResponse.edit.newtimestamp ) ) { //that nonsense second condition is a workaround for https://phabricator.wikimedia.org/T299809
						Bawl.trySectionEdit = false; //do not try section editing on the next try
						Bawl.editConflictRetries = Bawl.editConflictRetries - 1;
						if ( apiResponse.edit.result == 'Success' && ! apiResponse.edit.newtimestamp && Bawl.editConflictRetries > 0 ) { //damage control in case there is a legit situation that triggers this
							Bawl.editConflictRetries = 1;
						}
						Bawl.dbg('encountered edit conflict. ' + Bawl.editConflictRetries + ' tries left.');
						if ( Bawl.editConflictRetries >= 1 ) {
							Bawl.postReply1(Bawl.replyLinkParamsOpened);
						} else {
							Bawl.dbg('giving up');
						}
				} else if (params.action == 'edit' && apiResponse.edit.result == 'Success' ) { //edit made successfully
					Bawl.postedCommentType = encodeURIComponent(Bawl.replyLinkParamsOpened.type.replace(/ /g, '_'));
					if ( Bawl.replyLinkParamsOpened.subtype ) {
						Bawl.postedCommentSubType = encodeURIComponent(Bawl.replyLinkParamsOpened.subtype.replace(/ /g, '_'));
					} else {
						delete Bawl.postedCommentSubType;
					}
					Bawl.repliedToCommentID = Bawl.replyLinkParamsOpened.id;
					if ( Bawl.postedCommentType == 'comment' || Bawl.postedCommentSubType == 'BCL' ) {
						Bawl.newCommentTimestamp = apiResponse.edit.newtimestamp.replace(/([0-9\-T\:]{17})[0-9][0-9]/, '$100.000');
						Bawl.newCommentID = '#c-' + encodeURIComponent(mw.config.get('wgUserName').replace(/ /g, '_')) + '-' + encodeURIComponent(apiResponse.edit.newtimestamp.replace(/([0-9\-T\:]{17})[0-9][0-9]/, '$100.000')) + '-' + encodeURIComponent(Bawl.replyLinkParamsOpened.origReplyTo.replace(/ /g, '_')) + '-' + encodeURIComponent(Bawl.replyLinkParamsOpened.origTimestamp);
						Bawl.thankYouType = Bawl.msgs.commentPosted;
					} else if ( Bawl.postedCommentType == 'heading' ) { //likely wrong
						Bawl.newCommentID = '#c-' + encodeURIComponent(mw.config.get('wgUserName').replace(/ /g, '_')) + '-' + encodeURIComponent(apiResponse.edit.newtimestamp.replace(/([0-9\-T\:]{17})[0-9][0-9]/, '$100.000')) + '-' + encodeURIComponent(Bawl.UITextInputTitle.getValue().replace(/ /g, '_'));
						Bawl.thankYouType = Bawl.msgs.sectionAdded;
					} else if ( Bawl.postedCommentType == 'newsection' ) {
						Bawl.newCommentID = '#' + encodeURIComponent(Bawl.UITextInputTitle.getValue().replace(/ /g, '_'));
						Bawl.thankYouType = Bawl.msgs.sectionAdded;
					} else if ( Bawl.postedCommentType == 'edit' && typeof Bawl.replyLinkParamsOpened.origid == 'undefined' ) {
						Bawl.newCommentID = '#' + encodeURIComponent(Bawl.replyLinkParamsOpened.id);
						Bawl.thankYouType = Bawl.msgs.commentEdited;
					}
					Bawl.cancelReply(); //closes the reply form
					document.getElementById('bawlForm-' + Bawl.repliedToCommentID).outerHTML = document.getElementById('bawlForm-' + Bawl.repliedToCommentID).outerHTML + '<span id="thanksForUsing"><a href="?' + Math.floor(Math.random()*100000) + Bawl.newCommentID + '">' + Bawl.thankYouType + '</a>' + Bawl.msgs.commentPostedThankYou + '</span>'; // the ? forces page reload, # provides anchor to the comment that was commented on
					if ( Bawl.settings.afterPost == 'reload' || ( Bawl.replyLinkParamsOpened.type != 'comment' && Bawl.settings.afterPost != 'link' ) ) {
							window.location = Bawl.newCommentID;
						var DelayedReload = setInterval(function () {
							clearInterval(DelayedReload); location.reload(); //if we reload immediately we may not get served the most recent revision with our comment
						}, 2000);
					} else if ( Bawl.settings.afterPost == 'parsecomment' ) {
						Bawl.replyLinkParamsOpenedPreview = Bawl.replyLinkParamsOpened;
						Bawl.previewPostedParams = {
							'preview': true,
							'int': Bawl.replyLinkParamsOpenedPreview.int,
							'type':'edit',
							'id': Bawl.newCommentID.slice(1,),
							'origid': Bawl.replyLinkParamsOpened.id,
							'pageTitle': Bawl.pageTitleToEdit,
							'origReplyTo': mw.config.get('wgUserName'),
							'origTimestamp': Bawl.newCommentTimestamp,
							'sectionTitle': Bawl.replyLinkParamsOpenedPreview.sectionTitle,
							'origLevel': Bawl.replyLinkParamsOpenedPreview.origLevel + 1,
							'origReplyTo2': Bawl.replyLinkParamsOpenedPreview.origReplyTo,
							'origTimestamp2': Bawl.replyLinkParamsOpenedPreview.origTimestamp2,
							'headingLevel': Bawl.replyLinkParamsOpenedPreview.headingLevel
						};
						Bawl.PreviewAfterPostID = 'BawlPreviewAfterPost-' + Bawl.previewPostedParams.id.replace(/%/g, '');
						Bawl.postCommentSuccess = true;
						if ( Bawl.postedCommentParsed ) { //comment preview has already been parsed
							Bawl.dbg('editing took longer than preview parsing (this is common), insert parsed preview with HTML element ID ' + Bawl.PreviewAfterPostID);
							$('#thanksForUsing')[0].outerHTML = '<div class="BawlPreviewAfterPost" id="' + Bawl.PreviewAfterPostID + '">' + Bawl.postedCommentParsed.replace(/(<\/span>)(\n<\/p>\n<!-- \nNewPP)/m, '$1<span id="Bawlpreviewlinks"><a href="' + Bawl.newCommentID + '" class="BawlReplyLink">&nbsp;&#x1F517;&nbsp;</a></div>$2') + '</span></div>';
							Bawl.dbg('add edit link to posted comment with ID ' + Bawl.previewPostedParams.id);
							Bawl.addReplyLinkTo(Bawl.previewPostedParams); //adds edit link
						}
					}
					Bawl.UITextInput.setValue('');
					Bawl.UITextInputTitle.setValue('');
				}
		} );
	};
	Bawl.escapeRegExp = function(text) {
		return mw.util.escapeRegExp(text);
	}
	Bawl.escapeReplacement = function(text) {
		return text.replace(/\$/g, '$$$$');
	}
	Bawl.escapeHTML = function(text) {
		return text.replace(/\&/g, '&amp;').replace(/\'/g, '&apos;').replace(/\"/g, '&quot;').replace(/\</g, '&lt;').replace(/\>/g, '&gt;');
	}
	Bawl.rewritunUrUrlz = function(text) {
		Bawl.dbg('rewritun ur urlz');
		Bawl.rewritunUrUrlz2=text;
		Bawl.dbg('rewritun externalLinkRegExp');
		Bawl.rewritunRegExps = {
			'phabpage':'/https\\:\\/\\/phabricator\.wikimedia\.org\\/(([^\\n\\.\\,\\?\\& ]|[\\.\\,\\?\\&][^$ \\n])*)/[[:phab:$1]]/g',
			'page':'/https\\:\\/\\/([a-z\-]{0,10})(\.m)?\.(wikipedia|wikimedia|mediawiki|wikidata|wikibooks|wiktionary|wikinews|wikiquote|wikisource|wikiversity|wikivoyage)\.org\\/wiki\\/(([^\\n\\.\\,\\?\\& ]|[\\.\\,\\?\\&][^$ \\n])*)/[[INTERWIKI:$1.$3:$4]]/g',
			'diff':'/https\\:\\/\\/([a-z\-]{0,10})(\.m)?\.(wikipedia|wikimedia|mediawiki|wikidata|wikibooks|wiktionary|wikinews|wikiquote|wikisource|wikiversity|wikivoyage)\.org\\/w\\/index\.php\\?(title\=(([^\\n\\.\\,\\?\\& ]|[\\.\\,\\?\\&][^$ \\n])*)\\&)?diff\=([0-9]+)\\&oldid\=[0-9]*/[[INTERWIKI:$1.$3:Special:DiffSLASHCHAR$7|$5' + Bawl.wikiMsgs.difflinkname + ']]/g',
			'diffprevnext':'/https\\:\\/\\/([a-z\-]{0,10})(\.m)?\.(wikipedia|wikimedia|mediawiki|wikidata|wikibooks|wiktionary|wikinews|wikiquote|wikisource|wikiversity|wikivoyage)\.org\\/w\\/index\.php\\?(title\=(([^\\n\\.\\,\\?\\& ]|[\\.\\,\\?\\&][^$ \\n])*)\\&)?diff\=(next|prev)\\&oldid\=([0-9]*)/[[INTERWIKI:$1.$3:Special:DiffSLASHCHAR$8SLASHCHAR$7|$5' + Bawl.wikiMsgs.difflinknameprevnext + ']]/g',
			'spaceremoval':'/(Special\:Diff.[0-9]*)(\\/)?(prev|next)?. /$1$2$3|/g',
			'redlink':'/https\\:\\/\\/([a-z\-]{0,10})(\.m)?\.(wikipedia|wikimedia|mediawiki|wikidata|wikibooks|wiktionary|wikinews|wikiquote|wikisource|wikiversity|wikivoyage)\.org\\/w\\/index\\.php\\?title=([^\\&]*)\\&action=edit\\&redlink=1/[[INTERWIKI:$1.$3:$4]]/g',
			'history':'/https\\:\\/\\/([a-z\-]{0,10})(\.m)?\.(wikipedia|wikimedia|mediawiki|wikidata|wikibooks|wiktionary|wikinews|wikiquote|wikisource|wikiversity|wikivoyage)\.org\\/w\\/index\\.php\\?title=([^\\&]*)\\&action=history/[[INTERWIKI:$1.$3:Special:PageHistorySLASHCHAR$4|' + Bawl.wikiMsgs.pageHistoryLinkName + ']]/g',
			'localwiki':'/\\[\\[INTERWIKI:' + Bawl.escapeRegExp(mw.config.get('wgServer').replace(/\/\/([^\/]*)\.org.*/, '$1')) + '/[[/g',
			'testwiki':'/\\[\\[INTERWIKI:test\\.wikipedia/[[:testwiki/g',
			'commons':'/\\[\\[INTERWIKI:commons\\.wikimedia/[[:c/g',
			'meta':'/\\[\\[INTERWIKI:meta\\.wikimedia/[[:m/g',
			'mediawiki':'/\\[\\[INTERWIKI:www\\.mediawiki/[[:mw/g',
			'foundation':'/\\[\\[INTERWIKI:foundation\\.wikimedia/[[:foundation/g',
			'species':'/\\[\\[INTERWIKI:species\\.wikimedia/[[:species/g',
			'wikidata':'/\\[\\[INTERWIKI:wikidata\\.wikimedia/[[:d/g',
			'wikipedia':'/\\[\\[INTERWIKI:([a-z\-]{0,10})\\.wikipedia/[[:w:$1/g',
			'wikibooks':'/\\[\\[INTERWIKI:([a-z\-]{0,10})\\.wikibooks/[[:b:$1/g',
			'wiktionary':'/\\[\\[INTERWIKI:([a-z\-]{0,10})\\.wiktionary/[[:wikt:$1/g',
			'wikinews':'/\\[\\[INTERWIKI:([a-z\-]{0,10})\\.wikinews/[[:n:$1/g',
			'wikiquote':'/\\[\\[INTERWIKI:([a-z\-]{0,10})\\.wikiquote/[[:q:$1/g',
			'wikisource':'/\\[\\[INTERWIKI:([a-z\-]{0,10})\\.wikisource/[[:s:$1/g',
			'wikiversity':'/\\[\\[INTERWIKI:([a-z\-]{0,10})\\.wikiversity/[[:v:$1/g',
			'wikivoyage':'/\\[\\[INTERWIKI:([a-z\-]{0,10})\\.wikivoyage/[[:voy:$1/g',
		}
		for (int = 0; int < Object.keys(Bawl.rewritunRegExps).length; int++) {
			Bawl.rewritunReg = Bawl.rewritunRegExps[Object.keys(Bawl.rewritunRegExps)[int]].replace(/^\/(.*[^\\])\/(.*[^\\])\/(.*[^\\])/, '$1');
			Bawl.rewritunFlags = Bawl.rewritunRegExps[Object.keys(Bawl.rewritunRegExps)[int]].replace(/^\/(.*[^\\])\/(.*[^\\])\/(.*[^\\])/, '$3');
			Bawl.rewritunReplacement = Bawl.rewritunRegExps[Object.keys(Bawl.rewritunRegExps)[int]].replace(/^\/(.*[^\\])\/(.*[^\\])\/(.*[^\\])/, '$2');
			Bawl.dbg('Expression #' + int + ': ' + Bawl.rewritunReg + ', flags: ' + Bawl.rewritunFlags + ', replacement: ' + Bawl.rewritunReplacement);
			Bawl.rewritunRegExp = new RegExp(Bawl.rewritunReg, Bawl.rewritunFlags);
			Bawl.rewritunUrUrlz2 = Bawl.rewritunUrUrlz2.replace(Bawl.rewritunRegExp, Bawl.rewritunReplacement).replace(/SLASHCHAR/g, '/');
		}
		Bawl.rewritunMatchDiffs = Bawl.rewritunUrUrlz2.match(/Special:Diff\/([0-9]+)\|([^\]]*) \([^\)]*[0-9]+[^\)]*\)/g);
		if ( Bawl.rewritunMatchDiffs ) {
			for (int = 0; int < Bawl.rewritunMatchDiffs.length; int++) {
				Bawl.rewritunUrUrlz2 = Bawl.rewritunUrUrlz2.replace(Bawl.rewritunMatchDiffs[int], decodeURIComponent(Bawl.rewritunMatchDiffs[int].replace(/_/g, ' ')));
			}
		}
		Bawl.dbg('Rewritten urls: ' + Bawl.rewritunUrUrlz2);
		Bawl.dbg('rewritun youtu.be');
		Bawl.rewritunUrUrlz2 = Bawl.rewritunUrUrlz2.replace(/\/\/youtu\.be\/([^\?]*)\?\//g, '\/\/www.youtube.com\/watch\?$1&').replace(/\/\/youtu\.be\//g, '\/\/www.youtube.com\/watch\?'); //rewrite youtu.be shortened urls (these are blacklisted)
		Bawl.rewritunUrUrlz3 = Bawl.rewritunUrUrlz2;
		int=0;
		while ( ( Bawl.rewritunUrUrlz2 != Bawl.rewritunUrUrlz3 && int < 1000 ) || int == 0 ) {
			Bawl.rewritunUrUrlz2 = Bawl.rewritunUrUrlz3;
			Bawl.rewritunUrUrlz3 = Bawl.rewritunUrUrlz3.replace(/\[\[([^_\]]*)_(.*\]\])/g, '[[$1 $2'); //replace underscores in internal links with spaces
			int = int + 1;
			Bawl.dbg('rewritun #' + int + ' (' + Bawl.rewritunUrUrlz2 + ' to ' + Bawl.rewritunUrUrlz3 + ')' );
		}
		Bawl.rewritunUrUrlz4 = Bawl.rewritunUrUrlz3;
		Bawl.rewritunUrUrlz4RegExp = new RegExp('(\\[\\[[^\\]]*\\]\\])', 'g');
		Bawl.rewritunUrUrlz4match = Bawl.rewritunUrUrlz4.match(Bawl.rewritunUrUrlz4RegExp);
		if ( Bawl.rewritunUrUrlz4match ) {
			for (int = 0; int < Bawl.rewritunUrUrlz4match.length; int++) {
			Bawl.rewritunUrUrlz4 = Bawl.rewritunUrUrlz4.replace(Bawl.rewritunUrUrlz4match[int], decodeURIComponent(Bawl.rewritunUrUrlz4match[int]));
			}
		}
		Bawl.UITextInput.setValue(Bawl.rewritunUrUrlz4);
		return Bawl.rewritunUrUrlz4;
	};
	Bawl.applyMarkdown = function(text) {
		Bawl.dbg('Applying Markdown markup');
		return text.replace(/\*\*([^\*]*)\*\*/g, '\'\'\'$1\'\'\'').replace(/(^|\n| )_([^\_]*)_($|\n|[ \.\!\?])/g, '$1\'\'$2\'\'$3').replace(/`([^`]*)`/g, '<code>$1</code>').replace(/(^|\n)---($|\n)/, '$1<hr />$2');
		//todo: lists, links, images, maybe headers
	};
	Bawl.applyBBCode = function(text) {
		Bawl.dbg('applying BBCode');
		//list of wikis with a template:Smiley
		Bawl.wikiswithsmileytemplate = [ 'afwiki','alswiki','barwiki','dawiki','dewiki','enwiki','eswiki','fowiki','guwiki','jvwiki','kabwiki','kswiki','lijwiki','mywiki','nds_nlwiki','nlwiki','nowiki','orwiki','rowiki','scowiki','sdwiki','simplewiki','srwiki','svwiki','tawiki','thwiki','vecwiki','zhwiki' ,'enwikiversity' ,'dewikibooks','nlwikibooks','nowikibooks','enwikinews','eswikinews','enwikinews','nlwikinews','nowikinews','enwikiquote','nlwikiquote','enwikisource','guwikisource','enwikiversity','dewikivoyage','eswikivoyage','enwiktionary','eswiktionary','nlwiktionary','commonswiki','mediawikiwiki','metawiki','wikidatawiki' ];
		if ( Bawl.wikiswithsmileytemplate.indexOf(mw.config.get('wgDBname')) != -1 ) {
			text = text.replace(/(^| |\n)(:-\)|;-\)\|:-\()([^a-zA-Z0-9])/g, '$1{{Smiley|$2}}$3');
		}
		return text.replace(/\[\/?[Bb]\]/g, '\'\'\'').replace(/\[\/?[Ii]\]/g, '\'\'').replace(/\[(\/)?[Uu]\]/g, '<$1u>').replace(/\[(\/)?[Ss]\]/g, '<$1s>').replace(/\[url\](http)?(s?)(:\/\/)?([^\/\[]*)([^\[]*)\[\/url\]/gi, '[http$2://$4$5 ' + '$4' + ']').replace(/\[url="?(http)?(s?)(:\/\/)?([^\/\[]*)([^\[]*)"?\]([^\[]*)\[\/url\]/gi, '[http$2://$4$5 ' + '$6' + ']').replace(/\[img\]([^:\[]*:)?([^\[]*)\[\/img\]/g, '[[' + mw.config.get('wgFormattedNamespaces')[6] + ':$2|thumb]]').replace(/\[(\/)?[Cc]ode\]/g, '<$1code>').replace(/\[[Ss]tyle size="?([0-9]*)"?\]([^\[]*)\[\/(style)?\]/g, '<span style="font-size: $1pt">$2</span>').replace(/\[[Ss]tyle size="?([^"\]]*)"?\]([^\[]*)\[\/(style)?\]/g, '<span style="font-size: $1">$2</span>').replace(/\[([Ss]tyle )?color="?([0-9A-Fa-z]*)"?\]([^\[]*)\[\/(style|color)?\]/g, '<span style="color: $2">$3</span>').replace(/\[\*\] ?([^\n\[]*)\s*/gm, '<li>$1</li>').replace(/\[[Ll]ist\]\s*([^]*)\[\/[Ll]ist\]/gm, '<ul>$1</ul>').replace(/\s*<\/(ul|li)>/g, '</$1>').replace(/\[[Qq](uote)?\]([^\[]*)\[\/[Qq](uote)?\]/g, '<blockquote><p>$2</p></blockquote>').replace(/\[[Qq](uote)?=?"?([^"\]]*)"?\]([^\[]*)\[\/[Qq](uote)?\]/g, '<blockquote><p>$3</p>—$2</blockquote>').replace(/\s*\[(\/)?(td|tr)\]\s*/g, '<$1$2>').replace(/\[[Tt]able\]/g, '<table class="wikitable">').replace(/\[\/[Tt]able\]/g, '</table>');
	};
	Bawl.runCI = function(text) {
		Bawl.replacedInput = text;
		Bawl.dbg('start to process automatically applied custom inserts that are regular expressions');
		for (int = 0; int < 30; int++) {
			if ( Bawl.settings.cIThatRun && Bawl.settings.cIThatRun[int] && Bawl.settings.cIThatRun[int] != "" ) {	//non-empty insert found
				Bawl.dbg('process automatically applied custom inserts that are regular expressions ' + (int + 1) + '/30');
				Bawl.insertIsRegExpRegExp = new RegExp('^\/(.*)([^\])\/(.*)([^\])\/([gmi]*)$');
				if ( Bawl.settings.cIThatRun[int].match(Bawl.insertIsRegExpRegExp) && Bawl.settings.cIThatRun[int].match(Bawl.insertIsRegExpRegExp).length == 6 ) {
					Bawl.customInsertRegExpNowParts = Bawl.settings.cIThatRun[int].match(Bawl.insertIsRegExpRegExp);
					Bawl.customInsertRegExpNow = new RegExp(Bawl.customInsertRegExpNowParts[1] + Bawl.customInsertRegExpNowParts[2], Bawl.customInsertRegExpNowParts[5]);
					Bawl.replacedInput = Bawl.UITextInput.getValue().replace(Bawl.customInsertRegExpNow, Bawl.customInsertRegExpNowParts[3] + Bawl.customInsertRegExpNowParts[4]);
					Bawl.UITextInput.setValue(Bawl.replacedInput);
					Bawl.dbg('replaced ' + Bawl.customInsertRegExpNow + ' with ' + Bawl.customInsertRegExpNowParts[3] + Bawl.customInsertRegExpNowParts[4]);
				}
			}
		}
		return Bawl.replacedInput;
	};
	Bawl.convertToOneLineCmt = function(text) {
		Bawl.dbg('converting comment to a single line');
		Bawl.multilineText1 = ' \n \n' + text;
		Bawl.multilineText2 = '';
		Bawl.listInt = 0;
		while ( Bawl.multilineText1 != Bawl.multilineText2 && Bawl.listInt < 1000 ) {
			Bawl.listInt = Bawl.listInt + 1;
			Bawl.multilineText2 = Bawl.multilineText1;
			Bawl.multilineText1 = Bawl.multilineText1.replace(/(\n[^\#].*\n)(\#[ ]*)/g, '$1' + Bawl.listInt + '. ');
		}
		return Bawl.multilineText1.replace(/^[\s]*/, '').replace(/[\s]*$/, '').replace(/^[\*][\s]*/gm, '&bullet; ').replace( /\n/gm, Bawl.newLineTemplate );
	}
	Bawl.addSignature = function(text) {
		if ( text.match(/NOSIGN$/) ) { // comment signed with "NOSIGN"
			Bawl.dbg('found NOSIGN, skipping signature');
			return text;
		} else {
			Bawl.dbg('adding signature');
			if ( Bawl.settings.useLocator == true ) {
				Bawl.commentMilliseconds = new Date().getTime().toFixed().slice(-3,); //indeed, the local clock may differ from server time which we primarily rely on through {{subst:#time:U}}. And it's irrelevant as the milliseconds are only used to make the identifier more unique. Making two edits within the same second is already implausible but within the same millisecond? Get out. Doesn't solve the issue of non-Bawl users adding multiple comments in a single edit, but solving that would require MediaWiki to support "random" as a magic word that can produce different numbers when called multiple times within the same edit. Or have a bot that slightly adjusts timestamps to ensure they're unique.
				return text + ' ' + Bawl.endOfCommentLocator.replace(/INNERCONTENT/g, '~~~~').replace(/USERTIME/g, encodeURIComponent(mw.config.get('wgUserName')) + ':{{subst:#time:U}}' + Bawl.commentMilliseconds + ':' + encodeURIComponent(Bawl.replyLinkParamsOpened.pageTitle));
			} else {
				return text + ' ~~~~';
			}
		}
	};
	Bawl.progressPlusOne = function(reset) {
		$('#BawlProgressIndicator').append('▮'); //HTML: &#9646; BLACK VERTICAL RECTANGLE
	};
	Bawl.cancelReply = function() {
		document.getElementById('bawlForm-' + Bawl.replyLinkParamsOpened.id).innerHTML = '';
		document.getElementById('bawlForm-' + Bawl.replyLinkParamsOpened.id).classList = [ 'BawlNoDisplay BawlForm' ];
	};
	Bawl.doPreview = function(situation) {
		Bawl.dbg('preview');
		if ( situation != 'previewposted' ) {
			$(document.getElementsByClassName('BawlPreviewBox')).removeClass('BawlNoDisplay');
			if ( Bawl.settings.checkNewComments == true ) {
				Bawl.checkForNewComments(Bawl.replyLinkParamsOpened, 'preview');
			}
		}
		Bawl.processedCommentText = Bawl.UITextInput.getValue();
		if ( Bawl.settings.bbcode == true ) {
			Bawl.processedCommentText = Bawl.applyBBCode(Bawl.processedCommentText);
		}
		if ( Bawl.settings.markdown == true ) {
			Bawl.processedCommentText = Bawl.applyMarkdown(Bawl.processedCommentText);
		}
		if ( Bawl.settings.rewritun == true ) {
			Bawl.processedCommentText = Bawl.rewritunUrUrlz(Bawl.processedCommentText);
		} else {
			Bawl.processedCommentText = Bawl.UITextInput.getValue();
		}
		if ( Bawl.settings.enableCIThatRun == true ) {
			Bawl.dbg('applying your regular expressions');
			Bawl.processedCommentText = Bawl.runCI(Bawl.processedCommentText);
		}
		Bawl.processedCommentTextSigned = Bawl.addSignature(Bawl.processedCommentText);
		Bawl.processedCommentTextSignedOneLine = Bawl.convertToOneLineCmt(Bawl.processedCommentTextSigned);
		if ( situation == 'previewposted' ) {
			Bawl.dbg('add the last character from the indentation so preview renders properly with its indentation');
			Bawl.processedCommentTextSignedOneLine = Bawl.commentTextIndent.slice(-1,) + Bawl.processedCommentTextSignedOneLine;
		}
		Bawl.previewCommentParams = {
			format: 'json',
			action: 'parse',
			title: Bawl.replyLinkParamsOpened.pageTitle,
			pst: '1',
			prop: 'text',
			formatversion: '2',
			text: Bawl.processedCommentTextSignedOneLine + Bawl.repairTagImbalance(Bawl.processedCommentTextSignedOneLine)
		};
		Bawl.doAPICall(Bawl.previewCommentParams, situation);
	};
	Bawl.compareRevisionsToCheckForComments = function(replyLinkParams, situation) {
		Bawl.dbg('compare current revision to revision since last check');
			var api = new mw.Api();
			api.get( {
				action: 'query', prop: 'revisions', format: 'json', titles: replyLinkParams.pageTitle, rvlimit: 1, rvprop: 'timestamp|user|comment|content', rvslots: '*',
			} ).done( function ( data ) {
				Bawl.dbg('page content now:');
				Bawl.dbg(data);
				if ( data.query && data.query.pages && data.query.pages[ Object.keys(data.query.pages)[0] ] && data.query.pages[ Object.keys(data.query.pages)[0] ].revisions && data.query.pages[ Object.keys(data.query.pages)[0] ].revisions[0] ) {
					Bawl.pageRevisionCurrentText = data.query.pages[ Object.keys(data.query.pages)[0] ].revisions[0].slots.main['*'];
				} else {
					Bawl.pageRevisionCurrentText = '';
				}
				Bawl.pageRevisionSinceLastCheckText = Bawl.pageRevisionSinceLastCheck[replyLinkParams.pageTitle];
				if ( replyLinkParams.sectionnum ) {
					Bawl.pageRevisionCurrentText = Bawl.getSectionByNum(Bawl.pageRevisionCurrentText, replyLinkParams.sectionnum);
					Bawl.pageRevisionSinceLastCheckText = Bawl.getSectionByNum(Bawl.pageRevisionSinceLastCheck[replyLinkParams.pageTitle], replyLinkParams.sectionnum);
				}
				if ( Bawl.pageRevisionCurrentText != Bawl.pageRevisionSinceLastCheckText ){
					Bawl.pageRevisionCurrentSplit = Bawl.pageRevisionCurrentText.split('\n');
					Bawl.pageRevisionSinceLastCheckSplit = Bawl.pageRevisionSinceLastCheckText.split('\n');
					Bawl.linesSinceLastCheck = '';
					for (commentCheckInt = 0; commentCheckInt < Bawl.pageRevisionCurrentSplit.length; commentCheckInt++) {
						if ( Bawl.pageRevisionSinceLastCheckSplit.indexOf(Bawl.pageRevisionCurrentSplit[commentCheckInt]) == -1 ) {
							Bawl.dbg('line not found in the old revision of this page: ' + Bawl.pageRevisionCurrentSplit[commentCheckInt]);
							Bawl.linesSinceLastCheck = Bawl.linesSinceLastCheck + Bawl.pageRevisionCurrentSplit[commentCheckInt] + '\n';
						}
					}
					Bawl.showNewLinesButton = new OO.ui.ButtonWidget( {
						id: 'BawlshowNewLinesButton',
						label: Bawl.msgs.showNewLinesButton,
						flags: [ 'primary' ],
					} );
					Bawl.showNewLinesButton.on('click', function() {
						Bawl.showNewLinesButton.setDisabled(true);
						api.post( {
							action: 'parse', prop: 'revisions', format: 'json', title: mw.config.get('wgPageName'), pst: '1', prop: 'text', formatversion: '2', text: Bawl.linesSinceLastCheck
						} ).done( function ( data ) {
							Bawl.showNewLinesButton.setDisabled(false);
							$('#showNewLinesButton')[0].innerHTML = '';
							$('#BawlPreviewBox')[0].innerHTML = '';
							$('#BawlPreviewBox').removeClass('BawlNoDisplay');
							$('#BawlPreviewBox').append(data.parse.text);
						});
					});
					$('#showNewLinesButton').removeClass('BawlNoDisplay');
					$('#showNewLinesButton').innerHTML = '';
					$('#showNewLinesButton').append(Bawl.showNewLinesButton.$element);
				}
				if ( data.query && data.query.pages && data.query.pages[ Object.keys(data.query.pages)[0] ] && data.query.pages[ Object.keys(data.query.pages)[0] ].revisions && data.query.pages[ Object.keys(data.query.pages)[0] ].revisions[0] ) {
					Bawl.pageRevisionSinceLastCheck[replyLinkParams.pageTitle] = data.query.pages[ Object.keys(data.query.pages)[0] ].revisions[0].slots.main['*'];
				} else {
					Bawl.pageRevisionSinceLastCheck[replyLinkParams.pageTitle] = '';
				}
			});
	};
	Bawl.checkForNewComments = function(replyLinkParams, situation) {
		if ( Bawl.pageRevisionSinceLastCheck[replyLinkParams.pageTitle] ) {
			Bawl.compareRevisionsToCheckForComments(replyLinkParams, situation);
		} else {
			var api = new mw.Api();
			api.get( {
				action: 'query', prop: 'revisions', format: 'json', titles: replyLinkParams.pageTitle, rvlimit: 1, rvprop: 'timestamp|user|comment|content', rvslots: '*', rvstart: Bawl.pageLoadTimestamp,
			} ).done( function ( data ) {
				Bawl.dbg('page content as it was when loading the page:');
				Bawl.dbg(data);
				if ( data.query && data.query.pages && data.query.pages[ Object.keys(data.query.pages)[0] ] && data.query.pages[ Object.keys(data.query.pages)[0] ].revisions && data.query.pages[ Object.keys(data.query.pages)[0] ].revisions[0] ) {
					Bawl.pageRevisionSinceLastCheck[replyLinkParams.pageTitle] = data.query.pages[ Object.keys(data.query.pages)[0] ].revisions[0].slots.main['*'];
				} else {
					Bawl.pageRevisionSinceLastCheck[replyLinkParams.pageTitle] = '';
				}
				Bawl.compareRevisionsToCheckForComments(replyLinkParams, situation);
			});
		}
	};
	Bawl.closeSettings = function() {
			$(document.getElementsByClassName('BawlSettings')).addClass('BawlNoDisplay');
			window.BawlUITextInput.scrollIntoView();
	};
	Bawl.createPingText = function(replyLinkParams) {
		Bawl.dbg('create ping text');
		Bawl.recipientIsAnon = replyLinkParams.origReplyTo.match(/(^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$|\:)/); //IPv4 or contains a colon as in IPv6 which is disallowed in usernames. Will need adjustment after IP anonimization
		Bawl.userHatesPingTimestamp = Bawl.timestampToTimeAsInSig(replyLinkParams.origTimestamp);
		Bawl.checkHtmlForNoping = $('.bawlprocess')[replyLinkParams.int].parentElement.innerHTML;
		Bawl.checkLessHtmlForNopingRegExp = new RegExp(Bawl.escapeRegExp(replyLinkParams.origReplyTo) + '.*NOPING.*' + Bawl.userHatesPingTimestamp);
		Bawl.checkLessHtmlForNoping = '';
		if ( Bawl.checkHtmlForNoping.match(Bawl.checkLessHtmlForNopingRegExp) ) {
			Bawl.checkLessHtmlForNoping = Bawl.checkHtmlForNoping.match(Bawl.checkLessHtmlForNopingRegExp)[0];
		}
		Bawl.userHatesPingRegExp = new RegExp('(' + Bawl.escapeRegExp(replyLinkParams.origReplyTo) + '.*)NOPING(\:[^\:\<\>\"]{0,120})?(\:[^\:\<\>\"]{0,120})?(\:[^\:\<\>\"]{0,120})?(\:[^\:\<\>\"]{0,120})?(\:[^\:\<\>\"]{0,120})?(.{0,100}' + Bawl.userHatesPingTimestamp + '.*)');
		Bawl.userHatesPing = Bawl.checkLessHtmlForNoping.match(Bawl.userHatesPingRegExp);
		if ( Bawl.recipientIsAnon != null ) {
			Bawl.dbg('anon user found');
			return Bawl.pingTextAnon.replace(/USERNAME/g, Bawl.escapeReplacement(replyLinkParams.origReplyTo));
		} else if ( Bawl.userHatesPing ) {
			Bawl.dbg('user hates pings');
			Bawl.userNemesis = Bawl.checkLessHtmlForNoping.replace(Bawl.userHatesPingRegExp, '$2$3$4$5$6').replace(/_/g, ' ');
			if ( Bawl.userNemesis == '' || Bawl.userNemesis.match(':' + mw.config.get('wgUserName') + ':') ) {
				Bawl.dbg(replyLinkParams.origReplyTo + ' doesn\'t want to be pinged');
				if ( Bawl.userNemesis.match(':' + mw.config.get('wgUserName') + ':') ) {
					Bawl.dbg('BY YOU.');
				}
				mw.notify(Bawl.msgs.nopingNotify);
				return replyLinkParams.origReplyTo + ', ';
			} else {
				Bawl.dbg('this user has enemies, but you aren\'t one of them. adding ping');
				return Bawl.settings.pingText.replace(/USERNAME/g, Bawl.escapeReplacement(replyLinkParams.origReplyTo));
			}
		} else {
			return Bawl.settings.pingText.replace(/USERNAME/g, Bawl.escapeReplacement(replyLinkParams.origReplyTo));
		}
	};
	Bawl.openReplyForm = function(replyLinkParams) {
		Bawl.loadSettings();
		if ( Bawl.languagesAvailableInExternalFile.indexOf(mw.config.get('wgUserLanguage')) != -1 ) {
			mw.loader.getScript('https://en.wikipedia.org/enwiki/w/index.php?title=User:Alexis_Jazz/Bawl-lang.js&action=raw&ctype=text/javascript');
		}
		if ( typeof replyLinkParams == 'string' ) {
			replyLinkParams = JSON.parse(decodeURIComponent(replyLinkParams.replace(/\%27/g, '\'')));
		}
		Bawl.postCommentSuccess = false;
		if ( Bawl.settings.warnExit == true ) {
			window.onbeforeunload = function() { if ( Bawl.UITextInput.getValue() != '' && document.getElementById('BawlReplyForm') ) { return ''; } };
		}
		Bawl.dbg(replyLinkParams);
		Bawl.dbg('Bawl.openReplyForm');
		if ( document.getElementById('BawlUITextInput') != null && replyLinkParams.origReplyTo != 'anonSectReply' && replyLinkParams.type == 'comment' ) { //there is already a reply form open, add a ping instead
			Bawl.dbg('form already open, adding ping');
			Bawl.currentMessageLastCharacter = Bawl.UITextInput.getValue().slice(Bawl.UITextInput.getValue().length - 1, Bawl.UITextInput.getValue().length);
			if ( Bawl.currentMessageLastCharacter != " " ) {
				Bawl.spaceBeforePing = " ";
			} else {
				Bawl.spaceBeforePing = "";
			}
			Bawl.userPingText = Bawl.createPingText(replyLinkParams);
			if ( Bawl.UITextInput.getValue().match(Bawl.escapeRegExp(Bawl.userPingText)) ) {
				Bawl.dbg('this user has already been mentioned. I\'ll scroll Bawl into view so you can see');
				Bawl.UITextInput.scrollElementIntoView();
				Bawl.UIReplyButton.scrollElementIntoView();
				Bawl.UITextInput.focus();
			} else {
				Bawl.dbg('insert user ' + Bawl.userPingText);
				//Bawl.UITextInput.encapsulateContent() is the easier way to do this, but that will always focus the input field and scroll it into view. the focus isn't the issue, the scrolling can be if you are adding multiple names from elsewhere in the discussion
				Bawl.cursorPos = Bawl.UITextInput.getRange().from;
				Bawl.textInputWithMention = Bawl.UITextInput.getValue().slice(0, Bawl.cursorPos) + Bawl.spaceBeforePing + Bawl.userPingText + Bawl.UITextInput.getValue().slice(Bawl.cursorPos,);
				Bawl.UITextInput.setValue(Bawl.textInputWithMention);
			}
		} else if ( document.getElementById('BawlUITextInput') != null && ( replyLinkParams.origReplyTo == 'anonSectReply' || replyLinkParams.type != 'comment' ) ) {
			Bawl.dbg('not adding a mention for not-comment icons');
			Bawl.UITextInput.scrollElementIntoView();
			Bawl.UIReplyButton.scrollElementIntoView();
		} else if ( document.getElementById('BawlUITextInput') == null ) { //there is no reply form yet, create one
			Bawl.replyLinkParamsOpened = replyLinkParams;
			Bawl.bawlFormHTML = document.createElement('div');
			Bawl.bawlFormHTML.id = 'bawlForm-' + replyLinkParams.id;
			Bawl.bawlFormHTML.classList = [ 'BawlNoDisplay BawlForm' ];
			if ( replyLinkParams.origReplyTo == 'anonSectReply' ) {
				document.getElementById(replyLinkParams.id).append(Bawl.bawlFormHTML);
			} else if ( replyLinkParams.type == 'comment' || replyLinkParams.type == 'edit' ) {
				Bawl.dbg('add form to edit comment');
				if ( $('.bawlprocess')[replyLinkParams.int].parentElement && $('.bawlprocess')[replyLinkParams.int].parentElement.nextElementSibling && $('.bawlprocess')[replyLinkParams.int].parentElement.nextElementSibling.tagName == 'DL' && replyLinkParams.origLevel == 0 ) {
					Bawl.dbg('unindented comment with indented comments below it, insert the reply form below it. This should generally put the reply form where the reply will be.');
					$('.bawlprocess')[replyLinkParams.int].parentElement.nextElementSibling.append(Bawl.bawlFormHTML);
				} else {
					Bawl.dbg('unindented comment without indented comments below it, appending to:');
					Bawl.dbg($('.bawlprocess')[replyLinkParams.int].parentElement);
					$('.bawlprocess')[replyLinkParams.int].parentElement.append(Bawl.bawlFormHTML);
				}
				if ( replyLinkParams.preview == true ) {
					Bawl.dbg('add form to edit from preview');
					$('#Bawlpreviewlinks').append(Bawl.bawlFormHTML);
				}
			} else if ( replyLinkParams.type == 'edit' ) {
				Bawl.bawlFormHTML.id = 'bawlForm-edit-' + replyLinkParams.id;
				if ( replyLinkParams.preview == true ) {
					$('#Bawlpreviewlinks').append(Bawl.bawlFormHTML);
				}
			} else if ( replyLinkParams.type == 'heading' ) {
				$('.bawlprocess')[replyLinkParams.int].append(Bawl.bawlFormHTML);
			} else if ( replyLinkParams.subtype == 'BCL' ) {
				$('.bawlprocess')[replyLinkParams.int].append(Bawl.bawlFormHTML);
			}
			if ( Bawl.UITextInput && Bawl.UITextInput.getValue() != '' ) {
				Bawl.dbg('form was opened previously, reload last input');
				Bawl.preloadText = Bawl.UITextInput.getValue();
			} else if ( replyLinkParams.origReplyTo != 'anonSectReply' && replyLinkParams.origReplyTo != 'NO-VALUE-PLEASE-IGNORE' && Bawl.settings.autoPing == true && replyLinkParams.type == "comment" && replyLinkParams.origReplyTo != mw.config.get( "wgUserName" ) && !( replyLinkParams.origReplyTo == mw.config.get('wgTitle') && mw.config.get('wgNamespaceNumber') == 3 ) ) { //don't ping yourself and don't ping the recipient on their own talk page
				Bawl.dbg('preloading auto-mention');
				Bawl.preloadText = Bawl.createPingText(replyLinkParams);
			} else {
				Bawl.dbg('skipping auto-mention');
				Bawl.preloadText = '';
			}
			if ( Bawl.UITextInputTitle ) { Bawl.preloadTitle = Bawl.UITextInputTitle.getValue() } else { Bawl.preloadTitle = '' };
			if ( Bawl.settings.limitWidth == false ) {
				Bawl.BawlUITextInputTitleClass = 'BawlNoMaxWidth';
			} else {
				Bawl.BawlUITextInputTitleClass = '';
			}
			Bawl.UITextInputTitle = new OO.ui.TextInputWidget( {
				id: 'BawlUITextInputTitle',
				classes: [ 'BawlMarginHalfEm',Bawl.BawlUITextInputTitleClass ],
				value: Bawl.preloadTitle,
				placeholder: Bawl.msgs.titlePlaceholder,
			} );
			Bawl.UITextInput = new OO.ui.MultilineTextInputWidget( {
				id: 'BawlUITextInput',
				rows: 6,
				classes: [ 'BawlMarginHalfEm', 'BawlUnsetLimitWidth' ],
				value: Bawl.preloadText,
			} );
			if ( Bawl.settings.livePreview == true ) {
				Bawl.UITextInput.on('change', function() {
					const BawlCurrentInputValue = Bawl.UITextInput.getValue();
					var DelayedPreview = setInterval(function () { // only parse preview if content has been stable for at least half a second
						Bawl.newInputValue = Bawl.UITextInput.getValue();
						clearInterval(DelayedPreview);
						if ( BawlCurrentInputValue == Bawl.newInputValue ) {
							Bawl.doPreview('preview');
							Bawl.dbg('live preview');
						} else {
							Bawl.dbg('you\'re typing too fast!!');
						}
						delete BawlCurrentInputValue;
					}, 500);
				});
			}
			Bawl.buttonOnTheWrongSideClass = '';
			if ( Bawl.settings.wrongUI == true ) {
				Bawl.buttonOnTheWrongSideClass = 'BawlFloatRight';
			}
			Bawl.UIReplyButton = new OO.ui.ButtonWidget( {
				id: 'BawlUIReplyButton',
				label: Bawl.basicmsgs.BawlUIReplyButton,
				flags: [ 'primary', 'progressive' ],
				classes: [ Bawl.buttonOnTheWrongSideClass ]
			} );
			Bawl.UIReplyButton.on('click', function() { Bawl.postReply1(replyLinkParams) });
			Bawl.UIDryRunButton = new OO.ui.ButtonWidget( {
				id: 'BawlUIDryRunButton',
				label: 'Dry run',
				flags: [ 'primary', 'progressive' ],
				classes: [ Bawl.buttonOnTheWrongSideClass ]
			} );
			Bawl.UIDryRunButton.on('click', function() { Bawl.dryRunOnce = true;Bawl.postReply1(replyLinkParams) });
			Bawl.UIPreviewButton = new OO.ui.ButtonWidget( {
				id: 'BawlUIPreviewButton',
				label: Bawl.basicmsgs.BawlUIPreviewButton,
				flags: [ 'primary' ],
				classes: [ Bawl.buttonOnTheWrongSideClass ]
			} );
			Bawl.UIPreviewButton.on('click', function() { Bawl.doPreview('preview') });
			Bawl.UICancelButton = new OO.ui.ButtonWidget( {
				id: 'BawlUICancelButton',
				label: Bawl.basicmsgs.BawlUICancelButton,
				classes: [ Bawl.buttonOnTheWrongSideClass ]
			} );
			Bawl.UISettingsButton = new OO.ui.ButtonWidget( {
				id: 'BawlUISettingsButton',
				icon: 'settings',
				classes: ['BawlFloatRight'],
				framed: false,
			} );
			Bawl.UICancelButton.on('click', Bawl.cancelReply);
			Bawl.UIprogressIndicatorHTML = new OO.ui.HtmlSnippet('<span id="BawlProgressIndicator"></span>');
			Bawl.UIprogressIndicator = new OO.ui.LabelWidget( {
				label: Bawl.UIprogressIndicatorHTML,
			} );
			Bawl.UIMarkupBoldButton = new OO.ui.ButtonWidget( {
				id: 'BawlUIMarkupBoldButton',
				label: Bawl.basicmsgs.bold,
				framed: false,
				classes: ['BawlLeftRightMargin', 'BawlMarkupBold']
			} );
			Bawl.UIMarkupItalicButton = new OO.ui.ButtonWidget( {
				id: 'BawlUIMarkupItalicButton',
				label: Bawl.basicmsgs.italic,
				framed: false,
				classes: ['BawlLeftRightMargin', 'BawlMarkupItalic']
			} );
			Bawl.UIMarkupStrikeButtonLabel = new OO.ui.HtmlSnippet('<span style="text-decoration:line-through">' + Bawl.basicmsgs.strike + '</span>');
			Bawl.UIMarkupStrikeButton = new OO.ui.ButtonWidget( {
				id: 'BawlUIMarkupStrikeButton',
				label: Bawl.UIMarkupStrikeButtonLabel,
				framed: false,
				classes: ['BawlLeftRightMargin']
			} );
			Bawl.UIMarkupLinkButton = new OO.ui.ButtonWidget( {
				id: 'BawlUIMarkupLinkButton',
				label: '[[]]',
				framed: false,
				classes: ['BawlLeftRightMargin']
			} );
			Bawl.UIMarkupBoldButton.on('click', function() { Bawl.UITextInput.encapsulateContent('\'\'\'', '\'\'\'') } );
			Bawl.UIMarkupItalicButton.on('click', function() { Bawl.UITextInput.encapsulateContent('\'\'', '\'\'') } );
			Bawl.UIMarkupStrikeButton.on('click', function() { Bawl.UITextInput.encapsulateContent('<s>', '</s>') } );
			Bawl.UIMarkupLinkButton.on('click', function() { Bawl.UITextInput.encapsulateContent('[[', ']]') } );
			if ( Bawl.settings.markup == true ) {
				Bawl.MarkupButtonBar = new OO.ui.HorizontalLayout( {
					items: [
						Bawl.UIMarkupBoldButton,
						Bawl.UIMarkupItalicButton,
						Bawl.UIMarkupStrikeButton,
						Bawl.UIMarkupLinkButton
					],
					id: 'BawlMarkupButtonBar',
					classes: ['BawlLeftRightMargin']
				} );
			} else {
				Bawl.MarkupButtonBar = new OO.ui.HorizontalLayout( {} );
			}
			if ( Bawl.settings.wrongUI == false ) {
				Bawl.ButtonBarItems = [
						Bawl.UIReplyButton,
						Bawl.UIPreviewButton,
						Bawl.UICancelButton,
						Bawl.UIprogressIndicator,
						Bawl.MarkupButtonBar,
						Bawl.UISettingsButton
					];
			} else {
				Bawl.ButtonBarItems = [
						Bawl.UIprogressIndicator,
						Bawl.UIReplyButton,
						Bawl.UIPreviewButton,
						Bawl.UICancelButton,
						Bawl.UISettingsButton,
						Bawl.MarkupButtonBar,
					];
			}
			if ( Bawl.settings.debug == true ) {
				Bawl.ButtonBarItems.push(Bawl.UIDryRunButton);
			}
			Bawl.ButtonBar = new OO.ui.HorizontalLayout( {
				items: Bawl.ButtonBarItems,
				id: 'BawlMainButtonBar',
			} );
			Bawl.previewAndSettingsDiv = '<div id="BawlCustomInserts" class="BawlCustomInserts BawlMarginHalfEm BawlNoDisplay"></div><div id="showNewLinesButton" class="BawlNoDisplay"></div><div id="BawlPreviewBox" class="BawlPreviewBox BawlMarginHalfEm BawlNoDisplay"></div><div id="BawlSettings" class="BawlSettings BawlMarginHalfEm BawlNoDisplay"><span class="BawlFloatRight"><a href="https://en.wikipedia.org/wiki/User:Alexis_Jazz/Bawl" style="font-weight: bold">Bawl!</a> (early access)</span></div>';
			Bawl.editNoticeDiv = '<div id="BawlEditNotice" class="BawlNoDisplay BawlForm BawlEditNoticeDiv"></div>';
			Bawl.ReplyForm = new OO.ui.FormLayout( {
				items: [
					Bawl.UITextInputTitle,
					Bawl.UITextInput,
					Bawl.ButtonBar,
				],
				id: 'BawlReplyForm',
				classes: ['BawlReplyForm'],
			} );
			$(document.getElementById('bawlForm-' + replyLinkParams.id)).removeClass('BawlNoDisplay');
			$(document.getElementById('bawlForm-' + replyLinkParams.id)).append(Bawl.editNoticeDiv).append(Bawl.ReplyForm.$element);
			if ( replyLinkParams.type == 'edit' ) { //preload content
				Bawl.UITextInput.setDisabled(true); //disable textinput until preload is done
				Bawl.UIReplyButton.setLabel(Bawl.basicmsgs.BawlUIEditButton);
				Bawl.dbg('preloading existing comment');
					var api = new mw.Api();
					api.get( {
						action: 'query', export: 'true', format: 'json', titles: replyLinkParams.pageTitle,
					} ).done( function ( data ) {
						Bawl.dbg(data);
						Bawl.wikiTextForEdit = Bawl.getWikitextFromExport(data.query.export["*"]);
						Bawl.origTimeAsInSig = Bawl.timestampToTimeAsInSig(replyLinkParams.origTimestamp);
						Bawl.endOfCommentLocatorRegExp = new RegExp(' *(\{\{BawlCmt|<span id="[^"]*" class="BawlCmt").*');
						Bawl.wikiTextForEditCommentRegExp = new RegExp('(^|\n)[\\:\\*\\#]{' + replyLinkParams.origLevel + '}(.*(' + Bawl.escapeRegExp(encodeURIComponent(replyLinkParams.origReplyTo)).replace(/ /g, '[_ ]') + '|' + Bawl.escapeRegExp(replyLinkParams.origReplyTo).replace(/ /g, '[_ ]') + ').{0,255}' + Bawl.origTimeAsInSig + '.*)', '');
						Bawl.restoreNewlineRegExp = new RegExp(Bawl.escapeRegExp(Bawl.newLineTemplate), 'g');
						Bawl.origTimeAsInSigEditRegExp = new RegExp(' *' + Bawl.origTimeAsInSig + '[^]*');
						Bawl.wikiTextForEditComment = Bawl.wikiTextForEdit.match(Bawl.wikiTextForEditCommentRegExp)[2].replace(Bawl.endOfCommentLocatorRegExp, '').replace(Bawl.origTimeAsInSigEditRegExp, '').replace(/^[\*\:\#]*/, '');
						Bawl.wikiTextForEditCommentMultiline = Bawl.wikiTextForEditComment.replace( Bawl.restoreNewlineRegExp, '\n' );
						Bawl.UITextInput.setValue(Bawl.wikiTextForEditCommentMultiline);
						Bawl.UITextInput.setDisabled(false);
						Bawl.dbg('edit preload done, focus text input');
						Bawl.UITextInput.focus();
					});
			};
			if ( (replyLinkParams.preload || replyLinkParams.preloadtitle) && Bawl.UITextInput.getValue() == '' && Bawl.UITextInputTitle.getValue() == '' ) { //InputBox/Bawl-comment-link preload
				for (intInputBoxPreload = 0; intInputBoxPreload < $('.bawlprocess')[replyLinkParams.int].children.length; intInputBoxPreload++) {
					Bawl.dbg('process child element #' + intInputBoxPreload + '/' + $('.bawlprocess')[replyLinkParams.int].children.length + ' for element #' + int);
					if ( $('.bawlprocess')[replyLinkParams.int].children[intInputBoxPreload].name == 'preloadtitle' ) {
						replyLinkParams.preloadtitle = $('.bawlprocess')[replyLinkParams.int].children[intInputBoxPreload].value;
					}
				}
				if ( replyLinkParams.preloadtitle ) {
					Bawl.dbg('preloading title');
					Bawl.UITextInputTitle.setValue(replyLinkParams.preloadtitle);
				}
				if ( replyLinkParams.preload ) {
					Bawl.UITextInput.setDisabled(true); //disable textinput until preload is done
					Bawl.dbg('preloading page specified by InputBox');
						var api = new mw.Api();
						api.get( {
							action: 'query', export: 'true', format: 'json', titles: replyLinkParams.preload,
						} ).done( function ( data ) {
							Bawl.dbg(data);
							Bawl.wikiTextForEdit = Bawl.getWikitextFromExport(data.query.export["*"]);
							if ( typeof replyLinkParams.preloadparams == 'string' ) {
								replyLinkParams.preloadparams = JSON.parse(decodeURIComponent(replyLinkParams.preloadparams).replace(/\&quot\;/g, '"'));
							}
							for (intInputBoxPreloadParams = 0; intInputBoxPreloadParams < replyLinkParams.preloadparams.length; intInputBoxPreloadParams++) {
								Bawl.dbg('replacing preloadparam ' + (intInputBoxPreloadParams + 1));
								Bawl.replacePreloadVar = new RegExp('\\$' + ( intInputBoxPreloadParams + 1) + '([^0-9]|$)', 'g')
								Bawl.wikiTextForEdit = Bawl.wikiTextForEdit.replace(Bawl.replacePreloadVar, replyLinkParams.preloadparams[intInputBoxPreloadParams] + '$1');
							}
							Bawl.UITextInput.setValue(Bawl.wikiTextForEdit);
							Bawl.UITextInput.setDisabled(false);
							if ( Bawl.UITextInputTitle.isVisible() == false ) {
								Bawl.dbg('loaded requested preload page, focus input field');
								Bawl.UITextInput.focus();
							}
						});
				}
			};
			if ( replyLinkParams.type == 'newsection' ) {
				window.BawlUITextInputTitle.scrollIntoView();
			}
			$('#BawlReplyForm').append(Bawl.tosNagContainer);
			if ( Bawl.settings.tosNag == true && ! document.getElementById('BawlToSNag') ) {
				$('#BawltosNagContainer').append(Bawl.msgs.tosNagText);
			};
			$(document.getElementById('bawlForm-' + replyLinkParams.id)).append(Bawl.previewAndSettingsDiv);
			Bawl.customInsertButton = {};
			for (int = 0; int < 30; int++) {
				Bawl.dbg('process custom inserts');
				if ( Bawl.settings.cI && Bawl.settings.cI[int] && Bawl.settings.cI[int] != "" ) {	//non-empty insert found
					$('.BawlCustomInserts').removeClass('BawlNoDisplay');
					Bawl.dbg('adding button for custom insert #' + int);
					if ( Bawl.settings.cI[int].match(/\:\<\<([^\>]*)\>\>/) ) {
						Bawl.settings.cILabel = Bawl.settings.cI[int].replace(/.*\:\<\<([^\>]*)\>\>/, '$1');
					} else if ( Bawl.settings.cI[int].length > 14 ) {
						Bawl.settings.cILabel = Bawl.settings.cI[int].slice(0,10) + '..';
					} else {
						Bawl.settings.cILabel = Bawl.settings.cI[int];
					}
					Bawl.insertIsRegExpRegExp = new RegExp('^\/(.*)([^\])\/(.*)([^\])\/([gmi]*)$');
					Bawl.customInsertButton[int] = new OO.ui.ButtonWidget( {
						label: Bawl.settings.cILabel,
						classes: [ 'BawlMarginHalfEm' ]
					});
					Bawl.insertCustomInsert = function(num) {
						Bawl.activatedCustomInsert = Bawl.settings.cI[num].replace(/\:\<\<[^\>]*\>\>$/, '');
						if ( Bawl.activatedCustomInsert.match(Bawl.insertIsRegExpRegExp) && Bawl.activatedCustomInsert.match(Bawl.insertIsRegExpRegExp).length == 6 ) {
							Bawl.customInsertRegExpNowParts = Bawl.activatedCustomInsert.match(Bawl.insertIsRegExpRegExp);
							Bawl.customInsertRegExpNow = new RegExp(Bawl.customInsertRegExpNowParts[1] + Bawl.customInsertRegExpNowParts[2], Bawl.customInsertRegExpNowParts[5]);
							Bawl.UITextInput.setValue(Bawl.UITextInput.getValue().replace(Bawl.customInsertRegExpNow, Bawl.customInsertRegExpNowParts[3] + Bawl.customInsertRegExpNowParts[4]));
						} else {
							Bawl.UITextInput.encapsulateContent(Bawl.activatedCustomInsert,'');
						}
					}
					if ( int == 0 ) { Bawl.customInsertButton[0].on('click', function() { Bawl.insertCustomInsert(0); });	//this isn't very pretty but I'm not sure how else to solve it. You can't just call int because that'll be 10 by the time you press a button
					} else if ( int == 1 ) { Bawl.customInsertButton[1].on('click', function() { Bawl.insertCustomInsert(1); });
					} else if ( int == 2 ) { Bawl.customInsertButton[2].on('click', function() { Bawl.insertCustomInsert(2); });
					} else if ( int == 3 ) { Bawl.customInsertButton[3].on('click', function() { Bawl.insertCustomInsert(3); });
					} else if ( int == 4 ) { Bawl.customInsertButton[4].on('click', function() { Bawl.insertCustomInsert(4); });
					} else if ( int == 5 ) { Bawl.customInsertButton[5].on('click', function() { Bawl.insertCustomInsert(5); });
					} else if ( int == 6 ) { Bawl.customInsertButton[6].on('click', function() { Bawl.insertCustomInsert(6); });
					} else if ( int == 7 ) { Bawl.customInsertButton[7].on('click', function() { Bawl.insertCustomInsert(7); });
					} else if ( int == 8 ) { Bawl.customInsertButton[8].on('click', function() { Bawl.insertCustomInsert(8); });
					} else if ( int == 9 ) { Bawl.customInsertButton[9].on('click', function() { Bawl.insertCustomInsert(9); });
					} else if ( int == 10 ) { Bawl.customInsertButton[10].on('click', function() { Bawl.insertCustomInsert(10); });
					} else if ( int == 11 ) { Bawl.customInsertButton[11].on('click', function() { Bawl.insertCustomInsert(11); });
					} else if ( int == 12 ) { Bawl.customInsertButton[12].on('click', function() { Bawl.insertCustomInsert(12); });
					} else if ( int == 13 ) { Bawl.customInsertButton[13].on('click', function() { Bawl.insertCustomInsert(13); });
					} else if ( int == 14 ) { Bawl.customInsertButton[14].on('click', function() { Bawl.insertCustomInsert(14); });
					} else if ( int == 15 ) { Bawl.customInsertButton[15].on('click', function() { Bawl.insertCustomInsert(15); });
					} else if ( int == 16 ) { Bawl.customInsertButton[16].on('click', function() { Bawl.insertCustomInsert(16); });
					} else if ( int == 17 ) { Bawl.customInsertButton[17].on('click', function() { Bawl.insertCustomInsert(17); });
					} else if ( int == 18 ) { Bawl.customInsertButton[18].on('click', function() { Bawl.insertCustomInsert(18); });
					} else if ( int == 19 ) { Bawl.customInsertButton[19].on('click', function() { Bawl.insertCustomInsert(19); });
					} else if ( int == 20 ) { Bawl.customInsertButton[20].on('click', function() { Bawl.insertCustomInsert(20); });
					} else if ( int == 21 ) { Bawl.customInsertButton[21].on('click', function() { Bawl.insertCustomInsert(21); });
					} else if ( int == 22 ) { Bawl.customInsertButton[22].on('click', function() { Bawl.insertCustomInsert(22); });
					} else if ( int == 23 ) { Bawl.customInsertButton[23].on('click', function() { Bawl.insertCustomInsert(23); });
					} else if ( int == 24 ) { Bawl.customInsertButton[24].on('click', function() { Bawl.insertCustomInsert(24); });
					} else if ( int == 25 ) { Bawl.customInsertButton[25].on('click', function() { Bawl.insertCustomInsert(25); });
					} else if ( int == 26 ) { Bawl.customInsertButton[26].on('click', function() { Bawl.insertCustomInsert(26); });
					} else if ( int == 27 ) { Bawl.customInsertButton[27].on('click', function() { Bawl.insertCustomInsert(27); });
					} else if ( int == 28 ) { Bawl.customInsertButton[28].on('click', function() { Bawl.insertCustomInsert(28); });
					} else if ( int == 29 ) { Bawl.customInsertButton[29].on('click', function() { Bawl.insertCustomInsert(29); });
					}
					$('.BawlCustomInserts').append(Bawl.customInsertButton[int].$element);
				} //end non-empty insert found
			} //end for
			if ( Bawl.settings.limitWidth == true ) {
				$('.BawlForm').addClass('BawlLimitWidth');
				$('BawlUITextInput').removeClass('BawlUnsetLimitWidth');
				$('BawlUITextInput').addClass('BawlLimitWidth')
			}
			if ( replyLinkParams.type == 'comment' || replyLinkParams.type == 'edit' || replyLinkParams.subtype == 'BCL' ) {
				Bawl.dbg('hide title input and make it read-only');
				Bawl.UITextInputTitle.setValue('');
				Bawl.UITextInputTitle.setReadOnly(true);
				Bawl.UITextInputTitle.toggle(false);
			}
			if ( Bawl.settings.editNotice == true || replyLinkParams.editIntro ) { // load editnotice. if there isn't any it'll just be blank
				Bawl.dbg('Loading editnotice');
				$('#BawlEditNotice').removeClass('BawlNoDisplay');
				Bawl.editNoticeParams = {
					format: 'json',
					action: 'parse',
					title: Bawl.replyLinkParamsOpened.pageTitle,
					pst: '1',
					prop: 'text',
					formatversion: '2',
					text: '{{#ifexist:MediaWiki:Editnotice-{{NAMESPACENUMBER}}-{{#invoke:String|replace|{{PAGENAME}}|/|-}}|{{MediaWiki:Editnotice-{{NAMESPACENUMBER}}-{{#invoke:String|replace|{{PAGENAME}}|/|-}}}}|{{#ifexist:MediaWiki:Editnotice-{{NAMESPACENUMBER}}|{{MediaWiki:Editnotice-{{NAMESPACENUMBER}}}}}}}}',
				};
				if ( replyLinkParams.editIntro ) {
					Bawl.editNoticeParams.text = '{{:' + replyLinkParams.editIntro + '}}';
				}
				Bawl.doAPICall(Bawl.editNoticeParams, 'editnotice');
			}
			if ( Bawl.settings.checkNewComments == true ) {
				Bawl.checkForNewComments(replyLinkParams, 'openform');
			}
			Bawl.dbg('scroll reply button into view');
			Bawl.UIReplyButton.scrollElementIntoView();
			if ( replyLinkParams.type == 'newsection' | replyLinkParams.type == 'heading' ) {
				Bawl.dbg('focus input title and scroll it into view');
				Bawl.UITextInputTitle.focus();
				Bawl.UITextInputTitle.scrollElementIntoView();
			} else {
				Bawl.dbg('focus text input');
				Bawl.UITextInput.focus();
			}
		Bawl.openSettings = function(openclose) {
			Bawl.UISettingsButton.blur();
			if ( document.getElementById('saveSettingsButton') && ! $(document.getElementsByClassName('BawlSettings')).hasClass('BawlNoDisplay') && openclose != 'open' ) {
				Bawl.dbg('settings are already opened. hiding them');
				Bawl.closeSettings();
				return;
			} else if ( document.getElementById('saveSettingsButton') && $(document.getElementsByClassName('BawlSettings')).hasClass('BawlNoDisplay') ) {
				Bawl.dbg('settings were opened previously but currently hidden. unhiding them');
				$(document.getElementsByClassName('BawlSettings')).removeClass('BawlNoDisplay');
				return;
			}
			$(document.getElementsByClassName('BawlSettings')).removeClass('BawlNoDisplay');
			Bawl.settingElement = {};
			Bawl.settingElement.watchlist = new OO.ui.DropdownInputWidget( {
				options: [
					{ data: 'nochange', label: Bawl.msgs.watchlistexpirynochange },
					{ data: 'preferences', label: Bawl.msgs.watchlistexpirypreferences },
					{ data: 'unwatch', label: Bawl.msgs.watchlistexpiryunwatch },
					{ data: 'watch', label: Bawl.msgs.watchlistexpirywatch },
					],
				label: 'Bawl.msgs.watchlist',
				value: Bawl.settings.watchlist,
				id: 'UIwatchlist',
				classes: [ 'BawlDropDownMenu' ],
			} );
			Bawl.settingElement.watchlistFieldLayout = new OO.ui.FieldLayout( Bawl.settingElement.watchlist, { label: Bawl.msgs.watchlist, align: 'inline', classes: [ 'BawlOOuiFieldLayout' ] } );
			Bawl.settingElement.watchlistexpiry = new OO.ui.DropdownInputWidget( {
				options: [
					{ data: '14 days', label: Bawl.msgs.watchlistexpirydays.replace('DAYS', '14') },
					{ data: '30 days', label: Bawl.msgs.watchlistexpirydays.replace('DAYS', '30') },
					{ data: '90 days', label: Bawl.msgs.watchlistexpirydays.replace('DAYS', '90') },
					{ data: '180 days', label: Bawl.msgs.watchlistexpirydays.replace('DAYS', '180') },
					{ data: '365 days', label: Bawl.msgs.watchlistexpirydays.replace('DAYS', '365') },
					{ data: '730 days', label: Bawl.msgs.watchlistexpirydays.replace('DAYS', '730') },
					{ data: 'indefinite', label: Bawl.msgs.watchlistexpirydays.replace('DAYS', '∞') },
					],
				label: 'Bawl.msgs.watchlistexpiry',
				value: Bawl.settings.watchlistexpiry,
				id: 'UIwatchlistexpiry',
				classes: [ 'BawlDropDownMenu' ],
			} );
			Bawl.settingElement.watchlistexpiryFieldLayout = new OO.ui.FieldLayout( Bawl.settingElement.watchlistexpiry, { label: Bawl.msgs.watchlistexpiry, align: 'inline', classes: [ 'BawlOOuiFieldLayout' ] } );
			Bawl.settingElement.UIfontSize = new OO.ui.DropdownInputWidget( {
				options: [
					{ data: '0.875em', label: Bawl.msgs.UIfontSize0875em },
					{ data: 'x-small', label: Bawl.msgs.UIfontSizeTiny },
					{ data: 'small', label: Bawl.msgs.UIfontSizeSmall },
					{ data: 'medium' , label: Bawl.msgs.UIfontSizeMedium },
					{ data: 'large' , label: Bawl.msgs.UIfontSizeLarge },
					{ data: 'x-large', label: Bawl.msgs.UIfontSizeHuge },
					],
				label: 'Bawl.msgs.UIfontSizeDefault',
				value: Bawl.settings.UIfontSize,
				id: 'UIfontSize',
				classes: [ 'BawlDropDownMenu' ],
			} );
			Bawl.settingElement.UIfontSizeFieldLayout = new OO.ui.FieldLayout( Bawl.settingElement.UIfontSize, { label: Bawl.msgs.UIfontSize, align: 'inline', classes: [ 'BawlOOuiFieldLayout' ] } );
			Bawl.settingElement.afterPost = new OO.ui.DropdownInputWidget( {
				options: [
					{ data: 'parsecomment', label: Bawl.msgs.parsecomment },
					{ data: 'reload', label: Bawl.msgs.reloadafter } ,
					{ data: 'link', label: Bawl.msgs.linkafter },
					],
				label: 'Bawl.msgs.afterPost',
				value: Bawl.settings.afterPost,
				id: 'BawlAfterPost',
				classes: [ 'BawlDropDownMenu' ],
			} );
			Bawl.settingElement.afterPostFieldLayout = new OO.ui.FieldLayout( Bawl.settingElement.afterPost, { label: Bawl.msgs.afterPost, align: 'inline', classes: [ 'BawlOOuiFieldLayout' ] } );
			Bawl.settingElement.saveOptionsList = [ { data: 'browser', label: Bawl.msgs.saveToBrowser }, { data: 'commonjs', label: Bawl.msgs.saveToCommonJS } ];
			if ( mw.config.get('wgNoticeProject') == 'wikipedia' || mw.config.get('wgServerName').match(/[a-z\-]{0,20}\.wikipedia\.[a-z]*$/) || mw.config.get('wgDBname').match(/([a-z\-]{0,20})?(wiktionary|wikiquote|wikinews|wikisource|wikibooks|wikiversity|wikivoyage|commonswiki|wikidatawiki|specieswiki|metawiki|mediawikiwiki|incubatorwiki)/) ) {
				Bawl.dbg('This appears to be a Wikimedia SUL wiki. Add option to save preferences to global.js on metawiki');
				Bawl.settingElement.saveOptionsList.push({ data: 'globaljs', label: Bawl.msgs.saveToGlobalJS });
			}
			Bawl.settingElement.saveTo = new OO.ui.DropdownInputWidget( {
				options: Bawl.settingElement.saveOptionsList,
				label: 'Bawl.msgs.saveTo',
				value: Bawl.settings.saveTo,
				id: 'BawlSaveTo',
				classes: [ 'BawlDropDownMenu' ],
			} );
			Bawl.settingElement.saveToFieldLayout = new OO.ui.FieldLayout( Bawl.settingElement.saveTo, { label: Bawl.msgs.saveTo, align: 'inline', classes: [ 'BawlOOuiFieldLayout' ] } );
			Bawl.toggleClearPrefButton = function() {
				if ( Bawl.settingElement.saveTo.getValue() == 'browser' ) {
					Bawl.settingElement.resetPreferencesButton.setLabel(Bawl.msgs.resetPreferencesBrowser);
				} else if ( Bawl.settingElement.saveTo.getValue() == 'commonjs' ) {
					Bawl.settingElement.resetPreferencesButton.setLabel(Bawl.msgs.resetPreferencesCommonJS);
				} else if ( Bawl.settingElement.saveTo.getValue() == 'globaljs' ) {
					Bawl.settingElement.resetPreferencesButton.setLabel(Bawl.msgs.resetPreferencesGlobalJS);
				}
			};
			Bawl.settingElement.saveTo.on('change', Bawl.toggleClearPrefButton );
			Bawl.settingElement.pingText = new OO.ui.TextInputWidget( {
				value: Bawl.settings.pingText,
				id: 'BawlPingTextInput',
				placeholder: Bawl.msgs.BawlPingTextInputPlaceholder,
				classes: [ 'BawlMarginHalfEmTop', 'BawlMarginHalfEm', 'BawlCustomInsertTextInput' ],
			} );
			Bawl.settingElement.pingTextFieldLayout = new OO.ui.FieldLayout( Bawl.settingElement.pingText, { label: Bawl.msgs.pingText, align: 'inline', classes: [ 'BawlOOuiFieldLayout' ] } );
			Bawl.settingElement.UIversionDate = new OO.ui.LabelWidget( {
				label: Bawl.versionDate,
				classes: [ 'BawlFloatRight', 'BawlSmallerText' ]
			} );
			Bawl.settingElement.saveSettingsButton = new OO.ui.ButtonWidget( {
				id: 'saveSettingsButton',
				flags: [ 'primary', 'progressive' ],
				label: Bawl.msgs.saveSettings
			} );
			Bawl.settingElement.resetPreferencesButton = new OO.ui.ButtonWidget( {
				id: 'resetPreferencesButton',
				flags: [ 'primary', 'destructive' ],
				label: Bawl.resetPreferencesButtonLabel,
			} );
			Bawl.toggleClearPrefButton();
			Bawl.settingElement.cancelSettingsButton = new OO.ui.ButtonWidget( {
				id: 'cancelSettingsButton',
				label: Bawl.basicmsgs.BawlUICancelButton,
			} );
			Bawl.settingElement.saveSettingsButton.on('click', Bawl.saveSettings );
			Bawl.settingElement.resetPreferencesButton.on('click', Bawl.resetPreferences );
			Bawl.settingElement.cancelSettingsButton.on('click', Bawl.closeSettings );
			Bawl.settingElement.SettingsButtonBar = new OO.ui.HorizontalLayout( {
				items: [
					Bawl.settingElement.saveSettingsButton,
					Bawl.settingElement.resetPreferencesButton,
					Bawl.settingElement.cancelSettingsButton,
					Bawl.settingElement.UIversionDate
				],
				classes: [ 'BawlMarginHalfEmTop' ],
			} );
				Bawl.settingFormArray = [];
				Bawl.prefCount = Object.keys(Bawl.defaultSettings).length;
				for (prefint = 0; prefint < Bawl.prefCount; prefint++) {
					Bawl.processKey = Object.keys(Bawl.defaultSettings)[prefint];
					Bawl.dbg('process/create element ' + (prefint + 1) + '/' + Bawl.prefCount + ': ' + Bawl.processKey);
					if ( typeof Bawl.settings[ Bawl.processKey ] == 'string' && Bawl.settings[ Bawl.processKey ] == 'LABEL' ) {
						Bawl.dbg('make label');
						Bawl.settingElement[ Bawl.processKey + 'FieldLayout' ] = new OO.ui.LabelWidget( {
							label: Bawl.msgs[ Bawl.processKey ],
							classes: [ 'BawlSettingsSectionLabel' ]
						} );
					} else if ( typeof Bawl.settings[ Bawl.processKey ] != 'object' ) { //do not process the CI/runCI objects
						Bawl.dbg('make checkbox');
						if ( ! Bawl.settingElement[ Bawl.processKey ] ) {
							if ( typeof Bawl.msgs[ Bawl.processKey ] == 'string' && Bawl.msgs[ Bawl.processKey ].match(/\<a/) ) {
								Bawl.msgs[ Bawl.processKey ] = new OO.ui.HtmlSnippet(Bawl.msgs[ Bawl.processKey ]);
							}
							Bawl.settingElement[ Bawl.processKey ] = new OO.ui.CheckboxInputWidget( {
								id: 'BawlPref' + Bawl.processKey,
								selected: Bawl.settings[ Bawl.processKey ],
							} );
							Bawl.settingElement[ Bawl.processKey + 'FieldLayout' ] = new OO.ui.FieldLayout( Bawl.settingElement[ Bawl.processKey ], { id: 'BawlPref' + Bawl.processKey + 'FieldLayout', label: Bawl.msgs[ Bawl.processKey ], align: 'inline', classes: [ 'BawlOOuiFieldLayout' ] } );
						}
					}
					if ( Bawl.settingElement[ Bawl.processKey + 'FieldLayout' ] ) {
						Bawl.settingFormArray.push(Bawl.settingElement[ Bawl.processKey + 'FieldLayout' ]);
					}
				}
				Bawl.dbg('add settings button bar');
				Bawl.settingFormArray.push(Bawl.settingElement.SettingsButtonBar);
			Bawl.settingElement.tosNag.on('change', Bawl.toggleTosNag );
			Bawl.settingElement.dateLinks.on('change', function() { if ( Bawl.settingElement.dateLinks.isSelected() ) { Bawl.settingElement.dateLinksLocalTime.setDisabled(false) } else { Bawl.settingElement.dateLinksLocalTime.setDisabled(true) } } );
			if ( Bawl.settings.dateLinks == false ) {
				Bawl.settingElement.dateLinksLocalTime.setDisabled(true);
			}
			Bawl.settingsForm = new OO.ui.FormLayout( {
				items: Bawl.settingFormArray,
				id: 'BawlReplyForm',
				classes: ['BawlReplyForm'],
			} );
			$('#BawlSettings').append(Bawl.settingsForm.$element);
			Bawl.customInsertTextInput = {};
			Bawl.customInsertThatRunTextInput = {};
			Bawl.hideFurtherCIInputFields = false;
			Bawl.hideFurtherCIThatRunInputFields = false;
			for (int = 0; int < 30; int++) {
				Bawl.dbg('process custom inserts');
				Bawl.placeholderIntPlusOne = int + 1;
				if ( int == 0 ) {
					Bawl.customInsertClass = 'BawlMarginHalfEmTop';
				} else if ( Bawl.hideFurtherCIInputFields == false ) {
					Bawl.customInsertClass = '';
					if ( ( int.toFixed().slice(-1,) == 4 || int.toFixed().slice(-1,) == 9 ) && ! Bawl.settings.cI[int] ) {
						Bawl.dbg('hide further CI input fields');
						Bawl.hideFurtherCIInputFields = true;
					}
				} else {
					Bawl.customInsertClass = 'BawlNoDisplay';
				}
				if ( int == 0 ) {
					Bawl.customInsertThatRunClass = 'BawlMarginHalfEmTop';
				} else if ( Bawl.hideFurtherCIThatRunInputFields == false ) {
					Bawl.customInsertThatRunClass = '';
					if ( ( int.toFixed().slice(-1,) == 4 || int.toFixed().slice(-1,) == 9 ) && ! Bawl.settings.cIThatRun[int] ) {
						Bawl.dbg('hide further CIThatRun input fields');
						Bawl.hideFurtherCIThatRunInputFields = true;
					}
				} else {
					Bawl.customInsertThatRunClass = 'BawlNoDisplay';
				}
				Bawl.customInsertTextInput[int] = new OO.ui.TextInputWidget( {
					value: Bawl.settings.cI[int],
					id: 'BawlCustomInsert' + int,
					placeholder: Bawl.msgs.BawlCustomInsertPlaceholder.replace(/NUM/g, Bawl.placeholderIntPlusOne),
					classes: [ 'BawlMarginHalfEm', 'BawlCustomInsertTextInput', Bawl.customInsertClass ],
				} );
				Bawl.customInsertThatRunTextInput[int] = new OO.ui.TextInputWidget( {
					value: Bawl.settings.cIThatRun[int],
					id: 'BawlCustomInsertThatRun' + int,
					placeholder: Bawl.msgs.BawlCustomInsertThatRunPlaceholder.replace('NUM', Bawl.placeholderIntPlusOne),
					classes: [ 'BawlMarginHalfEm', 'BawlCustomInsertTextInput', Bawl.customInsertThatRunClass ],
				} );
						if ( int == 4 )					{ Bawl.customInsertTextInput[4].on('change', function() { if ( Bawl.customInsertTextInput[4].getValue() != '' ) { $('#BawlCustomInsert' + 5).removeClass('BawlNoDisplay');	$('#BawlCustomInsert' + 6).removeClass('BawlNoDisplay');	$('#BawlCustomInsert' + 7).removeClass('BawlNoDisplay');	$('#BawlCustomInsert' + 8).removeClass('BawlNoDisplay');	$('#BawlCustomInsert' + 9).removeClass('BawlNoDisplay') } } );	//this isn't very pretty but I'm not sure how else to solve it. You can't just call int because that'll be 10 by the time you press a button
						} else if ( int == 9 )	{ Bawl.customInsertTextInput[9].on('change', function() { if ( Bawl.customInsertTextInput[9].getValue() != '' ) { $('#BawlCustomInsert' + 10).removeClass('BawlNoDisplay');	$('#BawlCustomInsert' + 11).removeClass('BawlNoDisplay');	$('#BawlCustomInsert' + 12).removeClass('BawlNoDisplay');	$('#BawlCustomInsert' + 13).removeClass('BawlNoDisplay');	$('#BawlCustomInsert' + 14).removeClass('BawlNoDisplay') } } );
						} else if ( int == 14 )	{ Bawl.customInsertTextInput[14].on('change', function() { if ( Bawl.customInsertTextInput[14].getValue() != '' ) { $('#BawlCustomInsert' + 15).removeClass('BawlNoDisplay');	$('#BawlCustomInsert' + 16).removeClass('BawlNoDisplay');	$('#BawlCustomInsert' + 17).removeClass('BawlNoDisplay');	$('#BawlCustomInsert' + 18).removeClass('BawlNoDisplay');	$('#BawlCustomInsert' + 19).removeClass('BawlNoDisplay') } } );
						} else if ( int == 19 )	{ Bawl.customInsertTextInput[19].on('change', function() { if ( Bawl.customInsertTextInput[19].getValue() != '' ) { $('#BawlCustomInsert' + 20).removeClass('BawlNoDisplay');	$('#BawlCustomInsert' + 21).removeClass('BawlNoDisplay');	$('#BawlCustomInsert' + 22).removeClass('BawlNoDisplay');	$('#BawlCustomInsert' + 23).removeClass('BawlNoDisplay');	$('#BawlCustomInsert' + 24).removeClass('BawlNoDisplay') } } );
						} else if ( int == 24 )	{ Bawl.customInsertTextInput[24].on('change', function() { if ( Bawl.customInsertTextInput[24].getValue() != '' ) { $('#BawlCustomInsert' + 25).removeClass('BawlNoDisplay');	$('#BawlCustomInsert' + 26).removeClass('BawlNoDisplay');	$('#BawlCustomInsert' + 27).removeClass('BawlNoDisplay');	$('#BawlCustomInsert' + 28).removeClass('BawlNoDisplay');	$('#BawlCustomInsert' + 29).removeClass('BawlNoDisplay') } } );
						}
						if ( int == 4 )					{ Bawl.customInsertThatRunTextInput[4].on('change', function() { if ( Bawl.customInsertThatRunTextInput[4].getValue() != '' ) { $('#BawlCustomInsertThatRun' + 5).removeClass('BawlNoDisplay');	$('#BawlCustomInsertThatRun' + 6).removeClass('BawlNoDisplay');	$('#BawlCustomInsertThatRun' + 7).removeClass('BawlNoDisplay');	$('#BawlCustomInsertThatRun' + 8).removeClass('BawlNoDisplay');	$('#BawlCustomInsertThatRun' + 9).removeClass('BawlNoDisplay') } } );	//this isn't very pretty but I'm not sure how else to solve it. You can't just call int because that'll be 10 by the time you press a button
						} else if ( int == 9 )	{ Bawl.customInsertThatRunTextInput[9].on('change', function() { if ( Bawl.customInsertThatRunTextInput[9].getValue() != '' ) { $('#BawlCustomInsertThatRun' + 10).removeClass('BawlNoDisplay');	$('#BawlCustomInsertThatRun' + 11).removeClass('BawlNoDisplay');	$('#BawlCustomInsertThatRun' + 12).removeClass('BawlNoDisplay');	$('#BawlCustomInsertThatRun' + 13).removeClass('BawlNoDisplay');	$('#BawlCustomInsertThatRun' + 14).removeClass('BawlNoDisplay') } } );
						} else if ( int == 14 )	{ Bawl.customInsertThatRunTextInput[14].on('change', function() { if ( Bawl.customInsertThatRunTextInput[14].getValue() != '' ) { $('#BawlCustomInsertThatRun' + 15).removeClass('BawlNoDisplay');	$('#BawlCustomInsertThatRun' + 16).removeClass('BawlNoDisplay');	$('#BawlCustomInsertThatRun' + 17).removeClass('BawlNoDisplay');	$('#BawlCustomInsertThatRun' + 18).removeClass('BawlNoDisplay');	$('#BawlCustomInsertThatRun' + 19).removeClass('BawlNoDisplay') } } );
						} else if ( int == 19 )	{ Bawl.customInsertThatRunTextInput[19].on('change', function() { if ( Bawl.customInsertThatRunTextInput[19].getValue() != '' ) { $('#BawlCustomInsertThatRun' + 20).removeClass('BawlNoDisplay');	$('#BawlCustomInsertThatRun' + 21).removeClass('BawlNoDisplay');	$('#BawlCustomInsertThatRun' + 22).removeClass('BawlNoDisplay');	$('#BawlCustomInsertThatRun' + 23).removeClass('BawlNoDisplay');	$('#BawlCustomInsertThatRun' + 24).removeClass('BawlNoDisplay') } } );
						} else if ( int == 24 )	{ Bawl.customInsertThatRunTextInput[24].on('change', function() { if ( Bawl.customInsertThatRunTextInput[24].getValue() != '' ) { $('#BawlCustomInsertThatRun' + 25).removeClass('BawlNoDisplay');	$('#BawlCustomInsertThatRun' + 26).removeClass('BawlNoDisplay');	$('#BawlCustomInsertThatRun' + 27).removeClass('BawlNoDisplay');	$('#BawlCustomInsertThatRun' + 28).removeClass('BawlNoDisplay');	$('#BawlCustomInsertThatRun' + 29).removeClass('BawlNoDisplay') } } );
						}
				$('#BawlPrefenableCIFieldLayout').append(Bawl.customInsertTextInput[int].$element);
				$('#BawlPrefenableCIThatRunFieldLayout').append(Bawl.customInsertThatRunTextInput[int].$element);
			} //end for loop
		}; //end function opensettings
			Bawl.UISettingsButton.on('click', Bawl.openSettings);
		} //end there is no reply form yet, create one
	}; //end Bawl.openReplyForm
	Bawl.timestampToTimeAsInSig = function(origTimestamp, timezone) { //convert timestamp like 2021-12-11T14:29:00.000Z to whatever is found in signatures.
		if ( origTimestamp.match(/^[0-9]*$/) ) { // timestamp consists of only numbers, indicating this is locator timestamp. locator timestamp don't require any kind of conversion
			return origTimestamp;
		}
		Bawl.origTimestamp = origTimestamp.replace(/Z.*/, 'Z'); // when the ID isn't unique numbers get added like data-mw-comment='{"type":"comment","level":10,"id":"c-Alexis_Jazz-2022-01-08T22:48:00.000Z-1989-2022-01-08T21:09:00.000Z","replies":["c-1989-2022-01-09T03:42:00.000Z-Alexis_Jazz-2022-01-08T22:48:00.000Z","c-1989-2022-01-09T03:42:00.000Z-Alexis_Jazz-2022-01-08T22:48:00.000Z-1"],"timestamp":"2022-01-08T22:48:00.000Z","author":"Alexis Jazz"}'
		if ( typeof timezone != 'undefined' ) {
			Bawl.targetTimezone = timezone;
		} else {
			Bawl.targetTimezone = Bawl.wikiTimezone;
		}
		Bawl.origTime = new Date(Bawl.origTimestamp).toLocaleString("en-GB", {timeZone: Bawl.targetTimezone});
		Bawl.monthName = Bawl.origTime.match(/[0-3][0-9]\/0?([1-9]?[0-9])\//)[1];
		Bawl.monthName = Bawl.monthNames[Bawl.monthName];
		return Bawl.origTime.replace(/(0?)([1-3]?)([0-9])\/([0-1][0-9])\/([0-9]{4}), (0?)([1-2]?)([0-9])\:(0?)([0-9]?)([0-9])\:[0-6][0-9]/, Bawl.timestampFormat).replace('MONTHNAME', Bawl.monthName);
	};
	Bawl.getSectionByNum = function(wikitext, num) {
		Bawl.dbg('get section #' + num);
		Bawl.sectionByNumSplit = '\n' + wikitext.replace(/(^|\n)\=/g, '$1==');
		Bawl.sectionByNumSplit = Bawl.sectionByNumSplit.split('\n=');
		if ( Bawl.sectionByNumSplit[num] ) {
			Bawl.sectionByNumHeaderLevel = Bawl.sectionByNumSplit[num].match(/^[\=]*/)[0].length;
			Bawl.sectionByNumFoundEnd = 0;
			Bawl.sectionByNumWikiText = Bawl.sectionByNumSplit[num];
			for (int = 0; int < Bawl.sectionByNumSplit.length; int++) {
				if ( int >= num && Bawl.sectionByNumSplit[int].match(/^[\=]*/)[0].length > Bawl.sectionByNumHeaderLevel && Bawl.sectionByNumFoundEnd == 0 ) {
					Bawl.sectionByNumWikiText = Bawl.sectionByNumWikiText + Bawl.sectionByNumSplit[int];
				} else if ( int >= num && Bawl.sectionByNumSplit[int].match(/^[\=]*/)[0].length <= Bawl.sectionByNumHeaderLevel ) {
					Bawl.sectionByNumFoundEnd = 1;
				}
			}
		return Bawl.sectionByNumWikiText.replace(/^\n*/, '').replace(/\n*$/, '');
		} else {
			return null;
		}
	};
	Bawl.repairWikiText = function(text) {
		Bawl.dbg('look for a time (like 12:00) followed by more than one newline followed by an indented message and reduce the number of newlines to one. Otherwise replies to the that first post will go right under that post which is strictly speaking correct behavior (which is why I refuse to correct THAT), but not desired. Also: fuck you DiscussionTools.');
		return text.replace(/([0-9]{1,2}:[0-5][0-9].*)[\n]{2,}([\\:\\*\\#])/g, '$1\n$2');
	};
	Bawl.repairTagImbalance = function(text) {
		Bawl.dbg('check for unbalanced \'\', \'\'\', <i>, <b>, <s> and <span> and return an appropriate set of closing tags.');
		if ( text && Bawl.replyLinkParamsOpened.type != 'edit' ) {
			Bawl.balancingTags = '';
			Bawl.balancingTextCleaned = text.replace(/\<nowiki\>[^]*\<\/nowiki\>/gm, '').replace(/\{\{([^\{\}]|[\{\}][^\{\}])*\}\}/gm, '').replace(/\{\{([^\{\}]|[\{\}][^\{\}])*\}\}/gm, '').replace(/\{\{([^\{\}]|[\{\}][^\{\}])*\}\}/gm, '').replace(/\{\{([^\{\}]|[\{\}][^\{\}])*\}\}/gm, '').replace(/\{\{([^\{\}]|[\{\}][^\{\}])*\}\}/gm, '');
			for (int = 0; int < 10; int++) { //removing complete tag combinations in the right order. times 10 to also catch nested tags
				Bawl.balancingTextCleaned = Bawl.balancingTextCleaned.replace(/\<(?![\/]?[bis]\>|[\/]?span( [^>]*)?)/g, '').replace(/\<span( [^\>]*)?\>([^\<]|\<[\/]?[bis]\>)*\<\/span\>/gmi, '$2').replace(/\<b( [^\>]*)?\>([^\<]*|\<[\/]?span[^\>]*\>|\<[\/]?[is]\>)*\<\/b\>/gmi, '$2').replace(/\<i( [^\>]*)?\>([^\<]*|\<[\/]?[bs]\>|\<[\/]?span[^\>]*\>)*\<\/i\>/gmi, '$2').replace(/\<s( [^\>]*)?\>([^\<]*|\<[\/]?[bi]\>|\<[\/]?span[^\>]*\>)*\<\/s\>/gmi, '$2');
			}
			Bawl.dbg('text that will be checked for unbalanced tags:\n' + Bawl.balancingTextCleaned);
			Bawl.balancingOperations = 0; //prevent infinite loops in case something is screwed up
			Bawl.balancingTextTwoSingleQuotes = Bawl.balancingTextCleaned.match(/(^|[^\'])\'\'($|[^\'])/g);
			if ( Bawl.balancingTextTwoSingleQuotes ) { Bawl.balancingTextTwoSingleQuotes = Bawl.balancingTextTwoSingleQuotes.length};
			Bawl.balancingTextThreeSingleQuotes = Bawl.balancingTextCleaned.match(/(^|[^\'])\'\'\'($|[^\'])/g);
			if ( Bawl.balancingTextThreeSingleQuotes ) { Bawl.balancingTextThreeSingleQuotes = Bawl.balancingTextThreeSingleQuotes.length};
			if ( Bawl.balancingTextTwoSingleQuotes / 2 != (Bawl.balancingTextTwoSingleQuotes / 2).toFixed() ) {
				Bawl.balancingOperations = Bawl.balancingOperations + 1;
				Bawl.dbg('adding closing \'\' tag (' + Bawl.balancingOperations + ' tags added)');
				Bawl.balancingTags = Bawl.balancingTags + '\'\'';
			}
			if ( Bawl.balancingTextThreeSingleQuotes / 2 != (Bawl.balancingTextTwoSingleQuotes / 2).toFixed() ) {
				Bawl.balancingOperations = Bawl.balancingOperations + 1;
				Bawl.dbg('adding closing \'\'\' tag (' + Bawl.balancingOperations + ' tags added)');
				Bawl.balancingTags = Bawl.balancingTags + '\'\'\'';
			}
			Bawl.balancingTextOpenSpan = Bawl.balancingTextCleaned.match(/\<span( [^\>]*)?\>/gi);
			Bawl.balancingTextOpenB = Bawl.balancingTextCleaned.match(/\<b( [^\>]*)?\>/gi);
			Bawl.balancingTextOpenI = Bawl.balancingTextCleaned.match(/\<i( [^\>]*)?\>/gi);
			Bawl.balancingTextOpenS = Bawl.balancingTextCleaned.match(/\<s( [^\>]*)?\>/gi);
			if ( Bawl.balancingTextOpenSpan ) { Bawl.balancingTextOpenSpan = Bawl.balancingTextOpenSpan.length};
			if ( Bawl.balancingTextOpenB ) { Bawl.balancingTextOpenB = Bawl.balancingTextOpenB.length};
			if ( Bawl.balancingTextOpenI ) { Bawl.balancingTextOpenI = Bawl.balancingTextOpenI.length};
			if ( Bawl.balancingTextOpenS ) { Bawl.balancingTextOpenS = Bawl.balancingTextOpenS.length};
			while ( Bawl.balancingOperations < 100 && 0+Bawl.balancingTextOpenSpan > 0 ) {
				Bawl.balancingOperations = Bawl.balancingOperations + 1;
				Bawl.dbg('adding closing span tag (' + Bawl.balancingOperations + ' tags added)');
				Bawl.balancingTextOpenSpan = Bawl.balancingTextOpenSpan - 1;
				Bawl.balancingTags = Bawl.balancingTags + '</span>';
			}
			while ( Bawl.balancingOperations < 100 && 0+Bawl.balancingTextOpenB > 0 ) {
				Bawl.balancingOperations = Bawl.balancingOperations + 1;
				Bawl.dbg('adding closing B tag (' + Bawl.balancingOperations + ' tags added)');
				Bawl.balancingTextOpenB = Bawl.balancingTextOpenB - 1;
				Bawl.balancingTags = Bawl.balancingTags + '</b>';
			}
			while ( Bawl.balancingOperations < 100 && 0+Bawl.balancingTextOpenI > 0 ) {
				Bawl.balancingOperations = Bawl.balancingOperations + 1;
				Bawl.dbg('adding closing I tag (' + Bawl.balancingOperations + ' tags added)');
				Bawl.balancingTextOpenI = Bawl.balancingTextOpenI - 1;
				Bawl.balancingTags = Bawl.balancingTags + '</i>';
			}
			while ( Bawl.balancingOperations < 100 && 0+Bawl.balancingTextOpenS > 0 ) {
				Bawl.balancingOperations = Bawl.balancingOperations + 1;
				Bawl.dbg('adding closing S tag (' + Bawl.balancingOperations + ' tags added)');
				Bawl.balancingTextOpenS = Bawl.balancingTextOpenS - 1;
				Bawl.balancingTags = Bawl.balancingTags + '</s>';
			}
			Bawl.dbg(Bawl.balancingOperations +	' balancing tags added');
			return Bawl.balancingTags;
		} else {
			Bawl.dbg('no text input to balance');
			return '';
		}
	};
	Bawl.postReply1 = function(replyLinkParams, newCommentsChecked) {
		Bawl.dbg('postReply1');
		if ( Bawl.UITextInputTitle.getValue() == '' && Bawl.UITextInputTitle.isVisible() ) {
			$('#BawlUITextInputTitle').removeClass('BawlShakeIt');
			var BawlShakeTitle = setInterval(function () {
					clearInterval(BawlShakeTitle);
					$('#BawlUITextInputTitle').addClass('BawlShakeIt');
					}, 20);
			Bawl.dbg('title is empty');
			return
		}
		Bawl.disableForm(true); //disable form so you can't double click
		$(document.getElementById('BawlUIReplyButton')).addClass('BawlPendingBlink');
		if ( Bawl.settings.checkNewComments == true || newCommentsChecked ) {
			Bawl.checkForNewComments(replyLinkParams, 'postreply');
			//return //kill it for now, Bawl.checkForNewComments() will call this function again with newCommentsChecked if there are no new comments. todo: actually make it do that
		}
		Bawl.dbg('get the wikitext of the page we want to add the comment to');
		Bawl.currentPageTextParams = {
			'action':'query',
			'export':'true',
			'titles': replyLinkParams.pageTitle,
			'prop':'revisions'
		}
		var currentPageText = new mw.Api();
		currentPageText.post(Bawl.currentPageTextParams).done(function(currentPageText)
			{
				Bawl.dbg(currentPageText);
				//should consider adding some error handling here, check currentPageText.warnings, currentPageText.error.code, etc
				if ( ! currentPageText.query.pages[-1] ) {
					Bawl.dbg('got wikitext');
					Bawl.justCurrentPageText = Bawl.repairWikiText(Bawl.getWikitextFromExport(currentPageText.query.export["*"]));
					Bawl.currentRevID = currentPageText.query.pages[ Object.keys(currentPageText.query.pages)[0] ].revisions[0].revid;
				} else {
					Bawl.dbg('response indicates this page doesn\'t exist');
					Bawl.justCurrentPageText = '';
					Bawl.currentRevID = 0;
				}
				Bawl.postReply2(Bawl.justCurrentPageText, replyLinkParams, Bawl.currentRevID);
			})
	}
	Bawl.postReply2 = function(justCurrentPageText, replyLinkParams, currentRevID) {
		Bawl.progressPlusOne();
		Bawl.dbg('postReply2, process comment and actually post it');
		if ( replyLinkParams.sectionTitle != "" ) {
			Bawl.postCommentSummarySectionLink = '[[#' + replyLinkParams.sectionTitle + '|→' + replyLinkParams.sectionTitle + ']]: ';
		} else {
			Bawl.postCommentSummarySectionLink = ''; //no section? no link
		}
		if ( replyLinkParams.type == 'comment' ) {
			Bawl.postCommentSummary = Bawl.postCommentSummarySectionLink + Bawl.wikiMsgs.postCommentSummaryPost.replace(/USER/g, Bawl.escapeReplacement(replyLinkParams.origReplyTo));
		} else if ( replyLinkParams.type == 'anonSectReply' ) {
			Bawl.postCommentSummary = Bawl.postCommentSummarySectionLink + Bawl.wikiMsgs.postCommentSummaryPost.replace(/USER/g, Bawl.escapeReplacement(replyLinkParams.sectionTitle));
		} else if ( replyLinkParams.subtype == 'BCL' ) {
			Bawl.postCommentSummary = Bawl.postCommentSummarySectionLink + Bawl.summaryCredit;
		} else if ( replyLinkParams.type == 'heading' ) {
			Bawl.postCommentSummary = Bawl.postCommentSummarySectionLink + Bawl.wikiMsgs.postSubsectionSummaryPost.replace(/SUBSECTION/g, Bawl.escapeReplacement(Bawl.UITextInputTitle.getValue()));
		} else if ( replyLinkParams.type == 'newsection' && replyLinkParams.summary ) {
			Bawl.dbg('insert InputBox provided summary');
			Bawl.postCommentSummary = Bawl.wikiMsgs.postCommentSummaryNewSection.replace('SUMMARY', ' / ' + replyLinkParams.summary).replace(/NEWSECTION/g, Bawl.escapeReplacement(Bawl.UITextInputTitle.getValue()));
		} else if ( replyLinkParams.type == 'newsection' ) {
			Bawl.postCommentSummary = Bawl.wikiMsgs.postCommentSummaryNewSection.replace('SUMMARY', '').replace(/NEWSECTION/g, Bawl.escapeReplacement(Bawl.UITextInputTitle.getValue()));
		} else if ( replyLinkParams.type == 'edit' ) {
			Bawl.postCommentSummary = Bawl.postCommentSummarySectionLink + Bawl.wikiMsgs.editCommentSummary;
		}
		Bawl.origCmtLevel = replyLinkParams.origLevel;
		Bawl.origCmtLevelPlusOne = Bawl.origCmtLevel + 1;
		Bawl.dbg('replyLinkParams:');
		Bawl.dbg(replyLinkParams);
		Bawl.origTimeAsInSig = Bawl.timestampToTimeAsInSig(replyLinkParams.origTimestamp);
		if ( replyLinkParams.origTimestamp2 && replyLinkParams.origTimestamp2 != "" ) {
			Bawl.origTimeAsInSig2 = Bawl.timestampToTimeAsInSig(replyLinkParams.origTimestamp2);
		} else {
			Bawl.origTimeAsInSig2 = 'NO-VALUE-PLEASE-IGNORE';
		}
		Bawl.origReplyTo = Bawl.escapeRegExp(replyLinkParams.origReplyTo).replace(/ /g, '[_ ]'); //some users sign with [[User:User_Name]], others with [[User:User Name]]
		Bawl.origReplyTo2 = Bawl.escapeRegExp(replyLinkParams.origReplyTo2).replace(/_/g, '[_ ]');
		Bawl.returnOriginalMessageIndentRegExp2 = new RegExp('(' + Bawl.origReplyTo2 + '.{0,255}' + Bawl.origTimeAsInSig2 + '.*)((\n[\\:\\*\\#]{' + Bawl.origCmtLevel + ',50}([^\:\*\#]|[$]).*){0,15})(\n[\\:\\*\\#]{' + Bawl.origCmtLevel + '})(.*' + Bawl.origReplyTo + '.{0,255}' + Bawl.origTimeAsInSig + '.*)((\n*[\\:\\*\\#]{' + Bawl.origCmtLevelPlusOne + ',50}.*)*)', 'm');
		if ( Bawl.origCmtLevel == 0 ) { // fully select stuff like "foo bar ~~~~\nalmost forgot foo ~~~~\nand don't forget bar ~~~~" for which DiscussionTools takes data from the FIRST signature but puts the reply-link after the last signature (just brilliant!)
			Bawl.dbg('using special RegExp for unindented comments to catch ugly markup');
			Bawl.returnOriginalMessageIndentRegExp = new RegExp('()^()([^\\:\\*\\#].*' + Bawl.origReplyTo + '.{0,255}' + Bawl.origTimeAsInSig + '.*)+((\n[^\\:\\*\\#\\=\n].*)*(\n[\\:\\*\\#]{' + Bawl.origCmtLevelPlusOne + ',}([^\:\*\#]|[$]).*)*)', 'm');
		} else {
			Bawl.returnOriginalMessageIndentRegExp = new RegExp('()^([\\:\\*\\#]{' + Bawl.origCmtLevel + '})([^\:\*\#\=].*' + Bawl.origReplyTo + '.{0,255}' + Bawl.origTimeAsInSig + '.*)+((\n[\\:\\*\\#]{' + Bawl.origCmtLevelPlusOne + ',}([^\\:\\*\\#\\=]|[$]).*)*)', 'm');
		}
		Bawl.dbg('check if the post we\'re replying to can be found..');
		Bawl.stopwatch1 = new Date().getTime();
		Bawl.justCurrentPageTextMatch = justCurrentPageText.match(Bawl.returnOriginalMessageIndentRegExp);
		Bawl.stopwatch2 = new Date().getTime();
		Bawl.stopwatch3 = Bawl.stopwatch2 - Bawl.stopwatch1;
		Bawl.dbg('took ' + Bawl.stopwatch3 + 'ms');
		if ( Bawl.stopwatch3 > 200 ) {
			Bawl.errorReport = new Date().toLocaleString("en-GB", {timeZone: 'UTC'}) + ' (UTC) Regular expression 1 took longer than expected (probably not a fatal error) (RegExp 1: ' + Bawl.returnOriginalMessageIndentRegExp + ', RegExp 2: ' + Bawl.returnOriginalMessageIndentRegExp2 + ' Page: ' + replyLinkParams.pageTitle;
			Bawl.addScrewedLink(Bawl.errorReport);
		}
		Bawl.dbg('check if the post we\'re replying to AND the post they replied to can be found..');
		Bawl.stopwatch1 = new Date().getTime();
		Bawl.justCurrentPageTextMatch2 = justCurrentPageText.match(Bawl.returnOriginalMessageIndentRegExp2);
		Bawl.stopwatch2 = new Date().getTime();
		Bawl.stopwatch3 = Bawl.stopwatch2 - Bawl.stopwatch1;
		Bawl.dbg('took ' + Bawl.stopwatch3 + 'ms');
		if ( Bawl.stopwatch3 > 2000 ) {
			Bawl.errorReport = new Date().toLocaleString("en-GB", {timeZone: 'UTC'}) + ' (UTC) Regular expression 2 took longer than expected (probably not a fatal error) (RegExp 1: ' + Bawl.returnOriginalMessageIndentRegExp + ', RegExp 2: ' + Bawl.returnOriginalMessageIndentRegExp2 + ' Page: ' + replyLinkParams.pageTitle;
			Bawl.addScrewedLink(Bawl.errorReport);
		}
		Bawl.progressPlusOne();
		if ( Bawl.trySectionEdit == true && replyLinkParams.type == 'comment' && replyLinkParams.sectionnum ) {
			Bawl.dbg('checking if a section edit (which is faster) is an option');
			Bawl.sectionWikiTextByNum = Bawl.getSectionByNum(justCurrentPageText, replyLinkParams.sectionnum);
			if ( Bawl.sectionWikiTextByNum ) {
				Bawl.dbg('got section wikitext')
			};
				Bawl.sectionWikiTextByNumMatch = Bawl.sectionWikiTextByNum.match(Bawl.returnOriginalMessageIndentRegExp);
				Bawl.sectionWikiTextByNumMatch2 = Bawl.sectionWikiTextByNum.match(Bawl.returnOriginalMessageIndentRegExp2);
			if ( typeof Bawl.sectionWikiTextByNumMatch == null && typeof Bawl.sectionWikiTextByNumMatch2 == null ) {
				Bawl.dbg('section edit not possible');
				Bawl.trySectionEdit = false;
			}
		} else {
			Bawl.dbg('no good conditions for a section edit');
			Bawl.trySectionEdit = false;
			delete Bawl.sectionWikiTextByNum;
			delete Bawl.sectionWikiTextByNumMatch;
			delete Bawl.sectionWikiTextByNumMatch2;
		}
		if ( Bawl.trySectionEdit == true && replyLinkParams.type != 'newsection' ) {
			justCurrentPageText = Bawl.sectionWikiTextByNum + '\n';
		}
		if ( replyLinkParams.origTimestamp.match(/^[0-9]*$/) && replyLinkParams.origReplyTo != 'anonSectReply' ) {
			Bawl.dbg('Bawl locator doesn\'t record indentation levels, find indentation');
			Bawl.origMessageIndentLocatorRegExp = new RegExp('(^|\n)([\\:\\*\\#]*).*' + Bawl.escapeRegExp(encodeURIComponent(replyLinkParams.origReplyTo)) + '.*' + Bawl.escapeRegExp(replyLinkParams.origTimestamp) + '[^\n]*');
			Bawl.origMessageIndent = justCurrentPageText.match(Bawl.origMessageIndentLocatorRegExp)[2];
			Bawl.origCmtLevelPlusOne = Bawl.origMessageIndent.length + 1;
			Bawl.origMessageLocatorRegExp = new RegExp('(^|\n)([\\:\\*\\#]*).*' + Bawl.escapeRegExp(encodeURIComponent(replyLinkParams.origReplyTo)) + '.*' + Bawl.escapeRegExp(replyLinkParams.origTimestamp) + '[^\n]*((\n[\\:\\*\\#]{' + Bawl.origCmtLevelPlusOne + ',}([^\\:\\*\\#\\=]|[$]).*)*)');
			Bawl.relevantSectionPart = justCurrentPageText.match(Bawl.origMessageLocatorRegExp)[0];
		} else if ( replyLinkParams.origReplyTo == 'anonSectReply' ) {
			Bawl.origMessageIndent = '';
			Bawl.checkWikiTextForSectionTitleRegExp = new RegExp('(^|\n)=.*' + Bawl.escapeRegExp(replyLinkParams.sectionTitle) + '.*=.*');
			Bawl.checkWikiTextForSectionTextRegExp = new RegExp('(^|\n)=.*' + Bawl.escapeRegExp(replyLinkParams.sectionTitle) + '.*=.*(\n[^=].*)*');
			if ( Bawl.trySectionEdit == true && Bawl.sectionWikiTextByNum.match(Bawl.checkWikiTextForSectionTitleRegExp) ) {
				Bawl.dbg('anonSectReply, add section text to params');
				Bawl.relevantSectionPart = Bawl.sectionWikiTextByNum.match(Bawl.checkWikiTextForSectionTextRegExp)[0];
			} else if ( Bawl.trySectionEdit == false && justCurrentPageText.match(Bawl.checkWikiTextForSectionTitleRegExp).length == 1 ) {
				Bawl.dbg('anonSectReply, insert comment using whole page');
				Bawl.relevantSectionPart = justCurrentPageText.match(Bawl.checkWikiTextForSectionTextRegExp)[0];
			} else {
				Bawl.errorReport = new Date().toLocaleString("en-GB", {timeZone: 'UTC'}) + ' (UTC) Could not locate section "' + replyLinkParams.sectionTitle + '"to add comment to (anonSectReply) Page: ' + replyLinkParams.pageTitle;
				Bawl.addScrewedLink(Bawl.errorReport);
			}
		} else if ( Bawl.sectionWikiTextByNumMatch2 ) {
			Bawl.relevantSectionPart = justCurrentPageText.match(Bawl.returnOriginalMessageIndentRegExp2)[0];
			Bawl.origMessageIndent = Bawl.sectionWikiTextByNum.match(Bawl.returnOriginalMessageIndentRegExp2)[5].slice(1,);
			Bawl.dbg('attempting section edit, we know who we\'re replying to and who they replied to. Indentation of original message: "' + Bawl.origMessageIndent + '"');
		} else if ( Bawl.sectionWikiTextByNumMatch ) {
			Bawl.relevantSectionPart = justCurrentPageText.match(Bawl.returnOriginalMessageIndentRegExp)[0];
			Bawl.origMessageIndent = Bawl.sectionWikiTextByNum.match(Bawl.returnOriginalMessageIndentRegExp)[2];
			Bawl.dbg('attempting section edit, we know who we\'re replying to BUT NOT who they replied to. Indentation of original message: "' + Bawl.origMessageIndent + '"');
		} else if ( Bawl.justCurrentPageTextMatch2 ) { //looks like we know not only who we're replying to but also who they replied to, use both to determine insertion point
			Bawl.relevantSectionPart = justCurrentPageText.match(Bawl.returnOriginalMessageIndentRegExp2)[0];
			Bawl.origMessageIndent = justCurrentPageText.match(Bawl.returnOriginalMessageIndentRegExp2)[5].slice(1,);
			Bawl.dbg('we know who we\'re replying to and who they replied to. Indentation of original message: "' + Bawl.origMessageIndent + '"');
		} else if ( Bawl.justCurrentPageTextMatch ) { //fallback to just using who we are replying to
			Bawl.relevantSectionPart = justCurrentPageText.match(Bawl.returnOriginalMessageIndentRegExp)[0];
			Bawl.origMessageIndent = justCurrentPageText.match(Bawl.returnOriginalMessageIndentRegExp)[2];
			Bawl.dbg('we know who we\'re replying to BUT NOT who they replied to. Indentation of original message: "' + Bawl.origMessageIndent + '"');
		} else if ( replyLinkParams.origReplyTo == 'NO-VALUE-PLEASE-IGNORE' && replyLinkParams.type == 'heading' ) {
			Bawl.dbg('creating new subsection in section without timestamp');
			Bawl.origMessageIndent = '';
		} else if ( replyLinkParams.type != 'newsection' && replyLinkParams.type != 'heading' && ! replyLinkParams.origTimestamp.match(/^[0-9]*$/) ) { //maybe try adding to the bottom of the section instead? not sure
			Bawl.dbg('insertion point not found');
			Bawl.errorReport = new Date().toLocaleString("en-GB", {timeZone: 'UTC'}) + ' (UTC) insertion point not found (RegExp 1: ' + Bawl.returnOriginalMessageIndentRegExp + ', RegExp 2: ' + Bawl.returnOriginalMessageIndentRegExp2 + ' Page: ' + replyLinkParams.pageTitle;
			Bawl.addScrewedLink(Bawl.errorReport);
			Bawl.origMessageIndent = '';
		}
		Bawl.progressPlusOne();
		Bawl.dbg('original indentation: "' + Bawl.origMessageIndent + '"');
		if ( replyLinkParams.type != 'newsection' ) {
			Bawl.dbg('Find section in wikitext');
			Bawl.headingLevelPlusOne = replyLinkParams.headingLevel + 1;
			Bawl.headingLevelInsertionPoint = replyLinkParams.headingLevel;
			Bawl.justCurrentPageTextSectionRegExp = new RegExp('(^[\=]{' + Bawl.headingLevelInsertionPoint + '}.*' + Bawl.escapeRegExp(replyLinkParams.sectionTitle) + '.*[\=]{' + Bawl.headingLevelInsertionPoint + '}[ ]*)(((\n[^\=\n]{1}.*|\n[\=]{' + Bawl.headingLevelPlusOne + '}.*|\n))*)(.*' + Bawl.origReplyTo + '.*' + Bawl.origTimeAsInSig + '.*)(((\n[^\=\n]{1}.*|\n[\=]{' + Bawl.headingLevelPlusOne + '}.*|\n))*)', 'm');
			Bawl.justCurrentPageTextSectionMatch = justCurrentPageText.match(Bawl.justCurrentPageTextSectionRegExp);
			if ( Bawl.justCurrentPageTextSectionMatch ) { // found section with username+timestamp in it
				Bawl.justCurrentPageTextSection = Bawl.justCurrentPageTextSectionMatch[0];
				Bawl.dbg('Wikitext section, including user and timestamp:\n' + Bawl.justCurrentPageTextSection);
			} else { //try to find a section with this name regardless of timestamps contained within. section might be empty
				Bawl.justCurrentPageTextSectionRegExpAnon = new RegExp('(^[\=]{' + Bawl.headingLevelInsertionPoint + '}.*' + Bawl.escapeRegExp(replyLinkParams.sectionTitle) + '.*[\=]{' + Bawl.headingLevelInsertionPoint + '}[ ]*)(((\n[^\=\n]{1}.*|\n[\=]{' + Bawl.headingLevelPlusOne + '}.*|\n))*)', 'm');
				Bawl.justCurrentPageTextSectionMatchAnon = justCurrentPageText.match(Bawl.justCurrentPageTextSectionRegExpAnon);
				if ( Bawl.justCurrentPageTextSectionMatchAnon ) {
					Bawl.justCurrentPageTextSection = Bawl.justCurrentPageTextSectionMatchAnon[0];
					Bawl.dbg('Wikitext section, couldn\'t find user/timestamp:\n' + Bawl.justCurrentPageTextSection);
				} else {
					Bawl.dbg('could not locate section in wikitext. this is probably bad');
				}
			}
		}
		if ( Bawl.origMessageIndent == '' && replyLinkParams.type == 'comment' ) { //responding to an unindented comment
			Bawl.dbg('respond to unindented comment');
			//if that's no success, use the full page
			//find # of ^\#[^\#:\*], ^:[^\#:\*] and ^\*[^\#:\*], if * >= : && * <= # do *, if : >= * && : <= # do :, if # >= * || # >= : do #
			Bawl.mostPopularIndent = function(text, textType) {
				if ( text ) {
					Bawl.dbg('find the most popular indentation type (' + textType + ')');
					if ( text.match(/^\#/gm) ) { Bawl.countHashtags = text.match(/^\#/gm).length } else { Bawl.countHashtags = 0 }
					if ( text.match(/^:/gm) ) { Bawl.countColons = text.match(/^:/gm).length } else { Bawl.countColons = 0 }
					if ( text.match(/^\*/gm) ) { Bawl.countAsterisks = text.match(/^\*/gm).length } else { Bawl.countAsterisks = 0 }
					Bawl.countCombined = Bawl.countHashtags + Bawl.countColons + Bawl.countAsterisks;
					Bawl.dbg('total: ' + Bawl.countCombined + ', hashtags: ' + Bawl.countHashtags + ', colons: ' + Bawl.countColons + ', asterisks: ' + Bawl.countAsterisks);
					if ( Bawl.countAsterisks >= Bawl.countColons && Bawl.countAsterisks >= Bawl.countHashtags && Bawl.countCombined > 0 ) {
						Bawl.dbg('the asterisks have it (' + textType + ')');
						return '*';
					} else if ( Bawl.countColons >= Bawl.countAsterisks && Bawl.countColons >= Bawl.countHashtags && Bawl.countCombined > 0 ) {
						Bawl.dbg('the colons have it (' + textType + ')');
						return ':';
					} else if ( Bawl.countHashtags > Bawl.countColons || Bawl.countHashtags > Bawl.countAsterisks && Bawl.countCombined > 0 ) {
						Bawl.dbg('the hashtags have it (' + textType + ')');
						return '#';
					} else {
						Bawl.dbg('no indentation (' + textType + ')');
						return '';
					}
				} else {
					return '';
				}
			}
			Bawl.mostPopularIndentInSection = Bawl.mostPopularIndent(Bawl.justCurrentPageTextSection, 'section');
			if ( Bawl.mostPopularIndentInSection != "" ) {
				Bawl.dbg('a most popular indendation for the section is known');
				Bawl.commentTextIndent = Bawl.mostPopularIndent(Bawl.justCurrentPageTextSection, 'section');
			} else {
				Bawl.mostPopularIndentInFullPage = Bawl.mostPopularIndent(justCurrentPageText, 'full page');
				if ( Bawl.mostPopularIndentInFullPage != "" ) {
					Bawl.dbg('a most popular indendation for the whole page is known (could not be determined for just the section)');
					Bawl.commentTextIndent = Bawl.mostPopularIndentInFullPage;
				} else {
					Bawl.dbg('a most popular indendation could not be determined');
					Bawl.commentTextIndent = Bawl.commentTextIndentWikiDefault;
				}
			}
		} else if ( replyLinkParams.type == 'comment' ) {
			Bawl.dbg('responding to indented comment');
			Bawl.commentTextIndent = Bawl.origMessageIndent + Bawl.origMessageIndent.slice(Bawl.origMessageIndent.length - 1, Bawl.origMessageIndent.length); //repeat the last character of the indentation of the previous message, so e.g. ::* becomes ::**
		}
		Bawl.processedCommentText = Bawl.UITextInput.getValue();
		if ( Bawl.settings.bbcode == true ) {
			Bawl.processedCommentText = Bawl.applyBBCode(Bawl.processedCommentText);
		}
		if ( Bawl.settings.markdown == true ) {
			Bawl.processedCommentText = Bawl.applyMarkdown(Bawl.processedCommentText);
		}
		if ( Bawl.settings.rewritun == true ) {
			Bawl.dbg('rewritun ur urlz');
			Bawl.processedCommentText = Bawl.rewritunUrUrlz(Bawl.processedCommentText);
		} else {
			Bawl.processedCommentText = Bawl.UITextInput.getValue();
		}
		if ( Bawl.settings.enableCIThatRun == true ) {
			Bawl.dbg('applying your regular expressions');
			Bawl.processedCommentText = Bawl.runCI(Bawl.processedCommentText);
		}
		Bawl.commentTextSigned = Bawl.addSignature(Bawl.processedCommentText);
		Bawl.dbg('replacing newlines with templates');
		Bawl.commentTextSignedOneLine = Bawl.convertToOneLineCmt(Bawl.commentTextSigned);
		if ( replyLinkParams.type == 'heading' && replyLinkParams.subtype != 'BCL' ) { //new subsection
			Bawl.subsectionHeader = '';
			while ( Bawl.subsectionHeader.length < 6 && Bawl.subsectionHeader.length <= replyLinkParams.headingLevel) {
				Bawl.subsectionHeader = Bawl.subsectionHeader + '=';
			}
			Bawl.commentTextIndent = '\n\n' + Bawl.subsectionHeader + ' ' + Bawl.UITextInputTitle.getValue() + ' ' + Bawl.subsectionHeader + '\n';
		} else if ( replyLinkParams.subtype == 'BCL' ) {
			if ( replyLinkParams.indentation && replyLinkParams.indentation.match(/^\#\:\*$/) ) {
				Bawl.commentTextIndent = replyLinkParams.indentation + ' ';
			} else {
				Bawl.commentTextIndent = '* ';
			}
		} else if ( replyLinkParams.type == 'newsection' ) { //new section
			Bawl.commentTextIndent = '';
		}
		Bawl.commentTextIndentedSigned = Bawl.commentTextIndent + Bawl.commentTextSignedOneLine;
		if ( replyLinkParams.type == 'comment' ) {
			Bawl.wikiTextWithComment = justCurrentPageText.replace(Bawl.relevantSectionPart, Bawl.relevantSectionPart + '\n' + Bawl.commentTextIndentedSigned);
		} else if ( replyLinkParams.type == 'heading' && replyLinkParams.subtype != 'BCL' ) { //new subsection, replace section with section+new subsection
			Bawl.sectionWithNewSubsection = Bawl.justCurrentPageTextSection + Bawl.commentTextIndentedSigned + '\n\n';
			Bawl.sectionWithNewSubsection2 = Bawl.sectionWithNewSubsection.replace(/\n\n\n/g, '\n\n').replace(/\n\n\n/g, '\n\n').replace(/\n\n\n/g, '\n\n');
			Bawl.wikiTextWithComment = justCurrentPageText.replace(Bawl.justCurrentPageTextSection, Bawl.sectionWithNewSubsection2);
		} else if ( replyLinkParams.type == 'edit' ) {
			Bawl.commentTextOneLine = Bawl.convertToOneLineCmt(Bawl.processedCommentText);
			Bawl.wikiTextForEditCommentWithSignRegExp = new RegExp(Bawl.escapeRegExp(Bawl.wikiTextForEditComment) + '(.*' + Bawl.escapeRegExp(Bawl.origTimeAsInSig) + ')');
			Bawl.wikiTextWithComment = justCurrentPageText.replace(Bawl.wikiTextForEditCommentWithSignRegExp, Bawl.commentTextOneLine + '$1');
		}
		if ( Bawl.wikiTextWithComment ) {
			Bawl.wikiTextWithComment = Bawl.wikiTextWithComment.replace(/^[\s]*/, '').replace(/[\s]*$/, ''); //removing leading and trailing whitespace/newlines
		}
		if ( Bawl.settings.sumSnippet == true && replyLinkParams.type == 'comment' && Bawl.commentTextIndentedSigned ) {
			Bawl.snippetForSummary = Bawl.commentTextIndentedSigned.replace(/\[\[[^:]*:([^\\|\]]*)\|?\]\]/g, '$1').replace(/\{\{[^\\|\\\}\\\{]*\|([^\\\}]*)(\|[^\}]*)*\}\}/g, '$1').replace(/\[\[[^\\|]*\\|([^\\]])+\\]\\]/g, '$1').replace(/'''/g, '').replace(/''/g, '').replace(/^[\\:\\*\\#]*/, '').replace(/ *\{\{BawlCmt.*/, '');
			if ( Bawl.snippetForSummary.length > 5 ) {
				Bawl.snippetForSummaryShort = Bawl.snippetForSummary;
				if ( Bawl.snippetForSummary.length > 50 ) {
					Bawl.snippetForSummaryShort = Bawl.snippetForSummary.slice(0,40) + '...';
				}
				Bawl.postCommentSummary = Bawl.postCommentSummarySectionLink + Bawl.wikiMsgs.postCommentSummaryPost.replace(/USER/g, Bawl.escapeReplacement(replyLinkParams.origReplyTo) + ': ' + Bawl.snippetForSummaryShort);
			}
		}
		if ( replyLinkParams.type == 'edit' ) { //WP:PINGFIX
			Bawl.dbg('getting usernames mentioned in this comment');
			Bawl.usernamesInEditedComment = Bawl.extractUsernames(Bawl.UITextInput.getValue());
			Bawl.usernamesInUneditedComment = Bawl.extractUsernames(Bawl.wikiTextForEditComment);
			Bawl.userMentionInSummary = '';
			for (int = 0; int < Bawl.usernamesInEditedComment.length; int++) {
				Bawl.dbg('checking ' + Bawl.usernamesInEditedComment[int]);
				if ( Bawl.usernamesInEditedComment[int] && Bawl.usernamesInUneditedComment.indexOf(Bawl.usernamesInEditedComment[int]) == -1 && ! Bawl.userMentionInSummary.match(Bawl.usernamesInEditedComment[int] + '\\|') ) {
					Bawl.userMentionInSummary = Bawl.userMentionInSummary + ', [[' + mw.config.get('wgFormattedNamespaces')[2] + ':' + Bawl.usernamesInEditedComment[int] + '|' + Bawl.usernamesInEditedComment[int] + ']]';
				}
			}
			if ( Bawl.userMentionInSummary ) {
				Bawl.postCommentSummary = Bawl.postCommentSummary.replace(Bawl.summaryCredit, ' (' + Bawl.userMentionInSummary.replace(/^, /, '') + ')' + Bawl.summaryCredit);
			}
		}
		Bawl.postCommentParams = {
			format: 'json',
			action: 'edit',
			title: replyLinkParams.pageTitle,
			nocreate: true,
			summary: Bawl.postCommentSummary,
			baserevid: currentRevID,
			text: Bawl.wikiTextWithComment + Bawl.repairTagImbalance(Bawl.commentTextIndentedSigned),
			watchlist: Bawl.settings.watchlist,
			watchlistexpiry: Bawl.settings.watchlistexpiry
		};
		if ( replyLinkParams.subtype == 'BCL' ) {
			Bawl.dbg('set appendtext for BCL');
			delete Bawl.postCommentParams.text;
			Bawl.postCommentParams.appendtext = '\n' + Bawl.commentTextIndentedSigned + Bawl.repairTagImbalance(Bawl.commentTextIndentedSigned);
			if ( replyLinkParams.type == 'heading' ) {
				Bawl.dbg('set sectionnum in params for BCL section edit');
				Bawl.postCommentParams.section = replyLinkParams.sectionnum;
			}
		} else if ( replyLinkParams.type == 'newsection' ) {
			Bawl.postCommentParams.sectiontitle = Bawl.UITextInputTitle.getValue();
			Bawl.postCommentParams.section = 'new';
			Bawl.postCommentParams.text = Bawl.commentTextIndentedSigned + Bawl.repairTagImbalance(Bawl.commentTextIndentedSigned);
			delete Bawl.postCommentParams.nocreate;
		}
		if ( replyLinkParams.minor == true ) {
			Bawl.dbg('adding InputBox specified minor flag');
			Bawl.postCommentParams.minor = true;
		}
		if ( Bawl.trySectionEdit == true ) {
			Bawl.dbg('set sectionnum for params');
			Bawl.postCommentParams.section = replyLinkParams.sectionnum;
		}
		Bawl.progressPlusOne();
		if ( justCurrentPageText != Bawl.wikiTextWithComment || Bawl.postCommentParams.appendtext ) {
			if ( ! Bawl.postCommentParams.appendtext ) {
				Bawl.dbg('generated wikitext is different from the current wikitext, so it can be posted (without being a null edit). wikitext:\n' + Bawl.postCommentParams.text);
			}
			Bawl.dbg(Bawl.postCommentParams);
			if ( Bawl.dryRunOnce == true ) {
				Bawl.dryRunOnce = false;
				Bawl.dbg('dry run enabled, skipped API call');
				Bawl.disableForm(false); //re-enable form
				$(document.getElementById('BawlUIReplyButton')).removeClass('BawlPendingBlink');
			} else {
				Bawl.doAPICall(Bawl.postCommentParams);
				if ( Bawl.settings.afterPost == 'parsecomment' ) {
						delete Bawl.postedCommentParsed;
						Bawl.doPreview('previewposted');
				}
			}
		} else {
			Bawl.progressPlusOne();
			Bawl.dbg('couldn\'t insert comment, wikitext same as current text, possibly insertion point failure');
			Bawl.disableForm(false); //re-enable form
			$(document.getElementById('BawlUIReplyButton')).removeClass('BawlPendingBlink');
		}
	}; //end Bawl.postReply2
	Bawl.addReplyLinkTo = function(replyLinkParams) {
		if ( Bawl.settings.RLmasq == true && mw.config.get('wgUserLanguage') == 'pt' ) { //afaik reply-link only ever had a translation in Portuguese
			Bawl.svgBawlIcon = '<span style="color: #000"(</span><span style="color: #0645ad">responder</span><span style="color: #000">)</span>';
		} else if ( Bawl.settings.RLmasq == true ) {
			Bawl.svgBawlIcon = '<span style="color: #000">(</span><span style="color: #0645ad">reply</span><span style="color: #000">)</span>';
		}
		Bawl.replyLinkDebugInfo = '';
		if ( Bawl.settings.debug == true && int ) {
			Bawl.replyLinkDebugInfo = ' (' + int + ')';
			if ( ( replyLinkParams.type == 'comment' || replyLinkParams.type == 'edit' ) && replyLinkParams.origTimestamp.match(/^[0-9]*$/) ) { //Bawl locator
				Bawl.replyLinkDebugInfo = Bawl.replyLinkDebugInfo + ' (locator)';
			}
		}
		if ( replyLinkParams.type == 'comment' ) {
			Bawl.replyLinkText = '<span title="' + Bawl.msgs.replyToTitle.replace('USER', Bawl.escapeHTML(replyLinkParams.origReplyTo)) + Bawl.replyLinkDebugInfo + '" class="BawlReplyLinkIcon BawlReplyLink">' + Bawl.svgBawlIcon + '</span>';
		} else if ( replyLinkParams.type == 'heading' ) {
			Bawl.replyLinkText = '<span title="' + Bawl.msgs.newSectionTitle + Bawl.replyLinkDebugInfo + '" class="BawlReplyLinkIcon BawlReplyLink">' + Bawl.svgBawlIconNewSection + '</span>';
		}	else if ( replyLinkParams.type == 'edit' ) {
			Bawl.replyLinkText = '<span title="' + Bawl.msgs.editTitle + Bawl.replyLinkDebugInfo + '" class="BawlReplyLinkIcon BawlReplyLink">' + Bawl.svgBawlIconEdit + '</span>';
		}
		Bawl.replyLinkHTML = document.createElement('span');
		Bawl.replyLinkHTML.id = 'bawlLink-' + replyLinkParams.id
		Bawl.replyLinkHTML.innerHTML = '<a class="BawlReplyLink" onclick="Bawl.openReplyForm(\'' + encodeURIComponent(JSON.stringify(replyLinkParams)).replace(/\'/g, '%27') + '\')">' + Bawl.replyLinkText + '</a>';
		if ( replyLinkParams.type == 'comment' && Bawl.settings.dateLinksIcon == true ) {
			Bawl.dbg('try to add link to comment');
			Bawl.linkedSignaturedate = document.createElement('a');
			Bawl.linkedSignaturedate.href = '#' + encodeURIComponent(Bawl.replyLinkParams.id);
			Bawl.linkedSignaturedate.innerHTML = '&nbsp;&nbsp;&#x1F517;&nbsp;&nbsp;';
			Bawl.linkedSignaturedate.classList = [ 'BawlReplyLink' ];
			Bawl.replyLinkHTML.prepend(Bawl.linkedSignaturedate);
		}
		if ( ( replyLinkParams.type == 'comment' || replyLinkParams.type == 'edit' ) && replyLinkParams.origTimestamp.match(/^[0-9]*$/) ) { //Bawl locator
			Bawl.dbg('insert link to add comment (using locator)');
			$('.bawlprocess')[int].append(Bawl.replyLinkHTML);
		} else if ( replyLinkParams.type == 'comment' ) {
			Bawl.dbg('insert link to add comment (' + int + ')');
			$('.bawlprocess')[int].prepend(Bawl.replyLinkHTML);
		} else if ( replyLinkParams.type == 'edit' ) {
			Bawl.dbg('insert link to edit comment (' + int + ')' + ' bawlLink-' + replyLinkParams.id);
			if ( replyLinkParams.preview == true ) {
				$('#Bawlpreviewlinks').append(Bawl.replyLinkHTML);
			} else {
				$('.bawlprocess')[int].append(Bawl.replyLinkHTML);
			}
		} else if ( replyLinkParams.type == 'heading' ) {
			Bawl.dbg('insert link to add subsection (' + int + ')');
			$('.bawlprocess')[int].append(Bawl.replyLinkHTML);
		}
		if ( Bawl.replyLinkParams.type == 'comment' && Bawl.replyLinkParams.origReplyTo == mw.config.get('wgUserName') && replyLinkParams.preview != true && Bawl.settings.editLinks == true ) { //wait, I know this fucker
			Bawl.dbg('add edit link');
			Bawl.replyLinkParams.type = 'edit';
			Bawl.addReplyLinkTo(Bawl.replyLinkParams);
		}
	};
	//adding classes to elements we can extract the page title to edit from (which we extract from the "edit" link next to the section header) and DiscussionTools replylink-buttons (which we extract metadata from and append Bawl to)
	//this allows us to cycle through both in one loop in the original order, so the right page title can be added to each Bawl reply link
	$(document.getElementsByClassName('mw-editsection')).addClass('bawlprocess');	//section edit link to extract the name of the page to be edited in case of transcluded discussions
	$(document.getElementsByClassName('ext-discussiontools-init-replylink-buttons')).addClass('bawlprocess'); //insertion of comment link and extraction of comment metadata
	$(document.getElementsByClassName('mw-headline')).addClass('bawlprocess'); // h3/h4 sections
	$(document.getElementsByClassName('BawlCmt')).addClass('bawlprocess'); // Bawl locators
	$(document.getElementsByClassName('commentbox')).addClass('bawlprocess'); // InputBox
	$(document.getElementsByClassName('Bawl-comment-link')).addClass('bawlprocess'); // Special Bawl-comment-link that either opens the reply form or points to a &withJS page to load Bawl
	Bawl.pageTitleToEdit = mw.config.get('wgPageName'); //in case the first comment comes before any section edit link we define the [[Page title]]
	Bawl.sectionTitle = ""; //same for the ==Section title==
	if ( Bawl.settings.nSecLink == true ) {
		Bawl.replyLinkParams = {
			'id':'newSectionForm',
			'type':'newsection',
			'pageTitle': mw.config.get('wgPageName'),
			'sectionTitle':'NO-VALUE-PLEASE-IGNORE',
			'origReplyTo':'NO-VALUE-PLEASE-IGNORE',
			'origTimestamp':'2000-01-01T00:00:00.000Z',
			'origReplyTo2':'NO-VALUE-PLEASE-IGNORE',
			'headingLevel': 0
		}
		//skin support: replying and new sections should work everywhere, new subsections (dealth with further down) should work on Vector, timeless, monobook and modern. Not on Minerva
		if ( (mw.config.get('skin') == 'vector' || mw.config.get('skin') == 'vector-2022') && typeof $('#ca-addsection')[0] != "undefined" ) {
			$('#ca-addsection')[0].outerHTML = $('#ca-addsection')[0].outerHTML + $('#ca-addsection')[0].outerHTML.replace('ca-addsection', 'ca-bawladdsection').replace(/href="[^"]*"/, 'onclick="Bawl.openReplyForm(\'' + encodeURIComponent(JSON.stringify(Bawl.replyLinkParams)).replace(/\'/g, '%27') + '\')"').replace('++', '+9').replace('accesskey="+"', 'accesskey="9"').replace(/<span>.*<\/span>/, '<span>' + Bawl.svgBawlIcon + '</span>');
		} else if ( mw.config.get('skin') == 'minerva' && typeof $('#ca-edit')[0] != "undefined" ) {
			$('#ca-edit')[0].outerHTML = $('#ca-edit')[0].outerHTML + $('#ca-edit')[0].outerHTML.replace('ca-edit', 'ca-bawladdsection').replace(/href="[^"]*"/, 'style="background-image: url(' + Bawl.svgBawlIconData + ');background-repeat: no-repeat" onclick="Bawl.openReplyForm(\'' + encodeURIComponent(JSON.stringify(Bawl.replyLinkParams)).replace(/\'/g, '%27') + '\')"').replace('++', '+9').replace('accesskey="+"', 'accesskey="9"').replace(/(\<a.*\>)([^\<]*)(\<\/a\>)/, '$1' + '$3').replace(/title="[^"]*"/, 'title="' + Bawl.msgs.BawlAddSectionToolbar + '"').replace('mw-ui-icon-wikimedia-edit-base20', '');
		} else if ( ( mw.config.get('skin') == 'modern' && typeof $('#ca-addsection')[0] != "undefined" ) || ( mw.config.get('skin') == 'monobook' && typeof $('#ca-addsection')[0] != "undefined" ) ) {
			$('#ca-addsection')[0].outerHTML = $('#ca-addsection')[0].outerHTML + $('#ca-addsection')[0].outerHTML.replace('ca-addsection', 'ca-bawladdsection').replace(/href="[^"]*"/, 'onclick="Bawl.openReplyForm(\'' + encodeURIComponent(JSON.stringify(Bawl.replyLinkParams)).replace(/\'/g, '%27') + '\')"').replace('++', '+9').replace('accesskey="+"', 'accesskey="9"').replace(/>New section</, '>Bawl!<');
		} else if ( mw.config.get('skin') == 'timeless' && typeof $('#ca-addsection')[0] != "undefined" ) {
			$('#ca-addsection')[0].outerHTML = $('#ca-addsection')[0].outerHTML + $('#ca-addsection')[0].outerHTML.replace('ca-addsection', 'ca-bawladdsection').replace(/href="[^"]*"/, 'onclick="Bawl.openReplyForm(\'' + encodeURIComponent(JSON.stringify(Bawl.replyLinkParams)).replace(/\'/g, '%27') + '\')"').replace('++', '+9').replace('accesskey="+"', 'accesskey="9"').replace(/<span>.*<\/span>/, '<span>' + Bawl.svgBawlIcon + '</span>');
		}
			$('#mw-content-text').append('<div id="bawlForm-newSectionForm" class="BawlNoDisplay BawlForm"><\/div>');
	}
	$('.ext-discussiontools-init-replylink-buttons').addClass('BawlYesDisplay');
	if ( Bawl.settings.hideThePain == true ) {
		$('.ext-discussiontools-init-replylink-bracket').addClass('BawlNoDisplay');
		$('.ext-discussiontools-init-replylink-reply').addClass('BawlNoDisplay');
		$('#ca-addsection').addClass('BawlNoDisplay');
	}
	Bawl.stopwatchAddLinks1 = new Date().getTime();
	for (int = 0; int < document.getElementsByClassName('bawlprocess').length; int++) {
		Bawl.dbg('Process element #' + int + '/' + (document.getElementsByClassName('bawlprocess').length - 1) + ' with "bawlprocess" class');
		if ( Bawl.replyToSectionLinkNeeded && Bawl.sectionNumberToEdit && ( ( typeof document.getElementsByClassName('bawlprocess')[int].className != "undefined" && document.getElementsByClassName('bawlprocess')[int].className.match('mw-headline') ) || ! document.getElementsByClassName('bawlprocess')[int+1] ) ) {
			Bawl.dbg('found a new section or the last element to be processed. adding reply to section link');
			Bawl.replyLinkParams = {
				'int': int,
				'type':'comment',
				'id':'anonSectReply:' + Bawl.pageTitleToEdit + ':' + Bawl.sectionNumberToEdit,
				'pageTitle': Bawl.pageTitleToEdit,
				'sectionTitle': Bawl.sectionTitle,
				'origReplyTo':'anonSectReply',
				'origTimestamp':'',
				'origLevel': 0,
				'origTimestamp2':'',
				'origReplyTo2':'',
				'headingLevel': 0,
				'sectionnum': Bawl.sectionNumberToEdit,
			}
			Bawl.replyToSectionButton = document.createElement('div');
			Bawl.replyToSectionButton.style = 'width:100%;margin-bottom:0.5em';
			Bawl.replyToSectionButton.id = Bawl.escapeHTML(Bawl.replyLinkParams.id);
			Bawl.replyToSectionButton.innerHTML = '<a onclick="Bawl.openReplyForm(\'' + encodeURIComponent(JSON.stringify(Bawl.replyLinkParams)) + '\')"><span class="BawlAnonSectReply">' + Bawl.svgBawlIcon + '</span></a>';
			if ( ! document.getElementsByClassName('bawlprocess')[int+1] ) {
				Bawl.dbg('last element to process, append link');
				Bawl.replyToSectionButton.style = 'width:8em;margin-top:0.5em';
				document.getElementById('mw-content-text').append(Bawl.replyToSectionButton);
			} else {
				Bawl.dbg('another section, prepend link');
				document.getElementsByClassName('bawlprocess')[int].parentElement.style = 'margin-top:0.5em'; //reduce the padding from the section element
				document.getElementsByClassName('bawlprocess')[int].prepend(Bawl.replyToSectionButton);
			}
		}
		if ( document.getElementsByClassName('bawlprocess')[int].childNodes[1] && typeof document.getElementsByClassName('bawlprocess')[int].childNodes[1].dataset != "undefined" && typeof document.getElementsByClassName('bawlprocess')[int].childNodes[1].dataset.mwComment != "undefined" ) { //time to cheat, extract metadata
				Bawl.dbg('found a comment to add a link to');
				Bawl.formDataset[int] = JSON.parse(document.getElementsByClassName('bawlprocess')[int].childNodes[1].dataset.mwComment);
				Bawl.origLevel = Bawl.formDataset[int].level - 1; // metadata considers an unindented message as level 1, first indent as 2, etc, but we need the number of indentation characters
				Bawl.getDataFromIdRegExp = new RegExp('^c-(.*)\-([0-9]{4}-[0-1][0-9]-[0-3][0-9]T[^-]*)-(.*)-([0-9]{4}-[0-1][0-9]-[0-3][0-9]T.*)'); //RegExp notes: $1 is the first username, $2 the first timestamp, $3 the second username, $4 the second timestamp
				if ( Bawl.formDataset[int].id.match( Bawl.getDataFromIdRegExp ) && Bawl.formDataset[int].id.match( Bawl.getDataFromIdRegExp ).length == 5 ) { //id contains data for the comment above the one we're replying to, this can help to find the insertion point in case of duplicated combinations of username+timestamp
					Bawl.dbg('id contains a second username');
					Bawl.origTimestamp2 = Bawl.formDataset[int].id.replace( Bawl.getDataFromIdRegExp, '$4' );
					Bawl.origReplyTo2 = Bawl.formDataset[int].id.replace( Bawl.getDataFromIdRegExp, '$3' );
				} else { // would happen if you reply to the intial post of a discussion
					Bawl.dbg('no second username found');
					Bawl.origTimestamp2 = '';
					Bawl.origReplyTo2 = '';
				}
				if ( Bawl.formDataset[int].type == "comment" ) { //only add a link to comments here
					Bawl.replyLinkParams = {
						'int': int,
						'type': Bawl.formDataset[int].type,
						'id': Bawl.formDataset[int].id.replace(/'/g, ''),
						'pageTitle': Bawl.pageTitleToEdit,
						'sectionTitle': Bawl.sectionTitle,
						'origReplyTo': Bawl.formDataset[int].author,
						'origTimestamp': Bawl.formDataset[int].timestamp,
						'origLevel': Bawl.origLevel,
						'origTimestamp2': Bawl.origTimestamp2,
						'origReplyTo2': Bawl.origReplyTo2,
						'headingLevel': Bawl.headingLevel, //used for section extraction
						'sectionnum': Bawl.sectionNumberToEdit,
					}
					if ( $('.bawlprocess')[int-1] && $('.bawlprocess')[int-1].classList && $('.bawlprocess')[int-1].classList[0] == 'BawlCmt' && decodeURIComponent($('.bawlprocess')[int-1].id.replace(/([^\:]*).*/, '$1')) == Bawl.replyLinkParams.origReplyTo && new Date(new Number($('.bawlprocess')[int-1].id.replace(/([^\:]*)\:([0-9]*).*/, '$2').replace(/[^0-9]*/g, ''))).toLocaleString("en-GB", {timeZone: 'UTC'}).slice(0,-3) == new Date(Bawl.formDataset[int].timestamp).toLocaleString("en-GB", {timeZone: 'UTC'}).slice(0,-3) ) {
						Bawl.dbg('previous element is a Bawl locator for the same username+timestamp combo, skipping');
					} else {
						Bawl.addReplyLinkTo(Bawl.replyLinkParams);
					}
					if ( Bawl.settings.dateLinks ==	true ) {
						Bawl.dbg('try to add link to comment');
						Bawl.signatureTimeStampToLink = Bawl.timestampToTimeAsInSig(Bawl.replyLinkParams.origTimestamp);
						if ( $('.bawlprocess')[int].parentElement && $('.bawlprocess')[int].parentElement.innerHTML.match(' ' + Bawl.signatureTimeStampToLink) ) { //the space ensures we can't accidentally alter the commentID instead which is mostly an issue for wikis that rely on the hh:mm fallback. But seriously: why aren't signature dates wrapped in their own tag? The hacks Enterprisey must have gone through..
							Bawl.linkedSignaturedate = document.createElement('a');
							Bawl.linkedSignaturedate.href = '#' + encodeURIComponent(Bawl.replyLinkParams.id);
							if ( Bawl.settings.dateLinks == true ) {
								if ( Bawl.settings.dateLinksLocalTime == true ) {
									Bawl.browserTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
									Bawl.browserTimeZoneDisplay = new Date().getTimezoneOffset() / 60;
									if (Bawl.browserTimeZoneDisplay >= 0 ) {
										Bawl.browserTimeZoneDisplay = 'UTC -' + Bawl.browserTimeZoneDisplay;
									} else {
										Bawl.browserTimeZoneDisplay = 'UTC +' + ( Bawl.browserTimeZoneDisplay * -1 );
									}
									Bawl.signatureTimeStampLocalTime = Bawl.timestampToTimeAsInSig(Bawl.replyLinkParams.origTimestamp, Bawl.browserTimeZone);
									Bawl.linkedSignaturedate.innerText = Bawl.signatureTimeStampLocalTime;
									Bawl.signatureTimeStampToLinkRegExp = new RegExp(' ' + Bawl.escapeRegExp(Bawl.signatureTimeStampToLink) + '([^\(]*)\\([^\)]*\\)');
									$('.bawlprocess')[int].parentElement.innerHTML = $('.bawlprocess')[int].parentElement.innerHTML.replace(Bawl.signatureTimeStampToLinkRegExp, ' ' + Bawl.linkedSignaturedate.outerHTML + '$1' + ' (' + Bawl.browserTimeZoneDisplay + ')');
								} else {
									Bawl.linkedSignaturedate.innerText = Bawl.signatureTimeStampToLink;
									$('.bawlprocess')[int].parentElement.innerHTML = $('.bawlprocess')[int].parentElement.innerHTML.replace(' ' + Bawl.signatureTimeStampToLink, ' ' + Bawl.linkedSignaturedate.outerHTML);
								}
								Bawl.dbg('linked signature date');
							}
							if ( Bawl.settings.dateLinksIcon ==	true ) {
								Bawl.linkedSignaturedate.innerHTML = '&#x1F517;';
								Bawl.linkedSignaturedate.classList = [ 'BawlReplyLink BawlReplyLinkIcon' ];
								$('.bawlprocess')[int].prepend(Bawl.linkedSignaturedate);
							}
						} else {
							Bawl.dbg('could not link signature date');
						}
					}
				}
		}	else if (typeof document.getElementsByClassName('bawlprocess')[int].childNodes != "undefined" && typeof document.getElementsByClassName('bawlprocess')[int].childNodes[1] == 'object' && typeof document.getElementsByClassName('bawlprocess')[int].childNodes[1].href != "undefined" && document.getElementsByClassName('bawlprocess')[int].className.match('mw-editsection') ) {	//edit section link, extract page title and section
			if ( Bawl.settings.replySecLink == true ) {
				Bawl.replyToSectionLinkNeeded = true;
			}
			Bawl.dbg('section link found, extract page title and section (' + int + ')');
			Bawl.pageTitleToEdit = decodeURIComponent(document.getElementsByClassName('bawlprocess')[int].childNodes[1].href.replace( /.*title=([^&]*).*/, '$1')).replace(/_/g, ' ');
			Bawl.sectionNumberToEdit = decodeURIComponent(document.getElementsByClassName('bawlprocess')[int].childNodes[1].href.replace( /.*section=(T\-)?([0-9]*).*/, '$2')).replace(/_/g, ' ').replace(/([^0-9]*)/g, '');
			if ( document.getElementsByClassName('bawlprocess')[int - 1] && typeof document.getElementsByClassName('bawlprocess')[int - 1].dataset != "undefined" && typeof document.getElementsByClassName('bawlprocess')[int - 1].dataset.mwComment == 'string' ) {
				Bawl.formDataset[int - 1] = JSON.parse(document.getElementsByClassName('bawlprocess')[int - 1].dataset.mwComment);
				if ( Bawl.formDataset[int - 1] && Bawl.formDataset[int - 1].type == "heading" ) {
					if ( document.getElementsByClassName('bawlprocess')[int - 1] && typeof document.getElementsByClassName('bawlprocess')[int - 1].dataset != "undefined" && typeof document.getElementsByClassName('bawlprocess')[int - 1].dataset.mwComment ) {
						Bawl.getDataFromIdRegExpHeading = new RegExp('^c-(.*)\-([0-9]{4}-[0-1][0-9]-[0-3][0-9]T[^-]*).*');
						//need to deal with sections which have no replies or timestamps
						if ( typeof Bawl.formDataset[int - 1].replies[0] == 'undefined' ) {
							Bawl.paramorigReplyTo = 'NO-VALUE-PLEASE-IGNORE';
							Bawl.paramorigTimestamp = '2000-01-01T00:00:00.000Z';
						} else {
							Bawl.paramorigReplyTo = Bawl.formDataset[int - 1].replies[0].replace(Bawl.getDataFromIdRegExpHeading, '$1');
							Bawl.paramorigTimestamp = Bawl.formDataset[int - 1].replies[0].replace(Bawl.getDataFromIdRegExpHeading, '$2');
						}
						Bawl.replyLinkParams = {
							'int': int,
							'id': Bawl.formDataset[int - 1].id,
							'type':'heading',
							'pageTitle': Bawl.pageTitleToEdit,
							'sectionTitle': Bawl.sectionTitle,
							'origReplyTo': Bawl.paramorigReplyTo,
							'origTimestamp': Bawl.paramorigTimestamp,
							'origReplyTo2':'NO-VALUE-PLEASE-IGNORE',
							'headingLevel': Bawl.formDataset[int - 1].headingLevel, //section extraction and determine the level for the new header
							'sectionnum': Bawl.sectionNumberToEdit,
						}
						Bawl.headingLevel = Bawl.replyLinkParams.headingLevel;
						if ( Bawl.settings.secLinks == true ) {
							Bawl.addReplyLinkTo(Bawl.replyLinkParams); //add link to create a new subsection
						}
					}
				}
			}
		} else if (typeof document.getElementsByClassName('bawlprocess')[int].className != "undefined" && document.getElementsByClassName('bawlprocess')[int].className.match('mw-headline') ) { //section header, extract section title
			Bawl.dbg('section header found, extract section title');
			Bawl.sectionTitle = document.getElementsByClassName('bawlprocess')[int].innerText;
		} else if ( $('.bawlprocess')[int].classList[0] == 'BawlCmt' ) { //locator
			Bawl.dbg('locator found');
			Bawl.locatorUsername = $('.bawlprocess')[int].id.replace(/(.*)\:([0-9]{13,14})\:([^\:]*).*/, '$1');
			Bawl.locatorTimestamp = $('.bawlprocess')[int].id.replace(/(.*)\:([0-9]{13,14})\:([^\:]*).*/, '$2');
			Bawl.locatorPageTitle = $('.bawlprocess')[int].id.replace(/(.*)\:([0-9]{13,14})\:([^\:]*).*/, '$3');
			Bawl.replyLinkParams = {
				'int': int,
				'type':'comment',
				'id': $('.bawlprocess')[int].id,
				'pageTitle': decodeURIComponent(Bawl.locatorPageTitle),
				'sectionTitle': Bawl.sectionTitle,
				'origReplyTo': decodeURIComponent(Bawl.locatorUsername),
				'origTimestamp': Bawl.locatorTimestamp,
				'origLevel': 0,
				'origTimestamp2':'',
				'origReplyTo2':'',
				'headingLevel': Bawl.headingLevel, //used for section extraction
				'sectionnum': Bawl.sectionNumberToEdit,
			}
			Bawl.addReplyLinkTo(Bawl.replyLinkParams);
		} else if ( $('.bawlprocess')[int].className && ( $('.bawlprocess')[int].className.match('commentbox') || $('.bawlprocess')[int].className.match('createbox') ) ) {
			Bawl.dbg('found InputBox');
			if ( Bawl.settings.inputBoxTO == true ) {
				Bawl.dbg('inputbox takeover enabled');
					Bawl.replyLinkParams = {
						'int': int,
						'id':'newSectionForm',
						'type':'newsection',
						'subtype':'InputBox',
						'pageTitle': mw.config.get('wgPageName'),
						'sectionTitle':'NO-VALUE-PLEASE-IGNORE',
						'origReplyTo':'NO-VALUE-PLEASE-IGNORE',
						'origTimestamp':'2000-01-01T00:00:00.000Z',
						'origReplyTo2':'NO-VALUE-PLEASE-IGNORE',
						'headingLevel': 0,
						'preloadparams': []
					}
					for (intInputBox = 0; intInputBox < $('.bawlprocess')[int].children.length; intInputBox++) {
						Bawl.dbg('process child element #' + intInputBox + '/' + $('.bawlprocess')[int].children.length + ' for element #' + int);
						if ( $('.bawlprocess')[int].children[intInputBox].name == 'preload' ) {
							Bawl.replyLinkParams.preload = $('.bawlprocess')[int].children[intInputBox].value;
						} else if ( $('.bawlprocess')[int].children[intInputBox].name == 'preloadparams[]' ) {
							Bawl.replyLinkParams.preloadparams.push($('.bawlprocess')[int].children[intInputBox].value);
						} else if ( $('.bawlprocess')[int].children[intInputBox].name == 'editintro' ) {
							Bawl.replyLinkParams.editIntro = $('.bawlprocess')[int].children[intInputBox].value;
						} else if ( $('.bawlprocess')[int].children[intInputBox].name == 'summary' ) {
							Bawl.replyLinkParams.summary = $('.bawlprocess')[int].children[intInputBox].value;
						} else if ( $('.bawlprocess')[int].children[intInputBox].name == 'minor' ) {
							Bawl.replyLinkParams.minor = $('.bawlprocess')[int].children[intInputBox].value;
						} else if ( $('.bawlprocess')[int].children[intInputBox].name == 'title' ) {
							Bawl.replyLinkParams.pageTitle = $('.bawlprocess')[int].children[intInputBox].value;
						} else if ( $('.bawlprocess')[int].children[intInputBox].name == 'preloadtitle' ) {
							Bawl.replyLinkParams.preloadtitle = $('.bawlprocess')[int].children[intInputBox].value;
						} else if ( $('.bawlprocess')[int].children[intInputBox].type == 'submit' ) {
							Bawl.dbg('sabotage submit, add our own onclick instead');
							$('.bawlprocess')[int].children[intInputBox].type = ''; //don't do whatever you normally do
							$('.bawlprocess')[int].children[intInputBox].outerHTML = $('.bawlprocess')[int].children[intInputBox].outerHTML.replace(/>$/, ' onclick="Bawl.openReplyForm(\'' + encodeURIComponent(JSON.stringify(Bawl.replyLinkParams)).replace(/\'/g, '%27') + '\')">');
						}
					}//for
			}//Bawl.settings.inputBoxTO == true
		} else if ( $('.bawlprocess')[int].className && $('.bawlprocess')[int].className.match('Bawl-comment-link') && $('.bawlprocess')[int].id && $('.bawlprocess')[int].id.match(/^\{(\"[a-z]*\":\"[^"]*\",)*\"[a-z]*\":\"[^"]*\"\}/) ) {
			Bawl.dbg('Bawl-comment-link found');
			Bawl.replyLinkParams = {
				'int': int,
				'id':'Bawl-comment-link',
				'type':'newsection',
				'subtype':'BCL',
				'pageTitle': mw.config.get('wgPageName'),
				'sectionTitle': Bawl.sectionTitle,
				'origReplyTo':'NO-VALUE-PLEASE-IGNORE',
				'origTimestamp':'2000-01-01T00:00:00.000Z',
				'origReplyTo2':'NO-VALUE-PLEASE-IGNORE',
				'headingLevel': 0,
				'sectionnum': Bawl.sectionNumberToEdit,
				'preloadparams': []
			}
			Bawl.commentLinkID = JSON.parse($('.bawlprocess')[int].id);
			if ( Bawl.commentLinkID.type == 'section' ) {
				Bawl.replyLinkParams.type = 'heading';
			}
			if ( Bawl.commentLinkID.page ) {
				Bawl.replyLinkParams.pageTitle = Bawl.commentLinkID.page;
			}
			if ( Bawl.commentLinkID.preload ) {
				Bawl.replyLinkParams.preload = Bawl.commentLinkID.preload;
			}
			if ( Bawl.commentLinkID.preloadparams ) {
				Bawl.replyLinkParams.preloadparams = Bawl.commentLinkID.preloadparams;
			}
			document.getElementsByClassName('bawlprocess')[int].innerHTML = document.getElementsByClassName('bawlprocess')[int].innerHTML.replace(/href=\"[^"]*\"/, 'onclick="Bawl.openReplyForm(\'' + encodeURIComponent(JSON.stringify(Bawl.replyLinkParams)).replace(/\'/g, '\\\'') + '\')"');
			Bawl.checkUrlForBawlformRegExp = new RegExp('withJS=.*Bawl(\-core)\.js.*Bawlform=' + Bawl.commentLinkID.id);
			if ( document.location.href.match(Bawl.checkUrlForBawlformRegExp) ) {
				Bawl.automaticallyOpenFormParams = $.extend( true, {}, Bawl.replyLinkParams ); // copy as = only creates a shortcut
				if ( Bawl.automaticallyOpenFormParams.preloadparams && Bawl.automaticallyOpenFormParams.preloadparams.length > 0 ) {
					Bawl.automaticallyOpenFormParams.preloadparams = JSON.parse(decodeURIComponent(Bawl.automaticallyOpenFormParams.preloadparams).replace(/\&quot\;/g, '"'));
				}
			}
		}
	} //end for
	Bawl.stopwatchAddLinks2 = new Date().getTime();
	Bawl.stopwatchAddLinks3 = Bawl.stopwatchAddLinks2 - Bawl.stopwatchAddLinks1;
	Bawl.dbg('adding links took ' + Bawl.stopwatchAddLinks3 + 'ms');
	//console.log('adding links took ' + Bawl.stopwatchAddLinks3 + 'ms');
	if ( Bawl.automaticallyOpenFormParams ) {
		Bawl.openReplyForm(Bawl.automaticallyOpenFormParams);
	}
	if ( mw.config.get('wgDiscussionToolsFeaturesEnabled') == null ) {
		//TODO fallback method to add links
	}
}
);
} else {
console.log('Bawl: this doesn\'t seem like an appropriate page to load Bawl on, but if it is, report it');
};
//</nowiki>