User:Dust Filter/monobook.js

importScript('User:AzaToth/twinkle.js');

function removeElements { var argv = removeElements.arguments; var argc = argv.length; for ( i = 0; i < argc; i++ ) { var myNode = document.getElementById( argv[i] ); if ( myNode ) { myNode.parentNode.removeChild( myNode ); }   } } function appendMessage( sMessage, sSummary, bReplace, bPrepend, bMinor, bWatch, bSave ) { // puts a tag in a page var ed = document.editform; if ( bReplace == true ) { ed.wpTextbox1.value = sMessage; } else if ( bPrepend == true ) { ed.wpTextbox1.value = sMessage + "\n" + ed.wpTextbox1.value; } else { ed.wpTextbox1.value = ed.wpTextbox1.value + "\n" + sMessage; }   ed.wpSummary.value = sSummary; ed.wpMinoredit.checked = bMinor; ed.wpWatchthis.checked = bWatch; if ( bSave == true ) { ed.submit;        // save } else { ed.wpDiff.click;  // diff } } function doSandboxReset { // Resets the sandbox var msg = '{' + '{Please leave this line alone (sandbox ';   if ( wgNamespaceNumber == 5 ) {msg = msg + 'talk ';}    msg = msg + 'heading)}}' + "\n" + '<' + '!-- Hello! Feel free to try your formatting and editing skills below this line. As this page is for editing experiments, this page will automatically be cleaned every 12 hours. -->';   appendMessage( msg, 'Sweep Out the Sandbox', true, false, false, true, true ); } function doWelcomeMsg { var welcomemsg = '==Welcome==' + "\n" + '{' + '{subst:welcome}} ' + ''; if ( document.title.indexOf( 'Editing User talk:' ) != -1 ) { appendMessage( welcomemsg, 'Welcome to Wikipedia!', false, false, false, true, false ); } } function getAfDPageName( daysold ) { // link to today's AfD page (yyyy_mmmm_d) var months = new Array( 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' ); var date = new Date; date.setDate ( date.getDate - daysold ); var pagename = date.getUTCFullYear + '_' + months[date.getUTCMonth] + '_' + date.getUTCDate; return 'Wikipedia:Articles_for_deletion/Log/' + pagename; } function addMyPersonalLinks { // p-personal portal document.getElementById( 'pt-userpage' ).firstChild.innerHTML = wgUserName.toLowerCase; //document.getElementById( 'pt-mytalk' ).firstChild.innerHTML = 'my talk'; document.getElementById( 'pt-preferences' ).firstChild.innerHTML = 'preferences'; document.getElementById( 'pt-watchlist' ).firstChild.innerHTML = 'watchlist'; document.getElementById( 'pt-mycontris' ).firstChild.innerHTML = 'my contribs'; document.getElementById( 'pt-mycontris' ).getElementsByTagName('a')[0].href = '/w/index.php?title=Special:Contributions&target=' + wgUserName + '&limit=100'; document.getElementById( 'pt-logout' ).firstChild.innerHTML = 'logout'; addPortletLink( 'p-personal', '/w/index.php?title=Special:Log&user=' + wgUserName + '&limit=100', 'my logs', 'pt-mylogs', 'My user logs', '', document.getElementById( 'pt-logout' ) ); } function addMyNavLinks { // p-navigation portal addPortletLink( 'p-navigation', '/wiki/Wikipedia:Administrator intervention against vandalism#Alerts', 'AIV vandalism', 'n-linkaiv', 'Reports of vandalism' ); addPortletLink( 'p-navigation', '/wiki/Wikipedia:Requests for page protection#Current_requests_for_protection', 'RFPP', 'n-linkrfpp', 'Protection requests' ); addPortletLink( 'p-navigation', '/wiki/Category:Candidates for speedy deletion#Pages_in_category', 'Speedy', 'n-linkcsd', 'Candidates for speedy deletion' ); addPortletLink( 'p-navigation', '/wiki/' + getAfDPageName(0), 'Today\'s AfD', 'n-linktodaysafd', 'Today\'s AfD discussions' ); addPortletLink( 'p-navigation', '/wiki/' + getAfDPageName(5), 'Old AfD', 'n-linkoldafd', '5-day old AfD discussions' ); } function addMyActions { // c-actions portal // replace standard actions // history link if ( document.getElementById( 'ca-history' ) ) { document.getElementById( 'ca-history' ).getElementsByTagName('a')[0].href += '&limit=100'; }   if ( document.getElementById( 'ca-addsection' ) ) { document.getElementById( 'ca-addsection' ).firstChild.innerHTML = '+'; }   if ( document.getElementById( 'ca-talk' ) ) { document.getElementById( 'ca-talk' ).firstChild.innerHTML = 'talk'; }   if ( document.getElementById( 'ca-edit' ) ) { document.getElementById( 'ca-edit' ).firstChild.innerHTML = 'edit'; }   // prominent delete link if ( document.getElementById( 'ca-delete' ) ) { document.getElementById( 'ca-delete' ).firstChild.style.color = '#CC0000'; document.getElementById( 'ca-delete' ).firstChild.style.fontWeight = 'bold'; } //   // watchlist tabs if ( wgPageName == 'Special:Watchlist' ) { addPortletLink( 'p-cactions', '/w/index.php?title=Special:Log&limit=100', 'logs', 'ca-viewlog', 'Wikipedia logs', ,  ); addPortletLink( 'p-cactions', '/w/index.php?title=Special:Newpages&namespace=0&limit=100', 'new pages', 'ca-newpages', 'New pages', ,  ); addPortletLink( 'p-cactions', '/w/index.php?title=Special:Log&type=newusers&limit=150', 'new users', 'ca-newusers', 'New users', ,  ); addPortletLink( 'p-cactions', '/wiki/Template:Announcements/Community bulletin board', 'Wikinews', 'ca-wikinews', 'Wikipedia Community bulletin board', ,  ); }   // Sandbox if ( ( document.title.indexOf( 'Editing Wikipedia:Sandbox' ) != -1 ) || ( document.title.indexOf( 'Editing Wikipedia talk:Sandbox' ) != -1 ) ) { addPortletLink( 'p-cactions', 'javascript:doSandboxReset', 'Reset Sandbox', 'ca-sandboxreset', 'Reset Sandbox', ,  ); removeElements( 'ca-delete', 'ca-move', 'ca-protect', 'ca-unprotect' ) ; }   // editing user talk space if ( ( wgNamespaceNumber == 3 ) && ( document.title.indexOf( 'Editing User talk:' ) != -1 ) ) { removeElements( 'ca-delete', 'ca-addsection', 'ca-move', 'ca-watch', 'ca-unwatch', 'ca-protect', 'ca-unprotect' ) ; addPortletLink( 'p-cactions', 'javascript:doWelcomeMsg', 'welcome', 'ca-welcomemsg', 'Add a welcome message', ,  ); }   // user and user talk - show tab for user logs if ( ( wgNamespaceNumber == 2 ) || ( wgNamespaceNumber == 3 ) ) { var isip = wgTitle.split('/')[0].split('.'); if( isip[3] ) { addPortletLink( 'p-cactions', '/w/index.php?title=Special:Log&type=block&page=User:' + wgTitle.split('/')[0], 'block log', 'ca-blocklogs', 'View block logs for this IP address', ,  ); } else { addPortletLink( 'p-cactions', '/w/index.php?title=Special:Log&user=' + wgTitle.split('/')[0], 'user logs', 'ca-userlogs', 'View logs for this user', ,  ); }   }    // page logs tab if ( wgNamespaceNumber >= 0 ) { addPortletLink( 'p-cactions', '/w/index.php?title=Special:Log&page=' + wgPageName, 'logs', 'ca-logstab', 'View logs for this page', ,  ); } } addOnloadHook( function {   addMyPersonalLinks;    addMyNavLinks;    addMyActions; } );