Subscribe:   RSS icon   twitter icon

No More Cookie Warnings

Lee Phillips
September 26th, 2021

As web technologies become more powerful the actual experience of using the web becomes increasingly more annoying. In the last few years we’ve suffered a crescendo of abuse inflicted by people who obviously hate anyone with the gall to visit their sites.

Just when it seemed that things couldn’t get more irritating, cookie warnings seemed to spring up overnight, infecting almost every site run by a company or organization. You may think that it’s not the fault of these companies, because of some law that requires them. No, it is their fault. Notice that the site you’re reading now does not annoy you with any cookie warnings. I’m not required to use them because I don’t spy on you. When you see a cookie warning, the site is asking your permission to be spied upon and tracked. Consider leaving immediately and looking for a better place to get the information you need.

None of the sites I build for others have these warnings, either, because I don’t work with people who spy on their users. Any cookies we use are to maintain sessions, so, for sections of the sites where you need to log in, you don’t have to log in again every time you navigate to a new page. These are what the law defines as “strictly necessary” cookies that are not designed to track your behavior.

When I encounter these cookie warnings, I’m not interested in agreeing, denying, or “managing my cookies”. I don’t want to interact with the page in any way except by reading something on it. Until recently I dealt with these things by executing a bookmarklet that removed “fixed” elements from the page. This is a CSS position property that keeps elements fixed in position while you scroll. Most cookie warnings are fixed, so this took care of those. However, lately I’ve noticed that I’ve had to invoke the bookmarklet on most of the sites I visit, so I wanted to automate it. I usually don’t want any fixed elements on any web page. Erasing fixed elements from the page takes care of many other annoyances in addition to cookie warnings: those horrible videos, used by most news sites now, that sit there next to the article, stabbing you in the eye while you try to read; promotions for this and that; buttons to share on Twitter or something; and more.

Here’s what to do automatically clean up the web:

Install an extension that can automatically run javascript on all webpages. These days I’m using Chromium, and I installed an extension called User JavaScript and CSS, which seems very capable and also allows you to insert your own CSS into pages. There are other extensions that can serve as well, and Firefox has its own selection. I don’t know much about Safari or other browsers these days, sorry.

After the extension is installed, open it and add a new rule. A good extension of this type will allow you to specify what sites the rule should apply to with wildcards. For this purpose, enter the site rule "*", which means every site.

Paste this code into the javascript panel for the new rule:

var e = document.querySelectorAll('body *'), i = e.length - 1;
    while (i >= 0) {
        if (getComputedStyle(e[i]).position === 'fixed' ||
        getComputedStyle(e[i]).position === 'sticky')
        e[i].parentNode.removeChild(e[i]);
        i--;
    }

You’re done! Enjoy turning back the clock five years on the Internet. You’ll find consulting the web a quieter and far more pleasant experience. It’s amazing how much better this makes the WWW. Pages that formerly were thin rivulets of text peeking out from between giant fixed headers and footers can now actually be read.

For those sites where you need fixed elements, you can just click on a button to disable the extension and reload. It’s popular for programming language documentation sites to use a fixed navigation panel, for example.

More Details

The javascript is a minor modification of a bookmarklet created by somebody named cubetronic, which itself is a modification of similar bookmarklets that have been floating around the web for a while. I simply removed the wrapper that turns code into a bookmarklet, and added a condition that also zaps sticky elements. These are similar to fixed elements, but scroll with the page until they reach the top, where they…stick. They’re usually as annoying as fixed elements, but can be useful for headers of tables and lists.

This simple bit of javascript won’t eliminate all cookie warnings, only those implemented with a CSS fixed property. But it seems to get rid of a large proportion of them.


Share with Facebook Share with Twitter Share with Reddit Share with Slashdot
▶ Comment
lee-phillips.org is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to amazon.com.
Quotilizer ... loading ...

Tenuously related:

The best tool for CVs with publication lists.