Closed Bug 613220 Opened 14 years ago Closed 11 years ago

JavaScript failing to change style/class info in Wikipedia special/talk pages

Categories

(Firefox :: General, defect)

x86
All
defect
Not set
normal

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: richw, Unassigned)

Details

User-Agent:       Mozilla/5.0 (X11; Linux i686; rv:2.0b7) Gecko/20100101 Firefox/4.0b7
Build Identifier: Mozilla/5.0 (X11; Linux i686; rv:2.0b7) Gecko/20100101 Firefox/4.0b7

A JavaScript addon (User:ais523/adminrights.js), which is supposed to highlight user names of Wikipedia administrators, has stopped working in the 4.0 beta.

The relevant portion of the script is here:

function highlightadmins_inner(n,h) //node, relevant hyperlink fragment
{
  if (n.nodeType!=1||n.tagName.toLowerCase()!="a") return 0; // not an anchor
  if (n.href.indexOf(wgScript+"?title="+h) == -1 &&
      n.href.indexOf(wgArticlePath.split("$1")[0]+h) == -1) return 0; // to the wrong target
  var u=n.href.split(h)[1];
  if(adminrights[u.split("_").join("%20")]==1)
  {
    n.style.backgroundColor="#00FFFF";
    if(n.className==null||n.className=="") n.className="ais523_adminrights_admin";
    else n.className+=" ais523_adminrights_admin";
  }
  return 1;
}

I've verified (using Firebug) that the backgroundColor and className attributes are not being modified, even when a link does match a current list of administrators in the adminrights[] array.

The really strange thing is that if I add an alert() inside the "if", just before setting the backgroundColor -- *and* if I also add an "else" clause to the "if" with another alert() -- the highlighting actions *do* happen.  But if I check the box in one of these alerts, saying not to produce any more dialogs on the page, no more administrator names get highlighted after that point.

Another script (User:NuclearWarfare/Mark-blocked script.js), which marks the names of currently blocked users with a strikethrough, seems to work fine.

Reproducible: Always

Steps to Reproduce:
1. Have (or create) a Wikipedia account, and log in to your account.
2. In your account's vector.js or monobook.js file, include the following line:  importScript('User:Ais523/watchlistnotifier.js');
3. Display a page with signed contributions from administrators (such as WP:ANI).
Actual Results:  
There should be lots of user names highlighted with a cyan background -- but there aren't, because of this bug.

Expected Results:  
There should be lots of user names highlighted with a cyan background -- but there aren't, because of this bug.

I went through these same steps using the Opera and Chrome browsers, and the admin-highlighting function worked just fine.  It also worked fine in FF 3.6 before I switched to 4.0b7.

The author of the script in question (User:Ais523) has been made aware of the problem.  He can't see anything wrong with his code right now and believes it's a FF4 bug.  He's open to the idea of devising a workaround, but he understandably thinks the bug needs to be found and fixed.
Is this still an issue on current Firefox builds?
Flags: needinfo?(richw)
I am no longer using the adminrights.js script which was the subject of my bug report, so I cannot confirm that the bug is gone.  However, since it's been three years, I believe we can safely assume my bug report is outdated by now.
Flags: needinfo?(richw)
I tested <https://en.wikipedia.org/wiki/User:Amalthea/userhighlighter.js>, which works for me. I suspect https://en.wikipedia.org/w/index.php?title=User%3AAmalthea%2Fuserhighlighter.js&diff=571198860&oldid=437693511 fixed the issue.
Status: UNCONFIRMED → RESOLVED
Closed: 11 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.