User:BZPN/RfD.js: Difference between revisions

From Test Wiki
Jump to navigation Jump to search
Content deleted Content added
No edit summary
Tags: Mobile edit Mobile web edit
No edit summary
Tags: Mobile edit Mobile web edit
Line 17: Line 17:
openDeletionPopup();
openDeletionPopup();
};
};
}
}// === Wstaw ten fragment PRZED openDeletionPopup ===


// Dodanie zakładki Quick Delete do popupu
// Dodanie zakładki Quick Delete do popupu
function addQuickDeleteTab(popup) {
function addQuickDeleteTab(popup) {
const quickDeleteTab = $('<div>').attr('id', 'quick-delete-tab').css({
const quickDeleteTab = $('<div>').attr('id', 'quick-delete-tab').css({
'display': 'none' // Domyślnie ukryty
'display': 'none' // Domyślnie ukryty
}).appendTo(popup);
}).appendTo(popup);


$('<h3>').text('Quick Delete').css({
$('<h3>').text('Quick Delete').css({
'font-size': '18px',
'font-size': '18px',
'margin-bottom': '10px'
}).appendTo(quickDeleteTab);

$('<p>').html('Before proceeding with Quick Deletion, please read the <a href="/wiki/Template:QD" target="_blank">Template:QD</a> documentation and the <a href="/wiki/Wikipedia:Deletion_policy" target="_blank">Wikipedia Deletion Policy</a>.')
.css({
'font-size': '14px',
'margin-bottom': '10px'
'margin-bottom': '10px'
}).appendTo(quickDeleteTab);
}).appendTo(quickDeleteTab);


$('<p>').html('Before proceeding with Quick Deletion, please read the <a href="/wiki/Template:QD" target="_blank">Template:QD</a> documentation and the <a href="/wiki/Wikipedia:Deletion_policy" target="_blank">Wikipedia Deletion Policy</a>.')
const consentCheckbox = $('<input>').attr('type', 'checkbox').attr('id', 'consent-checkbox').css('margin-right', '10px');
.css({
const consentLabel = $('<label>').attr('for', 'consent-checkbox').text('I have read and understand the deletion policy.');
'font-size': '14px',
$('<div>').append(consentCheckbox).append(consentLabel).appendTo(quickDeleteTab);
'margin-bottom': '10px'
}).appendTo(quickDeleteTab);


const consentCheckbox = $('<input>').attr('type', 'checkbox').attr('id', 'consent-checkbox').css('margin-right', '10px');
$('<p>').text('Choose a reason for quick deletion from the list below:').css({
const consentLabel = $('<label>').attr('for', 'consent-checkbox').text('I have read and understand the deletion policy.');
'font-size': '14px',
$('<div>').append(consentCheckbox).append(consentLabel).appendTo(quickDeleteTab);
'margin-bottom': '10px'
}).appendTo(quickDeleteTab);


const quickDeleteSelect = $('<select>').attr('id', 'quick-delete-reason').css({
$('<p>').text('Choose a reason for quick deletion from the list below:').css({
'width': '100%',
'font-size': '14px',
'padding': '6px',
'margin-bottom': '10px'
'font-size': '14px',
}).appendTo(quickDeleteTab);
'margin-bottom': '10px'
}).appendTo(quickDeleteTab);


const quickDeleteSelect = $('<select>').attr('id', 'quick-delete-reason').css({
const reasons = [
{ value: 'A1', text: 'Little or no meaning' },
'width': '100%',
{ value: 'A2', text: 'No content' },
'padding': '6px',
{ value: 'A3', text: 'Article is transwikied' },
'font-size': '14px',
{ value: 'A4', text: 'Does not say why it is notable' },
'margin-bottom': '10px'
}).appendTo(quickDeleteTab);
{ value: 'A5', text: 'Not in English' },
{ value: 'A6', text: 'Hoax' }
];


const reasons = [
$.each(reasons, function(index, reason) {
{ value: 'A1', text: 'Little or no meaning' },
quickDeleteSelect.append($('<option>').attr('value', reason.value).text(reason.text));
{ value: 'A2', text: 'No content' },
});
{ value: 'A3', text: 'Article is transwikied' },
{ value: 'A4', text: 'Does not say why it is notable' },
{ value: 'A5', text: 'Not in English' },
{ value: 'A6', text: 'Hoax' }
];


$.each(reasons, function(index, reason) {
// Przycisk do szybkiego usunięcia
quickDeleteSelect.append($('<option>').attr('value', reason.value).text(reason.text));
$('<button>').text('Quick Delete').css({
'width': '100%',
});
'padding': '10px',
'background-color': '#d9534f',
'color': '#fff',
'border': 'none',
'border-radius': '5px',
'cursor': 'pointer',
'font-size': '16px'
}).on('click', function() {
const reason = quickDeleteSelect.val();
const consent = consentCheckbox.is(':checked');
if (reason && consent) {
tagPageForQuickDeletion(reason);
} else if (!consent) {
alert('Please confirm you have read the deletion policy.');
} else {
alert('Please choose a reason for quick deletion.');
}
}).appendTo(quickDeleteTab);
}


// Przycisk do szybkiego usunięcia
// === Koniec fragmentu PRZED openDeletionPopup ===
$('<button>').text('Quick Delete').css({
'width': '100%',
'padding': '10px',
'background-color': '#d9534f',
'color': '#fff',
'border': 'none',
'border-radius': '5px',
'cursor': 'pointer',
'font-size': '16px'
}).on('click', function() {
const reason = quickDeleteSelect.val();
const consent = consentCheckbox.is(':checked');
if (reason && consent) {
tagPageForQuickDeletion(reason);
} else if (!consent) {
alert('Please confirm you have read the deletion policy.');
} else {
alert('Please choose a reason for quick deletion.');
}
}).appendTo(quickDeleteTab);
}


