Internet Archive. If you find yourself often using this, consider donating to them for the insane amount of charity they do for the web ecosystem. If you don't have the cash to spare, perhaps consider signing up for an account to browse their huge catalogue of online books.
window.location.href = `https://web.archive.org/web/*/${document.URL}`;
Show the box model of the page by putting a bright red box around everything. See that the nesting looks good and nothing's chunky or broken. This is super valuable for spotting inline elements inside block elements, or links with a click target that is bigger than the visible parts of the element. It also helps debug a wide variety of other CSS and box model issues. This is by far the bookmarklet I use most.
document.querySelectorAll("*").forEach(
(elm, _) => {elm.style.boxShadow="0 0 0 1px red inset"}
);
This lists all the global variables on the page. Super handy to start to understand a site's code and APIs. It just compares the globals of the tab to that of a blank tab. It then uses said blank tab to list the unique global properties of the current tab, one per line. It's also a great gauge of how clean the devs are being about state. You wouldn't believe all the junk you often find.
const newWindow = open();
const agentGlobals = new Set(Object.keys(newWindow.window));
newWindow.document.documentElement.innerText = (
Object.keys(window)
.filter((key) => (!agentGlobals.has(key)))
.sort()
.join("\n")
);
Wardialing the URL continues to work to this day. Not perfect, not efficient, but a handy hammer when you spot a nail.
window.location = window.location.href.replace(
/(.*)(\d+)(.*)/,
(_, start, num, end) => (
`${start}${parseInt(num) + 1}${end}`
),
);
This sets every <img>
tag's src attribute to an empty string which should break most images on the page. This won't break CSS based images. This just helps catch issues around alt text and graceful degradation of the site.
document.querySelectorAll("img").forEach((elm, _) => {elm.src = ""});
This disables all the CSS on the page. Both a graceful degradation test and super crude accessibility first pass. This helps catch a lot of insane sized images/SVGs, menu hells, and JS that assumes styles are working. It's not perfect. It doesn't catch CSS issues from assumed agent defaults or that older user agents aren't left with a mess of half working styles. On the other hand, every bit helps.
[...document.styleSheets].forEach((sheet, _) => {sheet.disabled = true});
This copies all the cookies and local storage data from a page into the clipboard. It formats it so you can paste it into the console of some other profile, page, or user agent. Effectively a way to "transplant" the state. It can't copy HttpOnly
cookies (obviously), so it won't work on well secured sites. It's kind of an odd ball I created for a situation you may find yourself in.
const node = document.createElement('textarea');
const selection = document.getSelection();
node.textContent = `
document.cookie = ${JSON.stringify(document.cookie)};
Object.assign(window.localStorage, ${JSON.stringify(window.localStorage)});
location.reload();
`;
document.body.appendChild(node);
selection.removeAllRanges();
node.select();
document.execCommand('copy');
selection.removeAllRanges();
document.body.removeChild(node);
alert("Session Copied!");