Home / Fix the page: bookmarklets and a page API

A tool

Fix the page: bookmarklets and a page API

Six fixes for any page of this newsroom, as buttons, as bookmarklets, and as a JS API.

Every site has things a reader would change if they could: a menu they do not need while reading, text too small, too little contrast, no outline. This page is a working example of letting them, on this newsroom. It is the companion to Fix the page yourself, which makes the case.

Try them here, or take them with you

Press Try it here to apply a fix to this page. To use it on any page of this newsroom, drag the dashed button to your browser's bookmarks bar, open an article, and click the bookmark. Click it again to undo. What you turn on is remembered for this site, in your browser, and nothing leaves it.

FixHereBookmarklet
Reading mode
Only the text, in one column: no menu, no strip, no chips, no footer.
Reading mode
Bigger text
Everything at 125%.
Bigger text
High contrast
Black on white, links blue and underlined.
High contrast
Text spacing
Line, letter, word and paragraph spacing at the values WCAG 1.4.12 says a page must survive.
Text spacing
Outline
A box of the page's headings, to jump around.
Outline
Markdown
The same page as its markdown twin, which every article here has.
Markdown

The API underneath

Every bookmarklet is one line, because the work is in a page API. It loads once, and then anything can call it: a bookmarklet, the console, a test, or an agent driving the browser.

window.__tools.page.list()               // the fixes, and which are on
window.__tools.page.toggle('reading')    // flip one
window.__tools.page.apply('bigger', true)
window.__tools.page.reset()

It follows the convention the SGraph tools use: the API lives at window.__tools, announces itself with a tool:ready event, and is described by an api.json. The file itself is page-fixes.js, about 150 lines, versioned and immutable at its path, so a bookmarklet that loads it keeps working. For Playwright, or an agent:

await page.addScriptTag({ url: 'https://newsroom.sgit.ai/assets/page-fixes/v0/v0.1/v0.1.0/page-fixes.js' });
await page.waitForFunction(() => window.__tools?.page);
await page.evaluate(() => window.__tools.page.apply('reading'));

What a bookmarklet is

A bookmark whose address is a line of JavaScript instead of a web page. Click it and the line runs on the page you are on, with nothing installed. This is the one that toggles reading mode:

javascript:(()=>{const F='reading',U='https://newsroom.sgit.ai/assets/page-fixes/v0/v0.1/v0.1.0/page-fixes.js',t=window.__tools&&window.__tools.page;if(t){t.toggle(F);return}const s=document.createElement('script');s.src=U;s.onload=()=>window.__tools.page.toggle(F);document.head.appendChild(s)})()

And this one needs no file at all: a generic reading mode for any site, in one line. It is what you can do without the site's help, and it shows the limit: it guesses at the site's structure, and it gets it wrong where the site does not use the usual tags.

Reading mode, anywhere

javascript:(()=>{const s=document.createElement('style');s.textContent='header,nav,aside,footer,[role=banner],[role=complementary],iframe{display:none!important}main,article{max-width:42rem!important;margin:0 auto!important}';document.head.appendChild(s)})()

What this does not do yet

For an agent

This page loads a page API at window.__tools.page (see api.json beside page-fixes.js): list(), apply(name, on), toggle(name), reset(). The fixes are reading, bigger, contrast, spacing, outline and markdown. An agent can apply them on any newsroom page by loading the same file; they are CSS in the reader's browser and change nothing on the site.