// Tworzenie i otwarcie okna popup dla nominacji do usunięcia
// Tworzenie i otwarcie okna popup dla nominacji do usunięcia
Line 100: Line 98:
'height': '100%',
'height': '100%',
'background-color': 'rgba(0, 0, 0, 0.5)',
'background-color': 'rgba(0, 0, 0, 0.5)',
'z-index': '1000',
'z-index': '1000'
}).appendTo('body');
}).appendTo('body');


// Tworzenie okna popup
// Tworzenie okna popup
const popup = $('<div>').attr('id', 'deletion-popup').css({
const popup = $('<div>').attr('id', 'deletion-popup').css({
'width': '90%',
'position': 'fixed',
'max-width': '400px',
'top': '50%',
'margin': '10% auto',
'left': '50%',
'padding': '15px',
'transform': 'translate(-50%, -50%)',
'background-color': '#fff',
'background-color': '#fff',
'border-radius': '8px',
'padding': '20px',
'box-shadow': '0 4px 8px rgba(0, 0, 0, 0.2)',
'border': '1px solid #ddd',
'text-align': 'left',
'border-radius': '5px',
'position': 'relative'
'box-shadow': '0 0 10px rgba(0, 0, 0, 0.5)',
}).appendTo(overlay);
'z-index': '1001'
}).appendTo('body');
// === Wstaw ten fragment NA POCZĄTKU openDeletionPopup ===


// Dodanie zakładki Request for Deletion
// Dodaj przyciski do przełączania między zakładkami RfD i QD
const requestDeletionTab = $('<div>').attr('id', 'request-deletion-tab').appendTo(popup);
$('<div>').css({
'display': 'flex',
'justify-content': 'space-around',
'margin-bottom': '10px'
}).append(
$('<button>').text('Request for Deletion').css({
'flex': '1',
'padding': '6px',
'font-size': '14px',
'border': 'none',
'background-color': '#0073e6',
'color': '#fff',
'cursor': 'pointer'
}).on('click', function() {
$('#request-deletion-tab').show();
$('#quick-delete-tab').hide();
}),
$('<button>').text('Quick Delete').css({
'flex': '1',
'padding': '6px',
'font-size': '14px',
'border': 'none',
'background-color': '#d9534f',
'color': '#fff',
'cursor': 'pointer'
}).on('click', function() {
$('#quick-delete-tab').show();
$('#request-deletion-tab').hide();
})
).prependTo(popup);


