Jump to content

User:Rutilant/Reply.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
//for easily and quickly replying talk comment
$(function() {
	headerLevel = 2;
	$( 'h' + headerLevel + ' span.mw-headline' ).each( function( i, val ) {
						var sectionName = $( this ).text();
						var editSectionUrl = $( this ).parent().find( '.mw-editsection a:first' ).attr( 'href' );
						var sectionReg = /&section=(.*)/;
						var sectionRaw = sectionReg.exec( editSectionUrl );
						if ( sectionRaw != null && sectionRaw[ 1 ].indexOf( 'T' ) < 0 ) {
							var sectionNumber = parseInt( sectionRaw[ 1 ] );
							if ( $( this ).parent().prop( 'tagName' ) === 'H' + headerLevel ) {
	$( this ).parent( 'h' + headerLevel ).append( ' <div style=" font-size: 0.6em;font-family:calibri; font-weight: bold;float: right;border-left:3px solid black"><a id="' + sectionName + '" class="replyLink" href="'+mw.config.get('wgServer') + mw.config.get('wgScript') + "?title=" + wgPageName+'&action=edit&replyit=yes&section='+sectionNumber+'">Reply</a></div>' );
							}}})});
if (location.href.indexOf("&action=edit&replyit=yes") == -1) return;
    statusRegExp = /&action=edit&replyit=yes&section=(.*)/;
  var sectionNumber = statusRegExp.exec(location.href)[1];
 if (sectionNumber != null && sectionNumber != ""){
    var result = prompt("Type your reply\n You don't need to leave four tildes.",":");
    //Sign
    result=result+" ~~"+"~~";;
      document.editform.wpTextbox1.value = document.editform.wpTextbox1.value+result;
            document.editform.wpSummary.value ="re";
      $('#wpDiff').click();
}else{
	alert("Error! Please refresh and try again.\n Invalid section number");
}