User:Rzuwig/scripts/quickek.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:Rzuwig/scripts/quickek. |
// QuickEK script by [[:pl:User:ChP94]]
// based on quickimgdelete.js script written by [[:en:User:Howcheng]]
// Released under the [http://www.gnu.org/licenses/gpl.txt GNU Public License (GPL)]
// <nowiki>
var quickEkGadget = {
version: 1,
autosave: true,
reasonPrompt: "Dlaczego uważasz, że ta strona powinna zostać usunięta?",
quickEkCaption: "Ekspresowe kasowanie",
quickEkTooltip: "Zgłoś artykuł do ekspresowego kasowania",
quickEkSummary: "[[Category:Candidates for speedy deletion" + "|sd]]",
quickEkTemplate: "{" + "{db|1=$1}}\n",
fastEkCaption: "Błyskawiczne kasowanie",
fastEkTooltip: "Zgłoś artykuł do ekspresowego kasowania bez podawania powodu",
fastEkSummary: "[[Category:Candidates for speedy deletion" + "|sd]]",
fastEkTemplate: "{" + "{db}}\n",
ekRegex: /\{\{(?:ek|delete)/,
errorMissingCookie: "Akcja QuickEk została przerwana, ponieważ nie odnaleziono ciasteczka z informacją potwierdzającą wykonanie operacji przez użytkownika",
quickEk: function() {
var reason = prompt( this.reasonPrompt, '' );
if ( ( reason ) && ( reason != "" ) ) {
var titleEncoded = encodeURIComponent( mw.config.get( 'wgPageName' ) );
var reasonEncoded = encodeURIComponent( reason );
jQuery.cookie( 'quickEkPage', mw.config.get( 'wgPageName' ), {
path: '/'
} );
window.location.href = mw.config.get( 'wgScript' ) + '?title=' + titleEncoded + '&action=edit&quickEkAction=quickek&reason=' + reasonEncoded;
}
},
fastEk: function() {
var titleEncoded = encodeURIComponent( mw.config.get( 'wgPageName' ) );
jQuery.cookie( 'quickEkPage', mw.config.get( 'wgPageName' ), {
path: '/'
} );
window.location.href = mw.config.get( 'wgScript' ) + '?title=' + titleEncoded + '&action=edit&quickEkAction=fastek';
},
init: function() {
if ( document.getElementById( 'ca-edit' ) == null ) { // not editable by non-admin
return;
}
mw.util.addPortletLink( 'p-tb', 'javascript:quickEkGadget.fastEk()', this.fastEkCaption, 'fast-ek', this.fastEkTooltip );
mw.util.addPortletLink( 'p-tb', 'javascript:quickEkGadget.quickEk()', this.quickEkCaption, 'quick-ek', this.quickEkTooltip );
var fakeaction = mw.util.getParamValue( 'quickEkAction' );
if ( fakeaction != null && document.editform ) {
// Protection against malicious links
var quickEkPage = jQuery.cookie( 'quickEkPage' );
if ( quickEkPage != mw.config.get( 'wgPageName' ) ) {
alert( this.errorMissingCookie );
return;
}
var content = document.editform.wpTextbox1.value;
if ( ( content == null ) || ( content == "" ) || ( content.match( this.ekRegex ) ) ) {
return;
}
if ( fakeaction == "quickek" ) {
var reason = decodeURIComponent( mw.util.getParamValue( 'reason' ) );
if ( ( reason == null ) || ( reason == "" ) ) {
return;
}
content = this.quickEkTemplate.replace( /\$1/, reason ) + content;
document.editform.wpTextbox1.value = content;
document.editform.wpSummary.value = this.quickEkSummary;
if ( this.autosave ) {
document.editform.wpSave.click();
}
} else if ( fakeaction == "fastek" ) {
content = this.fastEkTemplate + content;
document.editform.wpTextbox1.value = content;
document.editform.wpSummary.value = this.fastEkSummary;
if ( this.autosave ) {
document.editform.wpSave.click();
}
}
}
}
}
mw.loader.using( "mediawiki.util", function() {
jQuery( document ).ready( function() {
quickEkGadget.init();
} );
} );
//</nowiki>