$('<h3>').text('Request for Deletion').css({
// Dodaj zakładkę Quick Delete do popupu
addQuickDeleteTab(popup);

// === Koniec fragmentu NA POCZĄTKU openDeletionPopup ===
// Przycisk zamknięcia popup
$('<span>').text('×').css({
'position': 'absolute',
'top': '10px',
'right': '15px',
'cursor': 'pointer',
'font-size': '18px',
'font-weight': 'bold'
}).on('click', closeDeletionPopup).appendTo(popup);

// Tytuł okna
$('<h3>').text('Nominate for deletion').css({
'font-size': '18px',
'font-size': '18px',
'margin-bottom': '10px'
'margin-bottom': '10px'
}).appendTo(popup);
}).appendTo(requestDeletionTab);


$('<p>').html('Before proceeding with Request for Deletion, please read the <a href="/wiki/Wikipedia:Deletion_policy" target="_blank">Wikipedia Deletion Policy</a>.')
// Informacja o zasadach RfD
.css({
$('<p>').text('Before nominating, please read the deletion policy and guidelines on the Wikipedia:Requests for deletion page.').css({
'font-size': '14px',
'font-size': '14px',
'margin-bottom': '10px'
'margin-bottom': '10px'
}).appendTo(popup);
}).appendTo(requestDeletionTab);
$('<a>').attr('href', '/wiki/Wikipedia:Requests_for_deletion').text('Go to Wikipedia:Requests for deletion').css({
'font-size': '14px',
'color': '#0073e6',
'text-decoration': 'underline',
'display': 'block',
'margin-bottom': '10px'
}).appendTo(popup);


const reasonInput = $('<textarea>').attr('id', 'deletion-reason').css({
// Pole na krótki powód - poprawka do krawędzi dolnej
$('<label>').attr('for', 'deletion-short-reason').text('Short reason:').css({
'display': 'block',
'margin-top': '10px',
'font-size': '14px'
}).appendTo(popup);
const shortReasonInput = $('<input>').attr({
'type': 'text',
'id': 'deletion-short-reason',
'placeholder': 'Enter short reason...'
}).css({
'width': '100%',
'width': '100%',
'padding': '6px',
'height': '100px',
'margin': '5px 0',
'padding': '10px',
'font-size': '14px',
'font-size': '14px',
'box-sizing': 'border-box',
'line-height': '1.5', // poprawka dla dolnej krawędzi
}).appendTo(popup);

// Pole na szczegółowy powód
$('<label>').attr('for', 'deletion-detailed-reason').text('Detailed reason for discussion:').css({
'display': 'block',
'margin-top': '10px'
}).appendTo(popup);
const detailedReasonInput = $('<textarea>').attr({
'id': 'deletion-detailed-reason',
'placeholder': 'Detailed reason...'
}).css({
'width': '100%',
'padding': '6px',
'font-size': '14px',
'height': '80px',
'margin-bottom': '10px'
'margin-bottom': '10px'
}).appendTo(popup);
}).appendTo(requestDeletionTab);

// Checkbox potwierdzenia zapoznania się z polityką
const policyCheckbox = $('<input>').attr({
'type': 'checkbox',
'id': 'policy-confirmation'
}).css({
'margin-right': '5px'
});
const policyLabel = $('<label>').attr('for', 'policy-confirmation').text('I have read and understand the deletion policy.');
$('<div>').append(policyCheckbox, policyLabel).css({
'margin-bottom': '15px'
}).appendTo(popup);




