Skip to content

Instantly share code, notes, and snippets.

@matijs
Created June 13, 2011 15:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matijs/1022955 to your computer and use it in GitHub Desktop.
Save matijs/1022955 to your computer and use it in GitHub Desktop.
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
Copy link

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
Copy link
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
Copy link

@matijs
Copy link
Author

matijs commented Jun 13, 2011

:*

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment