Skip to content

Instantly share code, notes, and snippets.

@siwells
Created July 29, 2011 18:19
Show Gist options
  • Save siwells/1114395 to your computer and use it in GitHub Desktop.
Save siwells/1114395 to your computer and use it in GitHub Desktop.
Use a regex to remove the font tags & their attributes from a page to undo highlighting applied using those self-same font tags
/*
* Clear the highlighting to allow the user to toggle
* between the original page & the highlighted page.
*/
function clearHighlighting()
{
alert("clearing hightlighting...");
if (!document.body || typeof(document.body.innerHTML) == "undefined") {
if (warnOnFailure) {
alert("Sorry, for some reason the text of this page is unavailable. Searching will not work.");
}
return false;
}
var re = new RegExp('<'+'font'+'[^><]*>|<.'+'font'+'[^><]*>','g')
var bodyText = document.body.innerHTML;
bodyText = bodyText.replace(re, '');
document.body.innerHTML = bodyText;
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment