Created
July 29, 2011 18:19
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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