Commons:CoolCat

For the original documentation, see User:Ponor/CoolCat.

Category:Uses of Wikidata Infobox
CoolCat; Wikimedia user script for category editing
CoolCat 
Wikimedia user script for category editing
Upload media
Instance of
Different from
user manual URL
official website
Authority file
Edit infobox data on Wikidata
Category:Uses of Wikidata Infobox with manual qid


CoolCat is a lightweight, mobile and keyboard-friendly gadget for editing categories on MediaWiki wikis. It provides a streamlined interface for adding, removing, and modifying categories without needing to edit the raw wikitext of the page.

It is designed as a robust alternative to tools like HotCat, featuring a modern UI, persistent toggle state, and "Winner-Takes-All" logic that handles complex duplicate scenarios automatically.

Category additions, removals, and sort key changes can be pre-filled by pasting or typing in a set of category actions into the CoolCat's edit summary and batch commands field. That can be useful for repetitive edits to numerous pages. Categories can be added or removed by using a dedicated URL parameter as well.

Features

Core functionality

  • Visual interface: Categories are displayed as interactive pills.
  • Inline editing: Click a button in any category pill to rename the category or change its sort key in place.
  • Keyboard friendly: Fully navigable via keyboard. Use Tab to move, Enter to commit, Esc to cancel, PgDn/PgUp to search subcategories or parent categories (limit 200).
  • Autocomplete: Fast prefix search suggestions appear as you type (limit 80).
  • Draft mode: Changes are staged first. You can perform multiple adds, removes, and renames before committing them to the database. Ctrl+Enter saves the changes.

Advanced features

  • Lazy loading (toggle): CoolCat remembers if you want it open or closed. By default, it loads as a small button to save resources. Clicking "CoolCat" expands the full interface and remembers your choice for next time.
  • Winner-Takes-All deduplication: CoolCat intelligently handles duplicate categories. If you rename a category to one that already exists, it automatically consolidates them into a single tag, ensuring clean wikitext output.
  • Dashed duplicates: If you accidentally add a duplicate category in the interface, both instances will be highlighted with a dashed border to visually warn you.
  • Redirects: If the category you are adding is a hard or soft redirect, CoolCat will replace it with the redirect target and notify you with two brief flashes. For soft redirects, it reads the target from the {{Category redirect}} template (Q5828850) or any of its local aliases.
  • Uncategorized template: CoolCat finds the local wiki's {{Uncategorized}} template (d:Q5884621) or any of its aliases and, optionally, removes it for you.
  • Smart diff: A built-in "Preview" button lets you see the exact wikitext diff before you save.
  • Mobile friendly: Large touch targets for edit/remove buttons make it usable on tablets and phones.

Installation

User script

To install CoolCat, add the following line to your common.js file on a local wiki, or to global.js on metawiki:

// Edit categories on a page [[:en:User:Ponor/CoolCat]]
mw.loader.load('https://en.wikipedia.org/wiki/User:Ponor/CoolCat.js?action=raw&ctype=text/javascript');

Gadget

Interface administrators can copy the following files to their wiki (as MediaWiki:Gadget-CoolCat.xxx)

en:User:Ponor/CoolCat
documentation
en:User:Ponor/CoolCat.js
save as MediaWiki:Gadget-CoolCat.js (example), change repoRoot to https://xx.wikipedia.org/w/index.php?title=MediaWiki:Gadget-
en:User:Ponor/CoolCat.css
save as MediaWiki:Gadget-CoolCat.css (example)
User:Ponor/CoolCat-xx.js
translations, such as testwiki:User:Ponor/CoolCat-hr.js, testwiki:User:Ponor/CoolCat-ja.js, testwiki:User:Ponor/CoolCat-sr-ec.js

Usage

Basic controls

  • Launch: Scroll to the bottom of any article. If CoolCat is minimized, click the CoolCat button to open it.
  • Add: Click the + button. Type a name. Press Enter to confirm.
  • Remove: Click the × icon on any pill. The category will be struck through (marked for deletion). Clicking it again will restore it.
  • Edit: Click the (pencil) icon to rename a category or change its sort key (the part after the "|").
  • Save: When you are happy with your changes, click Publish.

Keyboard shortcuts

CoolCat is optimized for power users.

KeyContextAction
PageDownEditing a pillChange Scope (Toggle search scope to Subcategories)
PageUpEditing a pillChange Scope (Toggle search scope to Parent Categories)
ArrowDownSuggestion BoxNext Suggestion
ArrowUpSuggestion BoxPrevious Suggestion
Ctrl+EnterAnywhereSave/Publish (Only if there are unsaved changes)
EscEditing a pillCancel Edit (Revert to original pill)
EscSuggestion BoxClose Suggestions
EnterEditing a pillConfirm Change (Commit to staging)

Staged changes

CoolCat uses a "Staging Area". When you make an edit, it is not saved to the wiki immediately. The pill changes color to reflect its pending status:

  • Green Pill New category added.
  • Yellow Pill Existing category modified (renamed or sort key changed).
  • Red Pill Existing category marked for deletion.
  • Dashed Border Duplicate detected; only one instance will be saved.

Bulk import of category additions and removals

Via summary field