// Przycisk wyślij
// Przycisk do nominacji do usunięcia
$('<button>').text('Submit nomination').css({
$('<button>').text('Nominate for Deletion').css({
'width': '100%',
'width': '100%',
'padding': '10px',
'padding': '10px',
'background-color': '#0073e6',
'background-color': '#337ab7',
'color': '#fff',
'color': '#fff',
'border': 'none',
'border': 'none',
Line 242: Line 148:
'font-size': '16px'
'font-size': '16px'
}).on('click', function() {
}).on('click', function() {
const shortReason = shortReasonInput.val().trim();
const reason = reasonInput.val();
const detailedReason = detailedReasonInput.val().trim();
if (reason) {
const policyConfirmed = policyCheckbox.is(':checked');
tagPageForDeletion(reason);
if (shortReason && detailedReason && policyConfirmed) {
initiateDeletionProcess(shortReason, detailedReason);
} else if (!policyConfirmed) {
alert('Please confirm you have read the deletion policy.');
} else {
} else {
alert('Please provide both a short and detailed reason.');
alert('Please enter a reason for deletion.');
}
}
}).appendTo(popup);
}).appendTo(requestDeletionTab);
}


// Dodanie zakładki Quick Delete
// Funkcja zamykająca popup
addQuickDeleteTab(popup);
function closeDeletionPopup() {
$('#deletion-popup-overlay').remove();
}


// Zamknięcie okna popup po kliknięciu poza nim
// Funkcja inicjująca proces usunięcia
overlay.on('click', function() {
function initiateDeletionProcess(shortReason, detailedReason) {
tagPageForDeletion(shortReason);
overlay.remove();
createDiscussionPage(detailedReason);
popup.remove();
addToDeletionList();
});
notifyPageCreator();
closeDeletionPopup();
}
}


