Jump to content

User:Sreejithk2000/SpeedyF8.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.
//<source lang=javascript>
 
function SpeedyF8OK(){
	var needAppend=document.editform.wpTextbox1.value;
	document.editform.wpTextbox1.value = document.editform.wpTextbox1.value + "{" + "{db-commons} + "}";
 
	document.editform.wpSummary.value = 'Nominating for [[Wikipedia:Criteria for speedy deletion#F8]]';
	document.editform.wpMinoredit.checked = true;
 
	document.editform.submit();
} 
 
addOnloadHook(function(){
 
	var targets = getElementsByClassName(document, 'div', 'nowcommons-reviewme');
	if(targets.length === 0) return true; // NowCommons is not on this page, return the function.
 
	targets[0].style.textAlign = 'center'; // center the text
 
	var nominateF8 = wgScript+"?title="+encodeURIComponent(mw.config.get('wgPageName'))+"&action=edit&functionName=SpeedyF8OK";
 
	targets[0].innerHTML = '[<a href="'+nominateF8+'">Nominate F8</a>]';
	return true;
});
 
// Link/Button maker
function addFunction(functionNameString, buttonDisplayName, buttonID)
{ 
	var _href;
	if (wgAction=="edit")
        { 
		_href = "javascript:"+functionNameString+"();";
	} 
        else 
        {
		_href = wgScript+"?title="+encodeURIComponent(mw.config.get('wgPageName'))+"&action=edit&functionName="+functionNameString;
	}
 
	// Add buttons
	// addOnloadHook(function(){ mw.util.addPortletLink('p-cactions', _href, buttonDisplayName, 'ca-'+buttonID, '', null, 0); });
	// addOnloadHook(function(){ mw.util.addPortletLink('p-tb', _href, buttonDisplayName, 'tb-'+buttonID, '', null, 0); });

	var query = {
		'title': wgPageName,
		'action': 'edit',
		'SpeedyF8OK' : 'OK'
	};

        twAddPortletLink( mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/index.php?' + QueryString.create( query ), 'SpeedyF8', 'tw-SpeedyF8', 'Nominate for F8' );
}
 
// Fire it off:
addFunction("SpeedyDeleteF8", "F8 Delete", "F8Speedy");
 
//</source>