Find And Replace Page Results

Case insensitive FireFox string replacement extension…

Summary:
FireFox Extension that will find in a case *insensitive* way, a single specific string within any web page. That string, once found, will be replaced with a new string, that comes from an array that I will be supplying. The replacement will happen randomly for each occurrence.

Example:
Search or load a web page, in the results are multiple occurrences of the string “Candy Bar”. “Candy Bar”, or “cAnDy Bar” will be considered a match, and replaced with one random item from an array. The next match is located, and another replacement will happen, pulled as a random item from the array. This should be a global regex replace, not an iterative loop for performance reasons on large web pages

Details:
I will supply a single .js file that contains the array. The array is in the format of:
// data_array.js contains only the following data, but will be
// of arbitrary number of items in the array. The size of the array will change
// which will be considered updates to the extension. Updates should be part of the functionality
// though I believe this is build into the API. I only need to know how to trigger the notification
// in the Add-Ons area of FireFox that there is an update.
var myArray = [];
myArray.push(‘Replace One’);
myArray.push(‘Replace 2’);
… // Arbitrary number of items in the array
… // Arbitrary number of items in the array
myArray.push(‘Final replace’); // last item of array

Given the following as a example web page:
Today, I went for a ride in my car to pick up a candy bar. I arrived at the candy shop, there were many candy bars at the store. I only wanted one candy bar, but there were so many to choose from. I finally found the candy bar I was looking for.

The FireFox Extension will transform the page to the following:
Today, I went for a ride in my car to pick up a Final replace. I arrived at the candy shop, there were many candy bars at the store. I only wanted one Replace One, but there were so many to choose from. I finally found the Final replace I was looking for.

* Items that meet the replace criteria:
…pick up a [candy bar]…
…candy bars… // Does not replace, is not an exact match because of the trailing ‘s’
…wanted one [candy bar], but there…
…finally found the [candy bar] I was looking for….

Note: Replacements are random, I understand there can and will be repetitious results if my array is is small or if FireFox’s random() function is not evenly distributed. I will supply an array with at least 10 items in it. Over time the array will have around 50-75 items in it, which will change over time. The data_array.js file needs to be a single file that can simply be replaced. I already created a Safari Extension that works exactly as I desire, and can supply it for an example. I want to be able to use the same data_array.js file for both Safari and FireFox extensions. The Safari Extension contains the array, copy, icon, version, description and any other data that may be needed.

There is no interface to the extension. It is always on, there need not be a way to turn it on and off, unless extremely simple and will not to add any cost to the project. A simple button in the top of the FireFox toolbar could be a small icon that will toggle on and off this functionality. The ON state would be the icon, the OFF state would be a lighter version of the same icon.

Materials I will supply:
Any icons that are needed
Any text copy that will be needed, I will need a list of what copy you need
Initial version number of the extension
The data_array.js file

The Safari Extension, which I had zero experience with, and was m y first extension, took me 40 minutes to get up to peed. This of course was new development in a new environment I was not used to, making it take longer. As long as you have made FireFox ddd-On, this should take very little time, or you are free to hack an existing Add-On you made. If you do decide to use an existing Add-On, please let me know the name so I can review the license.

Thanks

Leave a Reply

Your email address will not be published. Required fields are marked *