version 1.0 breaks on the following

56 views
Skip to first unread message

Trevor Butcher

unread,
Aug 28, 2012, 2:17:05 AM8/28/12
to greasemon...@googlegroups.com
Hi, I write my own scripts using my fairly basic knowledge of javascript. Very occasionally I will use a script fragment that I do not understand, to do something specific. And it just happens that one of these is no longer functioning since greasemonkey auto updated to 1.0 from whatever version of 0.9 it had been running.

This part of the script builds a table to be inserted at the bottom of a page, with the table having alternate background colors for the rows.

...
 // Zebra table stripe
 var even = false;
 var evenColor = arguments[1] ? arguments[1] : "#000";
 var oddColor = arguments[2] ? arguments[2] : "#226";

// table content
 var mtbody=document.createElement("tbody");

 for ( i = 0; i < total_row_numb; i++ )
 {
  if ( string_chng != 4 ) // do not add date data to array_PRES (Rank)
  {
  array_PRES[i][1] = array_month[array_PRES[i][1]];
  array_PRES[i][3] = array_universe[array_PRES[i][3]];
  };
  var mtrow=document.createElement("tr");
  mtrow.style.background = even ? evenColor : oddColor;
...

The row the script stops on is: var evenColor = arguments[1] ? arguments[1] : "#000";

If I reload 0.9 the script works fine again.

At the moment I am on my work machine and so won't be able to do any tests until I get home in about 8 hours or so to reload greasemonkey 1.0 on my home machine.

Thanks
Trevor

Anthony Lieuallen

unread,
Aug 28, 2012, 9:03:39 AM8/28/12
to greasemon...@googlegroups.com
On Tue, Aug 28, 2012 at 2:17 AM, Trevor Butcher <ginger...@gmail.com> wrote:
The row the script stops on is: var evenColor = arguments[1] ? arguments[1] : "#000";

The context of this line is very important.  Can you provide a link to the exact/entire script in question?

Trevor Butcher

unread,
Aug 28, 2012, 1:39:02 PM8/28/12
to greasemon...@googlegroups.com

Anthony Lieuallen

unread,
Aug 28, 2012, 1:48:32 PM8/28/12
to greasemon...@googlegroups.com
On Tue, Aug 28, 2012 at 2:17 AM, Trevor Butcher <ginger...@gmail.com> wrote:
 var evenColor = arguments[1] ? arguments[1] : "#000";
 var oddColor = arguments[2] ? arguments[2] : "#226";

As written (in the script you linked) these lines don't work because there is no arguments object.  Greasemonkey used to wrap scripts up in a function wrapper, which provided it, but this creates debugging problems.  You should change these lines to simply:


 var evenColor = "#000";
 var oddColor = "#226";

Reply all
Reply to author
Forward
0 new messages