简体   繁体   中英

How do I create a bookmarklet to hide a specific page element?

I'm a total noob with bookmarklets. Can anyone help me with the code I need to put in my bookmark URL to hide this specific page element?

<div id="snigel-cmp-framework" class="snigel-cmp-framework" style="height: 722px;">

我想隐藏的元素

It's for a website I access a lot with a super annoying/aggressive cookie policy. You have to click a million checkboxes to opt out, and your preferences are erased when you close your browser.

Thanks!

It's a simple javascript, you just need to make it a one liner, and add javascript: as href of the link you shall drag to your bookmark bar to become bookmarklet. As for the code itself, it's pretty simple.

 <a href='javascript:var elem = document.querySelector("#snigel-cmp-framework"); elem && elem.remove()'>Drag me to bookmark bar</a>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM