The GIF above is just a quick demonstration to show the script in action. I'm not an expert player, so please ignore my terrible moves and strategy! 😅
A lightweight Tampermonkey Userscript designed to restore full playability on Colonist.io for users playing with a drawing tablet (e.g., Ugee, Wacom, Huion).
When entering a match in Colonist, the game renders the board inside an HTML5 <canvas> element.
While standard UI buttons recognize pen taps, the game canvas often ignores them because drawing tablet drivers
(via Windows Ink) send PointerEvents instead of standard MouseEvents. This results in
being able to move the cursor, but being completely unable to click or interact with the board.
This script acts as a middleware. It listens for interactions from a pen (pointerdown, pointerup)
and dynamically translates them into synthetic mousedown and mouseup events, fooling the
game engine into thinking a standard mouse is being used.
You can copy the code directly from this box without having to search for the file in the repository:
// ==UserScript==
// ==UserScript==
// @name Colonist.io Drawing Tablet Fix v2
// @namespace http://tampermonkey.net/
// @version 2.0
// @description Spoofs pen pointer events as mouse pointer events to fix tablet input on Colonist.io.
// @author R0mb0
// @match *://colonist.io/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
function spoofPenAsMouse(event) {
// Intervene ONLY if the input is from a pen and is a legitimate, physical event (isTrusted).
// Bypassing this check would result in an infinite loop caused by our own dispatched synthetic events.
if (event.pointerType === 'pen' && event.isTrusted) {
// 1. Immediately halt the original pen event.
// This prevents the browser from translating it into a 'touchstart' event and stops the PixiJS engine from processing the native pen input.
event.stopImmediatePropagation();
if (event.type !== 'pointermove') {
event.preventDefault(); // Prevent unexpected native browser behaviors (e.g., scrolling, panning)
}
// 2. Construct a synthetic PointerEvent identical to the original, but spoofed as a mouse.
const simulatedEvent = new PointerEvent(event.type, {
bubbles: true,
cancelable: true,
view: window,
clientX: event.clientX,
clientY: event.clientY,
screenX: event.screenX,
screenY: event.screenY,
movementX: event.movementX,
movementY: event.movementY,
// Ensure mouse buttons are simulated correctly (left click mapping)
button: event.type === 'pointermove' ? -1 : 0,
buttons: event.type === 'pointerdown' ? 1 : (event.type === 'pointermove' && event.buttons ? 1 : 0),
pointerId: 1, // Standard pointerId for the primary mouse
pointerType: 'mouse',
isPrimary: true
});
// 3. Dispatch the synthetic event to the original target (the game canvas).
event.target.dispatchEvent(simulatedEvent);
}
}
// Use the capture phase (true) to intercept events BEFORE the game's event listeners can process them.
document.addEventListener('pointerdown', spoofPenAsMouse, true);
document.addEventListener('pointerup', spoofPenAsMouse, true);
document.addEventListener('pointermove', spoofPenAsMouse, true);
})();- Install a userscript manager browser extension like Tampermonkey or Violentmonkey.
- Create a new script in the extension dashboard.
- Copy the entire JavaScript code from the dark box above.
- Paste it into the new script window in Tampermonkey.
- Save the script (Ctrl+S or Cmd+S).
- Refresh your Colonist.io page and enjoy playing with your tablet!
Feel free to open an issue or submit a pull request if you notice bugs, especially regarding drag-and-drop actions which might require further event mapping.
