User:BZPN/RfD.js: Difference between revisions

From Test Wiki
Jump to navigation Jump to search
Content deleted Content added
Created page with "// Simple English Wikipedia Deletion Gadget // This gadget helps users nominate pages for deletion according to Simple English Wikipedia's policy. (function() { if (mw.config.get('wgNamespaceNumber') < 0 || mw.config.get('wgIsArticle') === false) return; // Check if page is already tagged for deletion if (document.getElementById('delete-tag')) { alert('This page is already nominated for deletion.'); return; } // Create deletion proc..."
Tags: Mobile edit Mobile web edit
 
Replaced content with "Nothing here"
Tags: Replaced Mobile edit Mobile web edit
 
(23 intermediate revisions by the same user not shown)
Line 1: Line 1:
Nothing here
// Simple English Wikipedia Deletion Gadget
// This gadget helps users nominate pages for deletion according to Simple English Wikipedia's policy.

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

// Check if page is already tagged for deletion
if (document.getElementById('delete-tag')) {
alert('This page is already nominated for deletion.');
return;
}

// Create deletion process UI elements
const deletionBtn = document.createElement('button');
deletionBtn.textContent = 'Nominate for deletion';
deletionBtn.style.margin = '10px';
deletionBtn.onclick = initiateDeletionProcess;

// Append button to page
document.getElementById('mw-content-text').prepend(deletionBtn);

// Function to initiate deletion process
function initiateDeletionProcess() {
const reason = prompt('Please provide a reason for deletion:', 'Not a notable topic');
if (!reason) {
alert('Deletion process canceled.');
return;
}

// Step 1: Tagging the article with deletion notice
tagPageForDeletion(reason);

// Step 2: Creating the deletion discussion page
createDiscussionPage(reason);

// Step 3: Adding the discussion link to the deletion list
addToDeletionList();
}

// Function to tag page with deletion notice
function tagPageForDeletion(reason) {
const tag = `{{rfd|${reason}}}`;
const editSummary = 'Nominating for deletion';

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.');
});
}

// Function to create deletion discussion page
function createDiscussionPage(reason) {
const discussionPageTitle = `Wikipedia:Requests for deletion/Requests/${mw.config.get('wgPageName')}`;
const discussionContent = `{{RfD/Preload/Template|reason=${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',
watchlist: 'watch',
}).done(function() {
alert('Deletion discussion page created.');
}).fail(function() {
alert('Failed to create deletion discussion page. Please try again.');
});
}

// Function to add deletion discussion to the list
function addToDeletionList() {
const deletionListTitle = 'Wikipedia:Requests for deletion/Current discussions';
const discussionLink = `{{Wikipedia:Requests for deletion/Requests/${mw.config.get('wgPageName')}}}`;

new mw.Api().edit(deletionListTitle, function(revision) {
return {
text: discussionLink + '\n' + revision.content,
summary: 'Adding new deletion discussion',
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.');
});
}
})();

Latest revision as of 19:44, 1 November 2024

Nothing here