What is needed? Your basic search script needs to know what site to look at, what form to fill out, what picture to use, how often to update itself and where to update itself from. Of course, being the nice people that we are, we will satisfy all of the scripts desires; otherwise, it gets cranky, and we don't want that.
So, open up notepad. It is customary to begin your search script with a couple of lines of comments. For these, a comment is any line that begins with a #, so comment away your title, your name, your email adress, and any info that you think anyone who could concievably get their hands on this might want to know. If you're not going to share it, comment anyway. Just do it. I know, 'comments r teh sux!!1', but it's a good habit to get into.
Now, to begin the actual script. Put this in:
<search
version = "..." //latest version that this has been tested with
name="..." //whatever it's called
description="..." //go on, you know you want to!
method="..." //whatever the form uses (usually "GET")
action="..." //check the source of the page for the form action
searchform="..." //the page on which the search-form resides
>
Now, you've got to take a look at the page you're writing this for. What is the form asking? What are the different inputs? Are there some hidden ones? Those need to go in too, but don't forget to give the one you'll be filling in, the search box, its propper name:
<input name="..." user=""> //whatever the input name is for what you'll type
<input name="..." value="..."> //fill in the rest of the form, if needed
I'm not exactly sure why this is necessary, but you also need to supply some information about where on the page you'll go to, where the results are. So, find salient small snippets of the source-code of the resultant site to fill these in. You should tell it where the results start and end, and the items start and end. As an example, I have supplied those used by Google.
<interpret
resultListStart="<!--a-->"
resultListEnd="<!--z-->"
resultItemStart="<!--m-->"
resultItemEnd="<!--n-->"
>
OK, that's the end of the searching part. Next, let's add a pretty tag on the next line:
</search>
Right. We're almost done. There's just one thing left to do. Perhaps sometime, you'll need to update this script: perhaps the forms on the site will change, perhaps you just noticed a bug. Whatever the reason, you don't want to have to email all your friends and say "hey guys, you gotta download the search thing again. Sorry", do you? And besides, you also want to make a pretty picture. So, one last part:
<browser
update="http://website.domain/dir/script.src" //full url of where you'll upload this and updates
updateIcon="http://website.domain/dir/pic.png" //full url of the pretty little pic you'll make
updateCheckDays="..." //3, or 7, or whatever you want
>
Done! Save that with the extension ".src". Now all we've got to do is make the picture. Try and make it descriptive, but keep in mind that it should be no more than a 16 by 16 pixel PNG. No less either. So make yourself a 16 by 16 pixel PNG, save it, and we're finished.
Now, for the last part: Installing it. There are two ways. First, you can make yourself a webpage with the handy javascript ripped straight from mozdev.org. That way looks cooler. Or, just copy the files into C:Program FilesMozilla Firefoxsearchplugins, or wherever it happens to be on your computer, and restart your browser.
Yay! You're done!
-Cyb.
Note: // in the code signifies my comments for this article. Do not comment lines in that manner within your script! |