// Funkcja do oznaczania strony do usunięcia
// Funkcja oznaczająca stronę do usunięcia
function tagPageForDeletion(reason) {
function tagPageForDeletion(reason) {
const tag = `{{rfd|${reason}}}`;
const tag = `{{db|${reason}}}`;
const editSummary = 'Nominating for deletion ([[User:BZPN/RfD.js|RfD]])';
const editSummary = 'Nominating for deletion ([[User :BZPN/RfD.js|RfD]])';


new mw.Api().postWithToken('csrf', {
new mw.Api().postWithToken('csrf', {
Line 287: Line 184:
}
}


// Funkcja do tworzenia strony dyskusji o usunięciu
// Funkcja tworząca stronę dyskusji o usunięciu
function createDiscussionPage(reason) {
function createDiscussionPage(reason) {
const discussionPageTitle = `Wikipedia:Requests for deletion/Requests/2024/${mw.config.get('wgPageName')}`;
const discussionPageTitle = `Wikipedia:Requests for deletion/Requests/2024/${mw.config.get('wgPageName')}`;
Line 296: Line 193:
title: discussionPageTitle,
title: discussionPageTitle,
text: discussionContent,
text: discussionContent,
summary: 'Starting deletion discussion ([[User:BZPN/RfD.js|RfD]])',
summary: 'Starting deletion discussion ([[User :BZPN/RfD.js|RfD]])',
watchlist: 'watch',
watchlist: 'watch',
}).done(function() {
}).done(function() {
Line 308: Line 205:
function addToDeletionList() {
function addToDeletionList() {
const deletionListTitle = 'Wikipedia:Requests for deletion/Current discussions';
const deletionListTitle = 'Wikipedia:Requests for deletion/Current discussions';
const discussionLink = `{{Wikipedia:Requests for deletion/Requests/2024/${mw.config.get('wgPageName')}}}`;
const discussionLink = `{{subst:Wikipedia:Requests for deletion/Requests/2024/${mw.config.get('wgPageName')}}}`;


new mw.Api().edit(deletionListTitle, function(revision) {
new mw.Api().edit(deletionListTitle, function(revision) {
return {
return {
text: discussionLink + '\n' + revision.content,
text: discussionLink + '\n' + revision.content,
summary: 'Adding new deletion discussion ([[User:BZPN/RfD.js|RfD]])',
summary: 'Adding new deletion discussion ([[User :BZPN/RfD.js|RfD]])',
watchlist: 'watch',
watchlist: 'watch',
};
};
Line 330: Line 227:
new mw.Api().postWithToken('csrf', {
new mw.Api().postWithToken('csrf', {
action: 'edit',
action: 'edit',
title: `User talk:${creator}`, appendtext: '\n' + notification,
title: `User talk:${creator}`,
summary: 'Notifying page creator about deletion nomination ([[User:BZPN/RfD.js|RfD]])',
appendtext: '\n' + notification,
summary: 'Notifying page creator about deletion nomination ([[User :BZPN/RfD.js|RfD]])',
watchlist: 'watch',
watchlist: 'watch',
}).done(function() {
}).done(function() {
alert('Page creator notified.');
alert('Page creator notified.');
}).fail(function() {
}).fail(function() {
alert('Failed to notify these page creator. Please try again.');
alert('Failed to notify the page creator. Please try again.');
});
});
}
}
}

// Funkcja oznaczająca stronę do szybkiego usunięcia
function tagPageForQuickDeletion(reason) {
const tag = `{{qd|${reason}}}`;
const editSummary = 'Nominating for quick deletion ([[User :BZPN/RfD.js|QD]])';

new mw.Api().postWithToken('csrf', {
action: 'edit',
title: mw.config.get('wgPageName'),
prependtext: tag + '\n',
summary: editSummary,
watchlist: 'watch',
}).done(function() {
alert('Page tagged for quick deletion.');
}).fail(function() {
alert('Failed to tag the page for quick deletion. Please try again.');
});
}
}
})();
})();

Revision as of 19:43, 1 November 2024

(function() {
    if (mw.config.get('wgNamespaceNumber') < 0 || mw.config.get('wgIsArticle') === false) return;

    // Dodaj przycisk "Nominate for deletion" do paska narzędzi
    var nominateLink = mw.util.addPortletLink(
        'p-tb', // Pasek narzędzi
        '#', // link docelowy
        'Nominate for deletion', // Tekst przycisku
        'ca-nominate-deletion', // ID linku
        'Nominate this page for deletion' // Podpowiedź tekstowa
    );

    // Jeśli dodanie przycisku się powiodło, przypisz funkcję do obsługi kliknięcia
    if (nominateLink) {
        nominateLink.onclick = function(event) {
            event.preventDefault();
            openDeletionPopup();
        };
    }

    // Dodanie zakładki Quick Delete do popupu
    function addQuickDeleteTab(popup) {
        const quickDeleteTab = $('<div>').attr('id', 'quick-delete-tab').css({
            'display': 'none' // Domyślnie ukryty
        }).appendTo(popup);

        $('<h3>').text('Quick Delete').css({
            'font-size': '18px',
            'margin-bottom': '10px'
        }).appendTo(quickDeleteTab);

        $('<p>').html('Before proceeding with Quick Deletion, please read the <a href="/wiki/Template:QD" target="_blank">Template:QD</a> documentation and the <a href="/wiki/Wikipedia:Deletion_policy" target="_blank">Wikipedia Deletion Policy</a>.')
            .css({
                'font-size': '14px',
                'margin-bottom': '10px'
            }).appendTo(quickDeleteTab);

        const consentCheckbox = $('<input>').attr('type', 'checkbox').attr('id', 'consent-checkbox').css('margin-right', '10px');
        const consentLabel = $('<label>').attr('for', 'consent-checkbox').text('I have read and understand the deletion policy.');
        $('<div>').append(consentCheckbox).append(consentLabel).appendTo(quickDeleteTab);

        $('<p>').text('Choose a reason for quick deletion from the list below:').css({
            'font-size': '14px',
            'margin-bottom': '10px'
        }).appendTo(quickDeleteTab);

        const quickDeleteSelect = $('<select>').attr('id', 'quick-delete-reason').css({
            'width': '100%',
            'padding': '6px',
            'font-size': '14px',
            'margin-bottom': '10px'
        }).appendTo(quickDeleteTab);

        const reasons = [
            { value: 'A1', text: 'Little or no meaning' },
            { value: 'A2', text: 'No content' },
            { value: 'A3', text: 'Article is transwikied' },
            { value: 'A4', text: 'Does not say why it is notable' },
            { value: 'A5', text: 'Not in English' },
            { value: 'A6', text: 'Hoax' }
        ];

        $.each(reasons, function(index, reason) {
            quickDeleteSelect.append($('<option>').attr('value', reason.value).text(reason.text));
        });

        // Przycisk do szybkiego usunięcia
        $('<button>').text('Quick Delete').css({
            'width': '100%',
            'padding': '10px',
            'background-color': '#d9534f',
            'color': '#fff',
            'border': 'none',
            'border-radius': '5px',
            'cursor': 'pointer',
            'font-size': '16px'
        }).on('click', function() {
            const reason = quickDeleteSelect.val();
            const consent = consentCheckbox.is(':checked');
            if (reason && consent) {
                tagPageForQuickDeletion(reason);
            } else if (!consent) {
                alert('Please confirm you have read the deletion policy.');
            } else {
                alert('Please choose a reason for quick deletion.');
            }
        }).appendTo(quickDeleteTab);
    }

    // Tworzenie i otwarcie okna popup dla nominacji do usunięcia
    function openDeletionPopup() {
        // Tworzenie nakładki
        const overlay = $('<div>').attr('id', 'deletion-popup-overlay').css({
            'position': 'fixed',
            'top': '0',
            'left': '0',
            'width': '100%',
            'height': '100%',
            'background-color': 'rgba(0, 0, 0, 0.5)',
            'z-index': '1000'
        }).appendTo('body');

        // Tworzenie okna popup
        const popup = $('<div>').attr('id', 'deletion-popup').css({
            'position': 'fixed',
            'top': '50%',
            'left': '50%',
            'transform': 'translate(-50%, -50%)',
            'background-color': '#fff',
            'padding': '20px',
            'border': '1px solid #ddd',
            'border-radius': '5px',
            'box-shadow': '0 0 10px rgba(0, 0, 0, 0.5)',
            'z-index': '1001'
        }).appendTo('body');

        // Dodanie zakładki Request for Deletion
        const requestDeletionTab = $('<div>').attr('id', 'request-deletion-tab').appendTo(popup);

        $('<h3>').text('Request for Deletion').css({
            'font-size': '18px',
            'margin-bottom': '10px'
        }).appendTo(requestDeletionTab);

        $('<p>').html('Before proceeding with Request for Deletion, please read the <a href="/wiki/Wikipedia:Deletion_policy" target="_blank">Wikipedia Deletion Policy</a>.')
            .css({
                'font-size': '14px',
                'margin-bottom': '10px'
            }).appendTo(requestDeletionTab);

        const reasonInput = $('<textarea>').attr('id', 'deletion-reason').css({
            'width': '100%',
            'height': '100px',
            'padding': '10px',
            'font-size': '14px',
            'margin-bottom': '10px'
        }).appendTo(requestDeletionTab);

        // Przycisk do nominacji do usunięcia
        $('<button>').text('Nominate for Deletion').css({
            'width': '100%',
            'padding': '10px',
            'background-color': '#337ab7',
            'color': '#fff',
            'border': 'none',
            'border-radius': '5px',
            'cursor': 'pointer',
            'font-size': '16px'
        }).on('click', function() {
            const reason = reasonInput.val();
            if (reason) {
                tagPageForDeletion(reason);
            } else {
                alert('Please enter a reason for deletion.');
            }
        }).appendTo(requestDeletionTab);

        // Dodanie zakładki Quick Delete
        addQuickDeleteTab(popup);

        // Zamknięcie okna popup po kliknięciu poza nim
        overlay.on('click', function() {
            overlay.remove();
            popup.remove();
        });
    }

    // Funkcja oznaczająca stronę do usunięcia
    function tagPageForDeletion(reason) {
        const tag = `{{db|${reason}}}`;
        const editSummary = 'Nominating for deletion ([[User :BZPN/RfD.js|RfD]])';

        new mw.Api().postWithToken('csrf', {
            action: 'edit',
            title: mw.config.get('wgPageName'),
            prependtext: tag + '\n',
            summary: editSummary,
            watchlist: 'watch',
        }).done(function() {
            alert('Page tagged for deletion.');
        }).fail(function() {
            alert('Failed to tag the page for deletion. Please try again.');
        });
    }

    // Funkcja tworząca stronę dyskusji o usunięciu
    function createDiscussionPage(reason) {
        const discussionPageTitle = `Wikipedia:Requests for deletion/Requests/2024/${mw.config.get('wgPageName')}`;
        const discussionContent = `{{subst:RfD/Preload/Template|deletereason=${reason}}}\n\n==Deletion discussion==\nMore detailed reason why this page should be deleted:\n* ${reason}`;

        new mw.Api().postWithToken('csrf', {
            action: 'edit',
            title: discussionPageTitle,
            text: discussionContent,
            summary: 'Starting deletion discussion ([[User :BZPN/RfD.js|RfD]])',
            watchlist: 'watch',
        }).done(function() {
            alert('Deletion discussion page created.');
        }).fail(function() {
            alert('Failed to create deletion discussion page. Please try again.');
        });
    }

    // Funkcja dodająca dyskusję do listy
    function addToDeletionList() {
        const deletionListTitle = 'Wikipedia:Requests for deletion/Current discussions';
        const discussionLink = `{{subst:Wikipedia:Requests for deletion/Requests/2024/${mw.config.get('wgPageName')}}}`;

        new mw.Api().edit(deletionListTitle, function(revision) {
            return {
                text: discussionLink + '\n' + revision.content,
                summary: 'Adding new deletion discussion ([[User :BZPN/RfD.js|RfD]])',
                watchlist: 'watch',
            };
        }).done(function() {
            alert('Deletion discussion added to the list.');
        }).fail(function() {
            alert('Failed to add the discussion to the deletion list. Please try again.');
        });
    }

    // Funkcja powiadamiająca autora strony
    function notifyPageCreator() {
        const creator = mw.config.get('wgPageContentModel') === 'wikitext' ? mw.config.get('wgPageCreator') : null;
        if (creator) {
            const notification = `{{subst:RFDNote|${mw.config.get('wgPageName')}}} ~~"+"~~`;
            new mw.Api().postWithToken('csrf', {
                action: 'edit',
                title: `User talk:${creator}`,
                appendtext: '\n' + notification,
                summary: 'Notifying page creator about deletion nomination ([[User :BZPN/RfD.js|RfD]])',
                watchlist: 'watch',
            }).done(function() {
                alert('Page creator notified.');
            }).fail(function() {
                alert('Failed to notify the page creator. Please try again.');
            });
        }
    }

    // Funkcja oznaczająca stronę do szybkiego usunięcia
    function tagPageForQuickDeletion(reason) {
        const tag = `{{qd|${reason}}}`;
        const editSummary = 'Nominating for quick deletion ([[User :BZPN/RfD.js|QD]])';

        new mw.Api().postWithToken('csrf', {
            action: 'edit',
            title: mw.config.get('wgPageName'),
            prependtext: tag + '\n',
            summary: editSummary,
            watchlist: 'watch',
        }).done(function() {
            alert('Page tagged for quick deletion.');
        }).fail(function() {
            alert('Failed to tag the page for quick deletion. Please try again.');
        });
    }
})();