t-mart / kill-sticky

Bookmarklet to remove sticky elements and restore scrolling to web pages!
826 stars 13 forks source link

Update element selector query #5

Open nspassov opened 1 year ago

nspassov commented 1 year ago

Selecting only direct descendants of body seems to work better for me. The previous selector seems more prone to ruin other UI elements on the page

t-mart commented 1 year ago

Hey, thanks for the PR. Before the HN mention yesterday, I hadn't thought about this code for quite a while.

Thinking again now, I'm not really sure how to move forward. There's no prescription for "annoying modal" element hierarchy. They could reasonably be direct descendants of the body or, just as reasonably, deep descendants of it.

And that's not to mention false positives, which can occur in either case. For example, navigational elements are often fixed or sticky.

The mozilla/readability project comes to mind when I think about an ideal solution to this problem. The mission there is to remove extraneous content around articles and render a "reader mode". They're faced with a similar problem in that every website is different, and they have to filter in/out specific bits. To achieve this, they use a content model that outputs a score -- it looks kinda complicated and would take a lot more work, but I honestly think that that's the level of detail you'd need to achieve to make this work.

So, I'm not convinced that changing the selector this way is going to help. There will be sites where kill-sticky needs that aggressive selector to have an effect, and also sites that it breaks. And, I think the same argument could be made for the proposed change you bring here.

I'm happy to keep talking about this. This is just what comes to mind.