Multiple category actions pasted into the Edit summary field are automatically parsed. The parse can be triggered by the button as well.

CoolCat allows you to quickly pre-fill the staging area by pasting a list of category actions directly into the Edit summary input field. This feature works if the summary field hasn't been modified yet. When you paste a supported format, CoolCat intercepts the text, applies the changes to the interface, and automatically generates the correct summary. Past the initial stage, the Edit summary field can be parsed for category actions using the button; the button works two ways: if the edit summary field is empty, it (re)generates the automatic summary.

Supported formats:

  • Wiki-links: +[[Category:Cats]] -[[Category:Dogs]] (standard CoolCat summary format)
  • Namespaced: +Category:New York -Category:Paris (requires the English or localized namespace prefix)
  • Pipe-delimited: +Cats|-Mice and snakes|+Dogs (the shortest format, uses | as category separator)

The three formats cannot be intermixed.

URL triggers

CoolCat supports a URL parameter that allows you to pre-fill the staging area with changes.

  • Parameter: coolcat_amend_categories
  • Format: [Action] [CategoryName] | [Action] [CategoryName] | …
    • + Add category (e.g., +History)
    • - Remove category (e.g., -Stub)
  • Example: ?coolcat_amend_categories=+History|-Uncategorized_pages

This will queue "History" for addition, and mark "Uncategorized pages" for deletion in CoolCat.

This can be useful when the same categories need to be removed or added on a number of pages: prepare the list on a wiki page, and click through it to amend the categories:

https://en.wikipedia.org/wiki/Wikipedia:Sandbox?coolcat_amend_categories=-Remove_this_cat|+Add_this_cat

https://en.wikipedia.org/wiki/Other_title?coolcat_amend_categories=-Remove_this_cat|+Add_this_cat

Bulk changes of sort keys

Open up any number of tags (pills) for editing using the (pencil) button, then paste into the pristine edit summary/batch command field, or type into it and process using the button any of the following:

  • ++New key to add or change the sort key to "New key"
  • ++ to clear the sort key, leaving only [[Category:...| ]]
  • -- to remove the sort key, leaving the bare [[Category:...]]

Configuration

CoolCat is highly configurable. You can customize its behavior by defining a window.CoolCatConfig object in your common.js file before the loader line.

Configuration options

OptionTypeDefaultDescription
noDirectSaveBooleanfalseIf true, the "Publish" button is replaced by a "Full Edit" button that opens the standard MediaWiki edit form with changes applied (useful for manual review).
doNotCapitalizeFirstLetterAtArray['wiktionary']Automatically capitaliz the first letter of new categories (e.g., "history" "History"), unless we are on a wiki whose wgDBname contains any of the strings in the array. Be as specific as necessary: 'enwiktionary', 'wiktionary', 'commonswiki', 'metawiki', 'wiki', 'wik'.
changeTagString'CoolCat'The Change Tag to apply to edits. Set to null to disable tagging. If the attempt to save fails when the wiki does not have the tag of that name defined, the edit will be re-submitted without the tag.
excludeNamespacesArray[-1, -2, 8, 10, 828]A list of namespace numbers where CoolCat should NOT load (e.g., Special, Media, Template, Module).
excludeActionsArray['history', 'edit', 'submit', 'delete', 'protect', 'watch', 'unwatch']A list of page actions where CoolCat should be disabled.

Internationalization (i18n)

You can override any text string used in the interface via the options inside CoolCatConfig, some of which are the following:

KeyDefault (English)Description
changeSummary"Updated categories"Default edit summary if the user leaves the input blank.
viaCoolCat"CoolCat"Appended to the edit summary.
btnPublish"Publish"Text for the save button.
btnPreview"Preview"Text for the diff preview button.
btnFullEdit"Full Edit"Text for opening the standard editor.
btnCancel"Cancel"Text for the reset button.
searchPlaceholder"Name | Key"Placeholder text for the input box.
summaryPlaceholder"Edit summary (auto-generated)..."Placeholder for the summary input.
confirmDiscard"Discard unsaved changes?"Alert message when navigating away with dirty state.
savedSuccess"Saved successfully!"Notification toast on success.

Example configuration

window.CoolCatConfig = {
    noDirectSave: true, // I prefer to review changes in the full editor
    changeSummary: "Cat cleanup",
    btnPublish: "Save now"
};

mw.loader.load('https://en.wikipedia.org/wiki/User:Ponor/CoolCat.js?action=raw&ctype=text/javascript');

Technical details

  • API Usage: CoolCat uses the MediaWiki API (action=opensearch) for fast prefix-based autocomplete with a limit of 80 results.
  • Conflict resolution: It scrapes the current DOM to find existing categories but performs a fresh prop=revisions fetch of the raw wikitext to ensure it edits the latest version of the page.
  • Storage: The user's preference for the toggle state (Open vs. Minimized) is stored locally using mw.storage (key: coolcat-state).

Feedback & bugs

Please report bugs or suggest features on the Talk page.

Category:CoolCat gadget Category:Gadget script documentation Category:Commons gadget scripts
Category:Commons gadget scripts Category:CoolCat gadget Category:Gadget script documentation Category:Uses of Wikidata Infobox Category:Uses of Wikidata Infobox with manual qid