User:Bosco-bot/common.js: Difference between revisions
Jump to navigation
Jump to search
Content deleted Content added
mNo edit summary Tag: Reverted |
Undid revisions from 69986 to 69954 // AdvancedRollback Tag: Undo |
||
| (One intermediate revision by the same user not shown) | |||
| Line 18: | Line 18: | ||
if (editCount !== null) mw.loader.addStyleTag('#pt-mycontris>a::after, .menu__item--userContributions>span>span::after, #mw-mf-page-left .menu__item--userContributions>span::after {content: " (' + editCount + ')"}') |
if (editCount !== null) mw.loader.addStyleTag('#pt-mycontris>a::after, .menu__item--userContributions>span>span::after, #mw-mf-page-left .menu__item--userContributions>span::after {content: " (' + editCount + ')"}') |
||
})(mw.config.get('wgUserEditCount')); |
})(mw.config.get('wgUserEditCount')); |
||
// |
|||
/** |
|||
* MediaWiki JS helper: Request deletion |
|||
* Adds a "Request deletion" tab to the page toolbar. |
|||
* When clicked, prompts for a reason and prepends {{delete|reason}}. |
|||
*/ |
|||
mw.loader.using(['mediawiki.util', 'mediawiki.api'], function () { |
|||
// Add the "Request deletion" tab in the actions menu |
|||
var link = mw.util.addPortletLink( |
|||
'p-cactions', // portlet: actions menu |
|||
'#', // href |
|||
'Request deletion', // link text |
|||
'ca-requestdeletion', // id |
|||
'Requesting deletion' // tooltip |
|||
); |
|||
// Attach click handler to the new link |
|||
$(link).on('click', function (e) { |
|||
e.preventDefault(); |
|||
// Prompt user for reason |
|||
var reason = prompt('Enter reason for deletion:'); |
|||
if (!reason) return; |
|||
var pageName = mw.config.get('wgPageName'); |
|||
// Fetch current page content |
|||
new mw.Api().get({ |
|||
action: 'query', |
|||
prop: 'revisions', |
|||
rvprop: 'content', |
|||
rvslots: 'main', |
|||
titles: pageName |
|||
}).done(function (data) { |
|||
var pages = data.query.pages; |
|||
var pageId = Object.keys(pages)[0]; |
|||
var content = pages[pageId].revisions[0].slots.main['*']; |
|||
// Prepend delete template |
|||
var newContent = '{{delete|' + reason + '}}\n' + content; |
|||
// Save with fixed summary |
|||
new mw.Api().postWithToken('csrf', { |
|||
action: 'edit', |
|||
title: pageName, |
|||
text: newContent, |
|||
summary: 'Requesting deletion' |
|||
}).done(function () { |
|||
location.reload(); // reload to show template |
|||
}).fail(function (err) { |
|||
alert('Error saving page: ' + JSON.stringify(err)); |
|||
}); |
|||
}); |
|||
}); |
|||
}); |
|||
Latest revision as of 09:19, 12 January 2026
// JWB
mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Joeytje50/JWB.js&action=raw&ctype=text/javascript');
// MarkRights-zh
importScript('User:Bosco/MediaWiki:Gadget-MarkRights.js'); // Backlink: [[User:Bosco/MediaWiki:Gadget-MarkRights.js]]
// Mass block
mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Timotheus_Canens/massblock.js&action=raw&ctype=text/javascript');
// AdvancedRollback
mw.loader.load('//dev.miraheze.org/w/index.php?title=User:PB2008/AdvancedRollback/auto.js&action=raw&ctype=text/javascript');
// Diffedit
mw.loader.load( '//meta.wikimedia.org/w/index.php?title=User:Jon_Harald_Søby/diffedit.js&action=raw&ctype=text/javascript' );
// Edit count
(function(editCount) {
if (editCount !== null) mw.loader.addStyleTag('#pt-mycontris>a::after, .menu__item--userContributions>span>span::after, #mw-mf-page-left .menu__item--userContributions>span::after {content: " (' + editCount + ')"}')
})(mw.config.get('wgUserEditCount'));