jquery.safeReplace.js Fork


jquery.safeReplace.js is a jQuery plugin for finding and altering text in a web page without negatively impacting the page. It acts on a root HTML element and searches through that element's children in order to find the text you don't want and replace it with the text you do want. It is fairly simple:

$('#some-element').safeReplace('half empty', 'half full');

The above example will look at all the places it says "half empty" in #some-element and replace it with "half full". It can do much more than that though, including search by regular expressions, replace text using capture groups, and provide custom replacement rules. It is really useful in Chrome/Firefox extensions! Check out the project page to learn its full capabilities!