lobste.rs has a js-error: here is a mitigation

5 points by refp


Introduction

https://lobste.rs – at the time of writing – has a javascript error on load for logged in users:

Uncaught ReferenceError: qS is not defined
    at new _LobstersFunction (user-c27ac03d.js:144:34)
    at user-c27ac03d.js:665:17

This error is causing much of the site functionality to not work, an easy way to check is to try and [preview] a comment, if that does not work – most likely you have an error in the js-console.

If you provide the missing definition for qS and qSA site functionality is restored in full-effect.

Known to fix:


Override using Dev Tools => Sources => Override

For those with webdev experience it is easy to fix the error yourself by simply patching the faulty script with the below:

 const qS = (a, b) => b === undefined ? document.querySelector(a) : a.querySelector(b);
 const qSA = (a,b) => b === undefined ? [...document.querySelectorAll(a)] : [...a.querySelectorAll(b)];

If the above is ran before the faulty line (665 in this case), all is well and things start working again.


Use an extension such as TamperMonkey

An easier alternative is to use TamperMonkey to automatically run custom javascript for the site, below is what I use:

// ==UserScript==
// @name         lobste.rs undefined qS/qSA fix
// @namespace    http://tampermonkey.net/
// @version      2026-07-27
// @description  try to take over the world!
// @author       You
// @match        https://lobste.rs/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=lobste.rs
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
     window.qS = (a, b) => b === undefined ? document.querySelector(a) : a.querySelector(b);
     window.qSA = (a,b) => b === undefined ? [...document.querySelectorAll(a)] : [...a.querySelectorAll(b)];
})();

end-of-transmission

Personally I used the override approach after discovering this, but I assume there are more than me who want to use our beloved features while waiting for a redeploy of lobste.rs

(\_/)_00_(\_/)
      ^- me previewing my own comments like crazy with the mitigation

Happy browsing!

refp
The previous tampermonkey script is sadly unstable, use the below:

.

  1. Install ViolentMonkey or TamperMonkey
  2. Create a new script (see next section)
  3. Reload the page.

.

Note: tampermonkey requires "enable user scripts" in your browser's extension settings, ViolentMonkey has no such requirement.


This works consistently for me now.

// ==UserScript==
// @name         lobste.rs qS/qSA repair
// @match        https://lobste.rs/*
// @run-at       document-end
// @grant        none
// ==/UserScript==

let nonce = null;
for (const s of document.scripts) if (s.nonce) { nonce = s.nonce; break; }
if (!nonce) throw new Error('no nonce found');

const el = document.createElement('script');
el.nonce = nonce;
el.type = 'module';
el.textContent = `
window.qS = (a, b) => b === undefined ? document.querySelector(a) : a.querySelector(b);
window.qSA = (a, b) => b === undefined ? [...document.querySelectorAll(a)] : [...a.querySelectorAll(b)];

const map = JSON.parse(document.querySelector('script[type="importmap"]').textContent);
const mod = await import(map.imports.user + '?retry=' + Date.now());
window._LobstersFunction = mod._LobstersFunction;
document.dispatchEvent(new Event('DOMContentLoaded'));
`;
document.documentElement.appendChild(el);
el.remove();