Remove anything that is sticky on websites - gHacks Tech News

Remove anything that is sticky on websites

Websites may throw a large number of different sticky things at your browser on load, from "we use cookies" and "please disable your ad-blocker" to "sign-up for our newsletter" or ads that move with the screen.

While some of these may be useful in some situations, they are more often than not annoying. Options to close the elements to hide them on the screen are offered by most sites but some shady ones may display sticky elements without such options.

Sticky elements are bad for a number of reasons: they take up valuable space which you notice more on small-screen or resolution devices, are often distracting, and may get in the way when you use page scroll functionality or want to print or save pages.

Kill Sticky Headers

kill sticky elements website

Kill Sticky Headers is a bookmarklet that you can run on any webpage you visit to remove sticky elements on it.

All that it takes is to click on the bookmarklet to execute it. The bookmarklet does its magic and removes the sticky element from the web page without touching anything else on it.

Useful especially if a site forces sticky elements on you that you cannot close or hide immediately. If you have ever been to a Pinterest listing of images you know that the site displays a sticky sign-up element on the page when you interact with the page a bit.

The element has no hide or close option and while you can use tricks to browse Pinterest without registration for as long as you like, most users would probably prefer an easier solution.

That easier solution comes in the form of Kill Sticky Headers as it removes sticky elements on webpages with just a click.

Note: The bookmarklet does not work on many sites in Firefox right now, likely because of this bug.

Here is a slightly modified version of Kill Sticky Headers that supports sticky and fixed position elements.

javascript:(function () {
var i, elements = document.querySelectorAll('body *');

for (i = 0; i < elements.length; i++) {
if (["sticky", "fixed"].includes(getComputedStyle(elements[i]).position)) {
elements[i].parentNode.removeChild(elements[i]);
}
}
})();

All that is left is create a new bookmark and use the code as a the URL.

  • Chrome and Chromium-based browsers: Right-click on the bookmarks bar and select New > Page. If the bookmarks bar is not there, use Ctrl-Shift-B to display it. Add the code as the URL and pick a descriptive name for the bookmarklet.
  • Firefox and Firefox-based browsers:  Right-click on the main toolbar and select Bookmarks Bar to display it. Right.click on the bar and select New Bookmark. Paste the code into the location field and pick a descriptive name. Select add to save it. The bookmarklet does not work right now on sites that use Content Security Policy apparently.

Just click on the new bookmark whenever you want to execute its JavaScript function.

Tip: You can use uBlock Origin to remove any element on any page permanently. If you are worried about cookie notices primarily, check out this guide on how to deal with them permanently.

Closing Words

Kill Sticky Headers is a useful bookmarklet that hides sticky elements such as cookie notices, newsletter sign up forms, or registration prompts, from websites temporarily. It works fine on many sites at the time of writing but there are probably some with limited functionality after running the script.

Now You: How do you deal with sticky elements on websites?

Summary
software image
Author Rating
1star1star1star1stargray
4.5 based on 7 votes
Software Name
Kill Sticky Headers
Software Category
Browser
Landing Page
Advertisement

We need your help

Advertising revenue is falling fast across the Internet, and independently-run sites like Ghacks are hit hardest by it. The advertising model in its current form is coming to an end, and we have to find other ways to continue operating this site.

We are committed to keeping our content free and independent, which means no paywalls, no sponsored posts, no annoying ad formats or subscription fees.

If you like our content, and would like to help, please consider making a contribution:


Previous Post: «
Next Post: »

Comments

  1. pHROZEN gHOST said on August 16, 2018 at 5:18 pm
    Reply

    Nice one. These “sticky thingies” are becoming all too common.

  2. chesscanoe said on August 16, 2018 at 6:25 pm
    Reply

    I used Martin’s script version after going to Chrome settings and choosing Show Bookmarks Bar. After going to an annoying site, I clicked the new Script bookmark, which worked, except after that I had to press F5 to reload the original URL. I am guessing this was necessary because of some other extension I run.

  3. stefann said on August 16, 2018 at 7:22 pm
    Reply

    Annoying is the word !

    Ghacks has one:”You are using an adblocker….”. Removed element due to it’s annoyance…..

    My personal right to decide what i want to see on a website – it’s not up to the webmaster ! Webmasters still haven’t understood that……

  4. Mr Stank said on August 16, 2018 at 8:58 pm
    Reply

    Addblock plus’s …block element works just fine for me even for stickies.

  5. Nobody said on August 16, 2018 at 9:00 pm
    Reply

    Nice, it also does work to remove that annoying “MANAGE YOUR CHOICES” popup that keeps appearing on this site each time i do visit it :-P

  6. Yuliya said on August 17, 2018 at 10:18 am
    Reply

    uBlockOrigin – Dashboard > Filter lists > Annoyances > Fanboy’s Annoyance List
    Gets rid of all this junk, including floating share widgets nonsense.

    1. Mr Stank said on August 17, 2018 at 12:15 pm
      Reply

      Nice. I did not know this. Thank you.

    2. chris said on August 18, 2018 at 5:56 pm
      Reply

      Great find many thanks, works for me.

  7. TelV said on August 17, 2018 at 11:13 am
    Reply

    Adblock Plus has a number of subscriptions to deal with these kind of annoyances at https://adblockplus.org/subscriptions

    For example, there’s an Adblock warning on https://www.techradar.com/ which prevents users from accessing the site unless they disable ABP. But the anti-adblock subscription removes it without a problem.

  8. Anders said on August 17, 2018 at 11:21 am
    Reply

    I exclude pinterest from every search. They are the worst site designers ever and will not get my clicks. I hope they decend ito obscurity.

  9. Belga said on August 17, 2018 at 1:09 pm
    Reply

    Lately, a popup did not appear in Firefox/Waterfox on the of site Softpedia (only in IE). And since it was impossible to mark its agreement, it was impossible to consult the site; the popup simply prevented the scrolling of the page.
    I notified them and it seems to be gone now.
    There is still a popup at the bottom of the page to accept cookies which is easily removed thanks to Kill Sticky.
    Thanks for the tip.

  10. Lewis Cowles said on August 18, 2018 at 9:37 am
    Reply

    Please consider using Gist for code examples.

    document.body.querySelectorAll(‘*’) is exactly what you’ve done, but I just feel it reads a bit better. Also you can borrow from MDN docs to create a more compatible version (works from IE9 up) by sacrificing includes method on arrays, and using explicit cast to array with forEach.

    https://gist.github.com/Lewiscowles1986/48e9f69967e4b09e010a238bff781055

  11. shiro said on August 28, 2018 at 8:33 pm
    Reply

    How to get this to work on Firefox Android?

Leave a Reply

Check the box to consent to your data being stored in line with the guidelines set out in our privacy policy

Please note that your comment may not appear immediately after you post it.