MediaWiki:Gadget-AddArchiveCategory.js
Jump to navigation
Jump to search
Note: After saving, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Go to Menu → Settings (Opera → Preferences on a Mac) and then to Privacy & security → Clear browsing data → Cached images and files.
mw.loader.using(['mediawiki.util', 'mediawiki.api'], function () { var api = new mw.Api(); function addCategory() { var text = `[[${"Category"}:${"Archived}]]`; api.edit(mw.config.get('wgPageName'), function (revision) { return { text: revision.content + '\n' + text, summary: 'Adding category ' + categoryName, minor: true }; }).then(function () { window.location.reload(); // Reload the page to see the new category }, function (e) { mw.notify('Failed to add category: ' + e); }); } $(document).ready(function () { mw.util.addPortletLink( 'p-tb', // sidebar section (portlet id). '#', // href for the link (will trigger javascript instead) 'Add Archived Category', // link text. 'ca-add-archive-category', // unique identifier for the link. 'Add a category to this page' // tooltip text. ); $('#ca-add-archive-category').click(function (e) { e.preventDefault(); addCategory(); }); }); });