User:Dinoguy1000/scripts/amdelsort.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
Documentation for this user script can be added at User:Dinoguy1000/scripts/amdelsort. |
/***********************************************************************************
* *
* [[Help:Substitution|Substituted]] from [[Template:Deltab]], which *
* was apparently based on code by [[User:Raylu|Raylu]]. *
* *
* This script adds an "anime and manga deletion" tab to the bottom *
* of XfD pages when in edit mode. *
* *
* Generalization of this script is being attempted at *
* [[User:Dinoguy1000/delsort.js]] based on [[User:Pb30/Delsort tab/delsort.js]]. *
* *
***********************************************************************************/
// Does the main config struct exist?
if( typeof( dgDelSort ) == "undefined" ) {
dgDelSort = {};
}
/*
dgDelSort.summary (string)
customize the edit summary
*/
if( typeof( dgDelSort.summary ) == "undefined" ) {
dgDelSort.summary = "Tagged as an anime- and manga-related XfD discussion ([[User:Dinoguy1000/scripts/amdelsort.js|script-assisted]]).";
}
/*
dgDelSort.signatureDash (string)
customize the dash inserted before your signature, defaults to "-- "
*/
if( typeof( dgDelSort.signatureDash ) == "undefined" ) {
dgDelSort.signatureDash = "-- ";
}
/*
dgDelSort.markAsMinor (boolean)
mark the notification as a minor edit, defaults to true
*/
if( typeof( dgDelSort.markAsMinor ) == "undefined" ) {
dgDelSort.markAsMinor = true;
}
/*
dgDelSort.autoSubmit (boolean)
automatically save the edit after inserting the notification and edit summary, defaults to false
*/
if( typeof( dgDelSort.autoSubmit ) == "undefined" ) {
dgDelSort.autoSubmit = false;
}
var textToAdd = "\n\{\{subst:deletion sorting|Anime and manga|" + dgDelSort.signatureDash + "\~\~\~\~\}\}\n";
function addDelsortMessage() {
document.editform.wpTextbox1.value = document.editform.wpTextbox1.value.rtrim();
document.editform.wpTextbox1.value += textToAdd;
if( document.editform.wpSummary.value.length !== 0 ){ document.editform.wpSummary.value += ' | '; }
document.editform.wpSummary.value += dgDelSort.summary;
if( dgDelSort.markAsMinor ){ document.editform.wpMinoredit.checked = true; }
if( dgDelSort.autoSubmit ){ document.editform.submit(); }
}
$( function() {
if( mw.config.get( "wgNamespaceNumber" ) == 4 && mw.config.get( "wgTitle" ).match( / for d(elet|iscuss)ion/ ) && ( mw.config.get( "wgAction" ) == "edit" || mw.config.get( "wgAction" ) == "submit" ) ) {
mw.util.addPortletLink( "p-cactions", "javascript:addDelsortMessage()", "Anime and manga deletion", "ca-Anime_and_mangadeletion", "Anime and manga Deletion", "" );
}
});