Project page: meta:Reaction
This gadget allows users to add reaction emojis (like 👍, ❤️, 😂, etc.) to comments on talk pages across Wikimedia projects. It enhances user interaction and engagement by providing a simple way to express feedback.
To use Reaction on one of the supported wikis, or install it on all wikis:
- For one wiki: Add the following line to your
common.jspage on that wiki ( e.g. English Wikipediacommon.js). - For all wikis: Add the following line to your
global.jspage on Meta-Wiki.
mw.loader.load("//meta.wikimedia.org/w/index.php?title=User:SuperGrey/gadgets/Reaction.js&action=raw&ctype=text/javascript"); // Backlink: [[meta:Reaction]]npm install
npm run buildUpload dist/bundled.js to your wiki userspace (e.g., User:YourName/Reaction.js) and add the following line to your common.js or global.js page:
mw.loader.load("//your.wiki.org/w/index.php?title=User:YourName/Reaction.js&action=raw&ctype=text/javascript");If your wiki does not host Template:Reaction and Module:Reaction, you need to install those first.
-
Create
Template:Reactionwith the content fromwikitext/Reaction.template.wikitext. -
Create
Template:Reaction/styles.csswith the content from en:Template:Reaction/styles.css. -
Choose the appropriate language version of
Module:Reactionfrom theReaction.module.*.luafiles in the latest release, and createModule:Reactionon your wiki with its content.
npm run build:debug # Build with sourcemaps
npm run lint # ESLint check
npm test # Run Vitest testsYou can test Reaction by pasting the bundle directly into a wiki tab:
- Run
npm run build:debug. The output appears at.debug/Gadget-Reaction.jsand.debug/Gadget-Reaction-<locale>.js. - Open
.debug/Gadget-Reaction.js, copy its entire contents, and switch to the wiki article you want to test. - If your locale has a supplementary bundle, paste
.debug/Gadget-Reaction-<locale>.jsafter the base bundle. - Open the browser DevTools console (
F12/Ctrl+Shift+I) on that page and paste the bundle. It bootstraps itself the same way the gadget loader does, so Reaction immediately mounts in the current tab. - When you rebuild, reload the wiki page and repeat the paste to pick up the changes. Keeping
npm run build:debug --watchin another terminal helps rebuild automatically; you only need to re-paste after each build.
The repository ships with a ready-to-run Firefox debugging workflow for VS Code. The .debug/manifest.json web extension installs a content script (inject.js) that injects the freshly built .debug/Gadget-Reaction*.js bundle into any *.wikipedia.org and *.wikimedia.org page, letting you test Reaction like a normal gadget while still using VS Code breakpoints and sourcemaps.
- Install the Debugger for Firefox extension in VS Code (it provides the
"firefox"debug type). - Open the Run and Debug panel and select Debug Reaction on Wikipedia.
- Press
▶️ . The pre-launch task defined in.vscode/tasks.jsonrunsnpm run watch:debug, which keeps rebuilding.debug/bundled.jswith inline sourcemaps. - VS Code launches Firefox to the URL from
launch.jsonand sideloads the.debugextension. The debugger auto-reloads the page wheneverGadget-Reaction*.js,inject.js, ormanifest.jsonchange, so edits + saves immediately refresh the gadget. - Set breakpoints anywhere in the TypeScript source; Firefox hits them against the rebuilt bundle thanks to the sourcemaps produced by the debug build.
Tip: Update url in .vscode/launch.json if you want the debug session to start on another article or wiki. Stop the debug session to terminate the watch:debug background task.
Disable the Meta-hosted loader while debugging. If your user common.js (or global.js) loads the Meta-hosted script, add a guard to skip it when you are running the local debug extension:
(() => {
const isDev = localStorage.getItem('reaction-dev') === '1';
if (isDev) return;
mw.loader.load("//meta.wikimedia.org/w/index.php?title=User:SuperGrey/gadgets/Reaction.js&action=raw&ctype=text/javascript"); // Backlink: [[meta:Reaction]]
})();The debug extension sets localStorage["reaction-dev"] = "1" at document_start, so the remote loader is disabled for the debug profile. To restore the online version:
localStorage.removeItem('reaction-dev');
location.reload();