Skip to content

Instantly share code, notes, and snippets.

@matijs matijs/ts.user.js
Created Jun 13, 2011

Embed
What would you like to do?
Remove the title attribute when it's the same as the innerText of an anchor
// ==UserScript==
// @name Title stripper
// @author Matijs Brinkhuis
// @namespace http://github.com/matijs
// @version 0.1
// @description Remove the title attribute when it's the same as the innerText of an anchor
// @include http://frontpage.fok.nl/*
// ==/UserScript==
[].forEach.call(document.querySelectorAll("a[title]"), function(el) { el.innerText === el.title && el.removeAttribute("title"); });
@mathiasbynens

This comment has been minimized.

Copy link

mathiasbynens commented Jun 13, 2011

When image replacement is used you probably don’t want to remove the title even if it’s the same as the innerText.

<a href="foo" class="image-replacement" title="Some text">Some text</a>
@matijs

This comment has been minimized.

Copy link
Owner Author

matijs commented Jun 13, 2011

I can think of numerous other reasons why you wouldn't want to remove a title attribute when it's the same as the innerText :) In fact, I only want this to run on specific sites, and I'm trying to figure out the syntax for that now.

@mathiasbynens

This comment has been minimized.

@matijs

This comment has been minimized.

Copy link
Owner Author

matijs commented Jun 13, 2011

:*

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.