+1 to Perchik, if you don't provide the definition of the functions you use, plus the html it's supposed to run on, we can't really help you to check your code.
Anyway, I still see two things you can change. The first one is to initialize your arrays as arrays, and not as empty objects. You can't use the push
method if your variable is not an array:
var tagHolder = new Array();
var availJobs = new Array();
The second one is to use jQuery or any other javascript library that can make your life easier. In GreaseMonkey, you can use @require
:
// ==UserScript==
// @name Script Name
// @namespace namespace
// @include http://www.website.net/*
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js
// ==/UserScript==
The @required
scripts are retrieved when you add your script to GreaseMonkey: if you want to use that, you'll have to remove your script and reload it. GreaseMonkey will then keep a local copy of the @required
scripts and load them when needed.
With jQuery, your code would then look like that:
var jobs = {};
jobs.scan = function() {
var tagHolder = new Array();
var availJobs = new Array();
$("#app8743457343_content b").each(function() {
tagHolder.push(this);
if ($(this).attr("color") == "silver")
availJobs.push($(this).text());
});
return alert(availJobs[0]);
}
jobs.scan();