3 ms·
Love it! Since it's now 2025, we probably should search for "fixed" & "sticky" Here's a minified version with "sticky" added: javascript:(()=>[...document.que
by DaveSwift 2y ago
Love it! Since it's now 2025, we probably should search for "fixed" & "sticky"
Here's a minified version with "sticky" added:
javascript:(()=>[...document.querySelectorAll('body *')].map(el=>["fixed","sticky"].includes(getComputedStyle(el).position)&&el.remove()))();
- evgpbfhnr 2y agoInterestingly running this in the console works but from a bookmarklet changes all the page content to false,false,false,.... (on firefox) Any idea?
- Robin_Message 2y agoChange map to forEach?
- silvestrov 2y agodocument.querySelectorAll('body *').forEach(e=>{if (["fixed","sticky"].includes(getComputedStyle(e).position)) e.remove()});
- 0xml 2y agoFirefox expects your script to return undefined, so you can add one at the end (or even shorter: void 0).
- evgpbfhnr 2y agoThank you (and neighbors), I didn't know this.
- handsclean 2y agoTo clarify slightly, bookmarklet behavior across browsers is to call `document.write` with the result of the bookmarklet’s last expression unless that result is `undefined`, and calling `document.write` after page load completes replaces the page’s DOM with the content written. It’s a weird bookmarklet thing, I don’t think there’s anywhere else in JS that accepts a list of statements, not expressions, but cares about the result of the last expression. People often disable this by making the last expression `void 0`, which evaluates to `undefined`. This is really an anachronism, though, the original point wasn’t actually brevity (it’s only one character shorter after URL encoding, not worth funky syntax) but that just writing `undefined` was broken and sometimes didn’t evaluate to the special value undefined. That’s fixed now, so I would just append `undefined` instead. Though, really what you should do is always wrap bookmarklets in IIFEs, which avoids stomping around the page’s global variables, lets you write code with early exits, lets you opt back in with an explicit return rather than editing boilerplate, and also solves this issue as a bonus.
- gabrielsroka 2y agoeven more minified. forEach doesn't return anything, so you don't need the IIFE. javascript:document.querySelectorAll('body *').forEach(el=>['fixed','sticky'].includes(getComputedStyle(el).position)&&el.remove()) or javascript:document.querySelectorAll('body *').forEach(el=>/^(fixed|sticky)$/.test(getComputedStyle(el).position)&&el.remove())