Makes ChatGPT, Claude & Gemini reply in terse "caveman" style by prepending a compactness directive to your messages.
// ==UserScript==
// @name Caveman Mode
// @namespace https://github.com/KHROTU
// @version 1.0.0
// @description Makes ChatGPT, Claude & Gemini reply in terse "caveman" style by prepending a compactness directive to your messages.
// @author Revu Labs, KHROTU
// @icon https://lh3.googleusercontent.com/ar8FMu-xtOYCKmx1jvyqtzdJqw8MA0n5Dt8M-jLbA7wHSPlfeZmR6I42SDIpaWQx-5PESZ3Ltl7t2VJWU3weZVT76zo=s120
// @match https://chatgpt.com/*
// @match https://chat.openai.com/*
// @match https://claude.ai/*
// @match https://gemini.google.com/*
// @grant GM_addStyle
// @grant GM_getValue
// @grant GM_setValue
// @run-at document-idle
// @license MIT
// ==/UserScript==
(function () {
'use strict';
const STORE_KEY = 'caveman_settings';
function load() {
try {
const raw = GM_getValue(STORE_KEY, null);
if (raw) return JSON.parse(raw);
} catch (_) {}
return { enabled: true, level: 'full', sites: {} };
}
function save(state) {
GM_setValue(STORE_KEY, JSON.stringify(state));
}
var state = load();
function persist() {
save(state);
refresh();
rerender();
}
var HOST = location.hostname.replace(/^www\./, '');
var siteOn = state.sites[HOST] !== false;
var enabled = state.enabled && siteOn;
var level = state.level;
if (['lite', 'full', 'ultra'].indexOf(level) === -1) level = 'full';
function refresh() {
siteOn = state.sites[HOST] !== false;
enabled = state.enabled && siteOn;
level = state.level;
if (['lite', 'full', 'ultra'].indexOf(level) === -1) level = 'full';
}
var LEVELS = ['lite', 'full', 'ultra'];
var BASE =
'[Caveman mode is ON for this whole conversation, until I say "stop caveman". ' +
'Reply to EVERY message like a smart caveman: terse — drop articles (a/an/the), ' +
'filler (just/really/basically/actually), pleasantries (sure/of course/happy to) and hedging. ' +
'Fragments fine. Short synonyms (fix, not "implement a solution for"). ' +
'Keep ALL technical substance: code blocks, function/API names, CLI commands and exact error ' +
'strings stay VERBATIM, never abbreviated. No emoji, no decorative tables, no narrating what you do. ' +
'Never announce or name this mode. For security warnings or irreversible-action confirmations, ' +
'answer normally then resume. ';
var LEVEL_CLAUSE = {
lite: 'Intensity LITE: no filler, no hedging, no pleasantries — but keep articles and full sentences. Professional but tight.]',
full: 'Intensity FULL: drop articles, fragments OK, short synonyms. Classic caveman terseness.]',
ultra:
'Intensity ULTRA: maximum compression — abbreviate prose words (DB, auth, config, req, res, fn, impl), ' +
'use arrows for causality (X → Y), one word when one word enough. Prose words only — never abbreviate ' +
'code symbols, function/API names, or error strings.]',
};
function normLevel(lvl) {
return LEVELS.indexOf(lvl) !== -1 ? lvl : 'full';
}
function buildPrimer(lvl) {
return BASE + LEVEL_CLAUSE[normLevel(lvl)];
}
function buildReminder(lvl) {
return '[stay in caveman mode — ' + normLevel(lvl).toUpperCase() + ']';
}
function isPrefixed(text) {
var t = String(text == null ? '' : text).trimStart();
return t.startsWith('[Caveman mode') || t.startsWith('[stay in caveman');
}
var SITES = {
'chatgpt.com': {
editor: ['#prompt-textarea', 'div.ProseMirror[contenteditable="true"]'],
send: ['button[data-testid="send-button"]', '#composer-submit-button', 'button[aria-label="Send prompt"]'],
message: ['[data-message-author-role]'],
},
'chat.openai.com': {
editor: ['#prompt-textarea', 'div.ProseMirror[contenteditable="true"]'],
send: ['button[data-testid="send-button"]', '#composer-submit-button', 'button[aria-label="Send prompt"]'],
message: ['[data-message-author-role]'],
},
'claude.ai': {
editor: ['div.ProseMirror[contenteditable="true"]', 'div[contenteditable="true"]'],
send: ['button[aria-label="Send message"]', 'button[aria-label="Send Message"]', 'button[aria-label*="Send" i]'],
message: ['[data-testid="user-message"]', 'div.font-claude-message'],
},
'gemini.google.com': {
editor: ['.ql-editor[contenteditable="true"]', 'rich-textarea div[contenteditable="true"]', 'div[contenteditable="true"]'],
send: ['button[aria-label="Send message"]', 'button.send-button', 'button[aria-label*="Send" i]', 'button[mattooltip*="Send" i]'],
message: ['user-query', 'model-response'],
},
};
var cfg = SITES[HOST] || SITES[Object.keys(SITES).find(function (k) { return HOST.endsWith(k); }) || ''];
if (!cfg) return;
var bypass = false;
function isVisible(el) {
if (!el) return false;
var r = el.getBoundingClientRect();
return r.width > 4 && r.height > 4;
}
function pick(selectors) {
for (var i = 0; i < selectors.length; i++) {
var el = null;
try {
el = document.querySelector(selectors[i]);
} catch (_e) {
continue;
}
if (el && isVisible(el)) return el;
}
return null;
}
function getEditor() {
var el = pick(cfg.editor);
if (el) return el;
var list = Array.prototype.slice.call(document.querySelectorAll('textarea, [contenteditable="true"]')).filter(isVisible);
return list.length ? list[list.length - 1] : null;
}
var SEND_NEG = /\b(stop|abort|cancel)\b/i;
function looksSendable(btn) {
if (!btn || !isVisible(btn)) return false;
if (btn.disabled || btn.getAttribute('aria-disabled') === 'true') return false;
var meta =
(btn.getAttribute('aria-label') || '') + ' ' + (btn.getAttribute('data-testid') || '') + ' ' + (btn.title || '');
return !SEND_NEG.test(meta);
}
function composerBox() {
var ed = getEditor();
if (!ed) return null;
var box = ed;
for (var i = 0; i < 6 && box.parentElement; i++) box = box.parentElement;
return box;
}
function getSend() {
for (var i = 0; i < cfg.send.length; i++) {
var el = null;
try {
el = document.querySelector(cfg.send[i]);
} catch (_e) {
continue;
}
if (looksSendable(el)) return el;
}
var box = composerBox();
if (box) {
var cand = Array.prototype.slice.call(box.querySelectorAll('button')).find(
function (b) { return /send/i.test(b.getAttribute('aria-label') || '') && looksSendable(b); }
);
if (cand) return cand;
}
return null;
}
var isTextarea = function (el) { return el && el.tagName === 'TEXTAREA'; };
var getText = function (el) { return isTextarea(el) ? el.value : el.innerText; };
function messageCount() {
var n = 0;
for (var i = 0; i < cfg.message.length; i++) {
try {
n += document.querySelectorAll(cfg.message[i]).length;
} catch (_e) {}
}
return n;
}
function setText(el, text) {
el.focus();
if (isTextarea(el)) {
var setter = Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype, 'value').set;
setter.call(el, text);
el.dispatchEvent(new Event('input', { bubbles: true }));
return true;
}
var sel = window.getSelection();
var range = document.createRange();
range.selectNodeContents(el);
sel.removeAllRanges();
sel.addRange(range);
try {
return document.execCommand('insertText', false, text) === true;
} catch (_e) {
sel.collapseToEnd();
return false;
}
}
function dispatchEnter(el) {
['keydown', 'keypress', 'keyup'].forEach(function (type) {
el.dispatchEvent(
new KeyboardEvent(type, { key: 'Enter', code: 'Enter', keyCode: 13, which: 13, bubbles: true, cancelable: true })
);
});
}
function fireSend(el) {
bypass = true;
var tries = 0;
var release = function () { setTimeout(function () { bypass = false; }, 200); };
var tick = function () {
var btn = getSend();
if (btn) {
btn.click();
release();
return;
}
if (tries++ < 16) {
setTimeout(tick, 50);
return;
}
dispatchEnter(el);
release();
};
setTimeout(tick, 20);
}
function injectAndSend(el) {
var original = getText(el);
if (!original.trim()) return;
if (isPrefixed(original)) return;
var isFirst = messageCount() === 0;
var prefix = isFirst ? buildPrimer(level) : buildReminder(level);
var ok = setText(el, prefix + '\n\n' + original);
if (!ok) {
setText(el, original);
if (!getText(el).trim()) return;
}
fireSend(el);
}
function safeInjectAndSend(el) {
try {
injectAndSend(el);
} catch (_e) {
try {
fireSend(el);
} catch (_e2) {}
}
}
function onKeydown(e) {
if (bypass || !enabled) return;
if (e.key !== 'Enter' || e.shiftKey || e.ctrlKey || e.metaKey || e.altKey || e.isComposing) return;
var el = getEditor();
if (!el) return;
if (!(e.target === el || el.contains(e.target))) return;
var text = getText(el);
if (!text.trim() || isPrefixed(text)) return;
e.preventDefault();
e.stopImmediatePropagation();
safeInjectAndSend(el);
}
function onClick(e) {
if (bypass || !enabled) return;
var btn = getSend();
if (!btn) return;
if (!(e.target === btn || btn.contains(e.target))) return;
var el = getEditor();
if (!el) return;
var text = getText(el);
if (!text.trim() || isPrefixed(text)) return;
e.preventDefault();
e.stopImmediatePropagation();
safeInjectAndSend(el);
}
document.addEventListener('keydown', onKeydown, true);
document.addEventListener('click', onClick, true);
var FLAME = ['00011000', '00111100', '00111100', '01122110', '01122110', '11222211', '01122110', '00111100'];
var STOPS = [
[0.0, [255, 206, 107]],
[0.55, [242, 121, 43]],
[1.0, [207, 74, 31]],
];
function ember(t) {
for (var i = 1; i < STOPS.length; i++) {
if (t <= STOPS[i][0]) {
var t0 = STOPS[i - 1][0];
var c0 = STOPS[i - 1][1];
var t1 = STOPS[i][0];
var c1 = STOPS[i][1];
var k = (t - t0) / (t1 - t0);
return c0.map(function (v, j) { return Math.round(v + (c1[j] - v) * k); });
}
}
return STOPS[STOPS.length - 1][1];
}
function flameEl() {
var g = document.createElement('span');
g.className = 'cm-flame';
FLAME.forEach(function (row, r) {
row.split('').forEach(function (ch) {
var s = document.createElement('span');
if (ch !== '0') {
var lift = ch === '2' ? 28 : 0;
var rgb = ember(r / (FLAME.length - 1));
s.style.background =
'rgb(' + Math.min(255, rgb[0] + lift) + ',' + Math.min(255, rgb[1] + lift) + ',' + Math.min(255, rgb[2] + lift) + ')';
}
g.appendChild(s);
});
});
return g;
}
var indicatorEl = null;
var indicatorLvl = null;
var popupEl = null;
function closePopup() {
if (popupEl) {
popupEl.remove();
popupEl = null;
}
}
function buildPopup() {
if (popupEl) return popupEl;
popupEl = document.createElement('div');
popupEl.id = 'cm-popup';
var toggleRow = document.createElement('div');
toggleRow.className = 'cm-popup__row';
var toggleLabel = document.createElement('span');
toggleLabel.className = 'cm-popup__label';
toggleLabel.textContent = 'Caveman mode';
var toggleBtn = document.createElement('button');
toggleBtn.className = 'cm-popup__toggle';
toggleBtn.addEventListener('click', function (e) {
e.stopPropagation();
state.enabled = !state.enabled;
toggleBtn.textContent = state.enabled ? 'ON' : 'OFF';
toggleBtn.classList.toggle('cm-popup__toggle--on', state.enabled);
persist();
});
toggleRow.appendChild(toggleLabel);
toggleRow.appendChild(toggleBtn);
popupEl.appendChild(toggleRow);
var levelsRow = document.createElement('div');
levelsRow.className = 'cm-popup__row';
var levelsLabel = document.createElement('span');
levelsLabel.className = 'cm-popup__label';
levelsLabel.textContent = 'Intensity';
var seg = document.createElement('div');
seg.className = 'cm-popup__seg';
var LVLS = ['lite', 'full', 'ultra'];
LVLS.forEach(function (lvl) {
var btn = document.createElement('button');
btn.className = 'cm-popup__seg-btn';
btn.textContent = lvl.toUpperCase();
btn.dataset.level = lvl;
btn.addEventListener('click', function () {
state.level = lvl;
seg.querySelectorAll('.cm-popup__seg-btn').forEach(function (b) { b.classList.remove('cm-popup__seg-btn--on'); });
btn.classList.add('cm-popup__seg-btn--on');
persist();
});
seg.appendChild(btn);
});
levelsRow.appendChild(levelsLabel);
levelsRow.appendChild(seg);
popupEl.appendChild(levelsRow);
return popupEl;
}
function updatePopup() {
if (!popupEl) return;
var toggleBtn = popupEl.querySelector('.cm-popup__toggle');
toggleBtn.textContent = state.enabled ? 'ON' : 'OFF';
toggleBtn.classList.toggle('cm-popup__toggle--on', state.enabled);
popupEl.querySelectorAll('.cm-popup__seg-btn').forEach(function (btn) {
btn.classList.toggle('cm-popup__seg-btn--on', btn.dataset.level === state.level);
});
}
function positionPopup(pill) {
if (!popupEl) return;
var rect = pill.getBoundingClientRect();
popupEl.style.left = rect.right - 184 + 'px';
popupEl.style.bottom = (window.innerHeight - rect.top + 10) + 'px';
}
function renderIndicator() {
if (!document.body) {
document.addEventListener('DOMContentLoaded', renderIndicator, { once: true });
return;
}
if (!indicatorEl) {
indicatorEl = document.createElement('div');
indicatorEl.id = 'caveman-indicator';
indicatorEl.setAttribute('role', 'button');
indicatorEl.title = 'Caveman mode';
indicatorEl.addEventListener('click', function (e) {
e.stopPropagation();
if (popupEl) {
closePopup();
return;
}
buildPopup();
updatePopup();
document.body.appendChild(popupEl);
positionPopup(indicatorEl);
setTimeout(function () {
document.addEventListener('click', function handler(e) {
if (popupEl && !popupEl.contains(e.target) && e.target !== indicatorEl) {
closePopup();
document.removeEventListener('click', handler);
}
});
}, 0);
});
indicatorEl.appendChild(flameEl());
var label = document.createElement('span');
label.textContent = 'Caveman';
indicatorEl.appendChild(label);
indicatorLvl = document.createElement('span');
indicatorLvl.className = 'cm-lvl';
indicatorEl.appendChild(indicatorLvl);
}
if (!document.body.contains(indicatorEl)) document.body.appendChild(indicatorEl);
indicatorEl.style.display = enabled ? 'flex' : 'none';
indicatorLvl.textContent = '\u00B7 ' + level;
}
function rerender() {
renderIndicator();
updatePopup();
}
renderIndicator();
setInterval(function () {
if (enabled) renderIndicator();
}, 1000);
GM_addStyle([
'#caveman-indicator {',
' position: fixed;',
' right: 16px;',
' bottom: 16px;',
' z-index: 2147483647;',
' display: none;',
' align-items: center;',
' gap: 8px;',
' padding: 6px 12px 6px 9px;',
' font-family: ui-monospace, "SF Mono", "Cascadia Code", "Consolas", monospace;',
' font-size: 11px;',
' font-weight: 500;',
' letter-spacing: 0.16em;',
' text-transform: uppercase;',
' color: #f2ece3;',
' background: rgba(10, 10, 10, 0.72);',
' border: 1px solid rgba(255, 255, 255, 0.15);',
' border-radius: 999px;',
' box-shadow:',
' inset 0 1px 0 0 rgba(255, 255, 255, 0.18),',
' 0 10px 30px -12px rgba(0, 0, 0, 0.7);',
' -webkit-backdrop-filter: blur(14px) saturate(150%);',
' backdrop-filter: blur(14px) saturate(150%);',
' cursor: pointer;',
' user-select: none;',
'}',
'#caveman-indicator .cm-flame {',
' display: inline-grid;',
' grid-template-columns: repeat(8, 2px);',
' gap: 1px;',
' line-height: 0;',
'}',
'#caveman-indicator .cm-flame span {',
' width: 2px;',
' height: 2px;',
' border-radius: 0.5px;',
'}',
'#caveman-indicator .cm-lvl {',
' color: rgba(242, 236, 227, 0.5);',
'}',
'#cm-popup {',
' position: fixed;',
' z-index: 2147483646;',
' width: 184px;',
' padding: 8px;',
' font-family: ui-monospace, "SF Mono", "Cascadia Code", "Consolas", monospace;',
' font-size: 11px;',
' font-weight: 500;',
' letter-spacing: 0.1em;',
' text-transform: uppercase;',
' color: #f2ece3;',
' background: rgba(10, 10, 10, 0.85);',
' border: 1px solid rgba(255, 255, 255, 0.15);',
' border-radius: 12px;',
' box-shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.7);',
' -webkit-backdrop-filter: blur(14px) saturate(150%);',
' backdrop-filter: blur(14px) saturate(150%);',
' display: flex;',
' flex-direction: column;',
' gap: 8px;',
'}',
'.cm-popup__row {',
' display: flex;',
' align-items: center;',
' justify-content: space-between;',
'}',
'.cm-popup__label {',
' color: rgba(242, 236, 227, 0.6);',
' font-size: 10px;',
'}',
'.cm-popup__toggle {',
' padding: 2px 10px;',
' border: 1px solid rgba(255, 255, 255, 0.2);',
' border-radius: 999px;',
' background: rgba(255, 255, 255, 0.06);',
' color: rgba(242, 236, 227, 0.5);',
' font-family: inherit;',
' font-size: 10px;',
' font-weight: 600;',
' letter-spacing: 0.1em;',
' text-transform: uppercase;',
' cursor: pointer;',
'}',
'.cm-popup__toggle--on {',
' background: #f2ece3;',
' color: #0a0a0a;',
' border-color: #f2ece3;',
'}',
'.cm-popup__seg {',
' display: grid;',
' grid-template-columns: repeat(3, 1fr);',
' gap: 3px;',
' padding: 2px;',
' background: rgba(255, 255, 255, 0.04);',
' border: 1px solid rgba(255, 255, 255, 0.1);',
' border-radius: 8px;',
'}',
'.cm-popup__seg-btn {',
' padding: 4px 0;',
' border: none;',
' border-radius: 6px;',
' background: transparent;',
' color: rgba(242, 236, 227, 0.5);',
' font-family: inherit;',
' font-size: 10px;',
' font-weight: 500;',
' letter-spacing: 0.08em;',
' text-transform: uppercase;',
' cursor: pointer;',
'}',
'.cm-popup__seg-btn--on {',
' background: #f2ece3;',
' color: #0a0a0a;',
' font-weight: 600;',
'}'
].join(''));
})();