| Foxreplace Lord Edition Firefox Addon |
| Montag, den 17. November 2008 um 18:38 Uhr |
|
Achtung: Dieser Artikel und das Firefox Addon ist nur für Fortgeschrittene gedacht, die sich mit html und javascript auskennen. Ich bin nicht verantwortlich für Fehler die durch das addon verursacht werden. Dazu zählen alle Arten von Fehlen, die durch das Addon verursacht werden könnten, wie Abstürze, Datenverlust und finanzieller Verlust. Attention: This entry and the firefox addon is only meant to be used by advanced user, with knowledge about html and javascript. I'm not responsible for any problems caused by the addon, like crashes or loss of data or loss of money. Um möglichst viele Leute zu erreichen ist dieser Eintrag auf Englisch. To reach as many people as possible, this information is in english. If you visit your favourite website often, you might have some things you wish to change. For example: Some links are in submenus or there is some textual content you would not like to read. To make things short: Sometimes you wish to replace some content on a website, or even add contents. Marc Ruiz created an addon called Foxreplace (https://addons.mozilla.org/de/firefox/addon/6510). It is used to replace tag attributes like value and text, even links, automatically on page load. But that was not enough for my needs. What I want to do is: -Replace any part of the page -add own javascripts (which itself can do things to the page that foxreplace itself cannot do.) The Implementationwould have taken more days it took already, if there wasn't the pretty good to use code "framework".I must admit that it was a trial and error implementation very often, because I did not know javascript very well. I had also no idea how to build firefox addons from the scratch. Foxreplace Lord edition 1.0 is based on Foxreplace 0.8.0 by Marc Ruiz. UsageI am too lazy to change any included windows and helpfiles. Please read this "how to".How to UseFirst, you should backup your data, like every day.Then you should download the original version of Foxreplace from the firefox experimental addon page. Yes you have to register, BUT, never enter any real important information, as Google is able to find your nickname, homepage, and real name AND, you cannot delete your profile!. (I'm still trying to reach the webmaster >:o ) Because I don't know what I'm doing and I did not generate a unique program id number, I built no installation package. Download the modded foxreplace.jar here. DOWNLOAD Just overwrite the installed foxreplace addon with your downloaded version from this page (you may rename the original one). C:\Dokumente und Einstellungen\<username>\Anwendungsdaten\ Mozilla\Firefox\Profiles\<profilename>.default\extensions\fox(AT)replace.fx\chrome\foxreplace.jar (Stupid editor sees links where ther are no.)Start Firefox. Now there is a Foxreplace entry in tools. Choose "foxreplace options..." Click "add" to add a new substitution for a set of webpages. Type your URL like http://www.myfavouritepage.com/* or perhaps without www. Click "add". There are 4 kinds of substitutionsText: substitutes text by text. '<a xhref="http://www.haxx0rdezimal.de/#"' => '<b xhref="http://www.haxx0rdezimal.de/#"'Word: substitutes complete words. Regex: regular expressions as used by javascript but without the slashes not '/regex/', but 'regex' example: \<a xhref=(.*?)>(.*?)\<\/a\> => '$1 $2' Text (with javascript) to inject javascript: ##SCRIPT:object_id => [javascript is added to the object] examples: SCRIPT Search => Replace [sometext] => [sometext]<div id="myid"></div> ##SCRIPT:myid => alert("my new javascript"); ONCLICK Search => Replace [sometext] => [sometext]<a id="myid">Click here to shortcut</a> ##ONCLICK:myid => Call some java function from the page; TippsFirefox rearranges some attributes. This can be understood by viewing the sourcecode of the whole page, and compare it with source code of a selected area.ex: <div class="cl1" id="mydiv"> and <div id="mydiv" class="cl1"> This may lead to matching problems. You can do pretty powerful things to lists. (This looks like a function call or something.) example list: a 1 X b 2 Y c 3 Z Search => Replace [regex which matches listcode] => __Operation_$1_$2_$3__ (results in: __Operation_a_1_X__ in each line) /__Operation_(.*?)_(.*?)_(.*?)__/g => [complex html using $1 - $3] OR [regex which matches listcode] => <div id="op1">__Operation_$1_$2_$3__</div> ##SCRIPT:scriptid => document.getElementById("op1").... [extract the values and compute other values...] Known problemsYou may edit inside the head tag and inside the body tag, but not between them. Also you cannot search for body or head start and end tag.When viewing .css or .js files (plain text files), the linefeeds somehow disappear. The substitutions with ##SCRIPT: are also replaced inside the webpage, but I assumed that this string never happens, plus the name of the id. Editing features are very bad. Edit your strings in an external editor and paste them into the textboxes. List of the substitutions ist ugly, because you cannot see important parts. When using the edit button, the kind of substitution (text, word, regex) is not automatically set. "Tricks" (see how to) are needed to add javascript. Not implemented: Keep status information. eg: ##SETSTATE:myvar => [searchstring] Feel free to improve, but consider the license. I made these changes to improve the addon mainly to fit my needs. And I will only improve the addon when I think it is necessary or someone has a very good idea. |
sees links where ther are no.)