Search code examples
htmladblock

Remove attribute from tag with uBlock Origin


How can i remove an attribute from a tag using uBlock?

For example in the following div i want to remove the hidden attribute

<div class="test" hidden="hidden">some content</div>

Expected result:

<div class="test">some content</div>

Solution

  • You can use uBlock's Static filter syntax scriptlet injection. You have the list of available filters in the uBlock's Resources-Library.

    In your case, you can use remove-attr.js, from the documentation:

    remove-attr.js

    Removes attribute(s) from DOM tree node(s). Will run only once after page load.

    Regarding your question, you can remove hidden attribute from the div adding in your uBlock My Filters:

    example.com##+js(ra.js, hidden, div.test)
    

    In case you want to remove another attribute, then change hidden by the attribute you want to remove, and div.test by the CSS selector of your choice.