User:Cizagna/fastdelete.js

//See user page for more info. if(wgNamespaceNumber != -1 && !window.DeleteButtonsLoaded) addOnloadHook(addDeleteButtons) var DeleteButtonsLoaded = true; //prevent duplication

function addDeleteButtons { if(!window.fdButtons) return; var masterurl = wgScriptPath + '/index.php?title=' + escape(wgPageName) + '&action=delete&submitdelete=true&wpReason='; switch(skin) { case 'answers': /* pass to monobook */ case 'monaco': if(!document.getElementById('ca-delete')) { return; } for(var i=0;i<fdButtons.length;i++) { addPageBarlink(masterurl+ encodeURIComponent(fdButtons[i].summary),fdButtons[i].label,'control_delete'); }     break;

case 'quartz': if(!document.getElementById('ca-delete')) return for(var i=0;i<fdButtons.length;i++) { addArticleBarlink(masterurl+ encodeURIComponent(fdButtons[i].summary),fdButtons[i].label); }     break;

case 'chick': /* pass to monobook */ case 'simple': /* pass to monobook */ case 'myskin': /* pass to monobook */ case 'monobook': if(!document.getElementById('ca-delete')) return var url=document.getElementById('ca-delete').firstChild.href for(var i=0;i<fdButtons.length;i++) { if(fdButtons[i].hotkey) { addPortletLink('p-cactions', masterurl+ encodeURIComponent(fdButtons[i].summary),fdButtons[i].label,'ca-delete'+i,'one-click delete: '+fdButtons[i].summary,fdButtons[i].hotkey); } else { addPortletLink('p-cactions', masterurl+ encodeURIComponent(fdButtons[i].summary),fdButtons[i].label,'ca-delete'+i,'one-click delete: '+fdButtons[i].summary); }     }      break;

case 'wow': /* pass to slate */ case 'wookie': /* pass to slate */ case 'memalpha': /* pass to slate */ case 'smoke': /* pass to slate */ case 'slate': if(!document.getElementById('delete')) return for(var i=0;i<fdButtons.length;i++) { addMSBlink(masterurl+ encodeURIComponent(fdButtons[i].summary),fdButtons[i].label); }     break;

case 'classic': break; /* not supported yet */ case 'standard': break; /* not supported yet */ case 'cologneblue': break; /* not supported yet */ case 'nostalgia': break; /* not supported yet */ } }

addOnloadHook(checkdelete); function checkdelete { if(queryString('autoclose')=='true' && document.getElementById('deleteconfirm')) { document.getElementById('deleteconfirm').action += '&autoclose=now'; document.getElementById('deleteconfirm').target = '_top'; } if(queryString('submitdelete')=='true') { var btn = (document.getElementById('mw-filedelete-submit')) ? document.getElementById('mw-filedelete-submit') : document.getElementById('wpConfirmB') btn.click; } if(queryString('autoclose')=='now') { try { window.close; } catch(e) { // not a JS-created window. } } }

function queryString(p) { var re = RegExp('[&?]' + p + '=([^&]*)'); var matches; if (matches = re.exec(document.location)) { try { return decodeURI(matches[1]); } catch (e) { } }  return null; }

function addPageBarlink(url,text,id) { var pc = document.getElementById('page_controls'); if(pc.length < 1) { return;} var d = document.createElement('div'); var link = document.createElement('a'); link.href = url; link.appendChild(document.createTextNode(text)); var nuli = document.createElement('li'); nuli.id = id; nuli.appendChild(d); nuli.appendChild(link); pc.appendChild(nuli); }

function addArticleBarlink(url,text) { var ab = getElementsByClassName(document,'div','articleBar'); if(ab.length < 1) return; var obj = ab[0].getElementsByTagName('div')[0]; var link = document.createElement('a'); link.style.color = 'red'; link.href = url; link.appendChild(document.createTextNode(text)); obj.appendChild(link); }

function addMSBlink(url,text) { var msbs = document.getElementById('myStuffBar').getElementsByTagName('a')[0].parentNode; var link = document.createElement('a'); link.href = url; link.appendChild(document.createTextNode(text)); link.style.marginLeft = '10px'; link.style.color = 'red'; msbs.appendChild(link); }