User:Alanl/CloseMerge.js

Source: 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.
// closecfd.js - written by [[User:Alanl]], modified from 
// [[Wikipedia:WikiProject User scripts/Scripts/CloseAFD.js]] by [[User:Johnleemk]] 

// and [[User:Lifebaka/closedrv.js]] by [[User:Lifebaka]]   

function automerge_result() 

{ 	

var close = prompt("Result of merge discussion?");	

var f = document.editform, t = f.wpTextbox1; 	
var title = mw.config.get('wgPageName');
t.value = t.value.split(' ==').join(' ==' + '\n' + '{{subst:' + 'Discussion top' + '|1=' + 'The result of this discussion was to' + '\'' + '\'' + '\'' + close + '\'' + '\'' + '\'' + '. ~~' + '~~' + '}}');
if (t.value.length > 0) {
t.value += '\n';
}
t.value += "{{subst:" + "Discussion bottom" + "}}";
t.value += '\n';
t.value += '{{Copied|from=OtherPage1' + '|from_oldid=' + '|to=' + title + '|diff=}}';
f.wpSummary.value += "Closing merge discussion; result was " + close; 

}  

 

function automerge_add_tabs() { 	

// Only add for pages with the right string somewhere in the title 	

if ((document.title.indexOf("Editing Talk:") != -1) && (document.title.indexOf("(section)") != -1)) 	

{ 		

mw.util.addPortletLink('p-cactions', 'javascript:automerge_result()', "merge close"); 	

} 

}   

addOnloadHook(automerge_add_tabs);