Bug - Fixed Right Click Menu enhancements don't work with certain right click options enabled

Qualidus

New member
As part of RequestEditorKit.java, addChatFeatures attempts to add right click capabilities to to almost every page by injecting the actions list and including rcm.2.js.

In rcm.2.js a check is made while building the list for actions of type 1 and 5 which are automatically added and then an else check looks for a variable notchat.

Since this variable is only set in mchat.php and lchat.php, the javascript throws an exception causing the menu not to build correctly.

If a user has any of the following options enabled, the RCM breaks as these are not actions 1 or 5:
Perform /whois in chat
Send private message in chat
Add to contact list
Add to ignore list

It seems like a simple fix for this is to add a var notchat = true; prior to writing the actions list.

However, this should not be done on the chat page itself (why are we changing the RCM on the chat pages anyway?)

Another way to fix it would be to surround this check with a try/catch in the javascript although this file is coming directly from the KoL servers so less practical.

Steps to reproduce:
1) Enable any of the above 4 options under the Chat preferences in KoL options.
2) Exit out of KoLMafia (needed to refresh the cached Right Click Menu from lchat.php)
3) Restart KoLMafia
4) Navigate to a page that uses the right click menu such as the Mall Sales Activity.
5) Right click on a player's name and notice that the default browser context menu is displayed

I've tested a quick ASH fix for backoffice.php to verify this works:
writeln(visit_url().replace_string("var actions = {", "var notchat = true; var actions = {"));

For non-chat pages, we want notchat to be true as the specified menu options unsuccessfully attempt to update components of the chat pane if notchat is false.
 

Darzil

Developer
Trying again, r13456. Now only adding right click menu to pages with showplayer.php but without rcm.20090915.js and rcm.20101215.js as well as rcm.js, rcm.2.js and rcm.3.js.

Hmm, should probably be adding rcm.20101215.js rather than rcm.2.js to the page, to come in line with normal lchat.php functionality. Will look at that.
 

Darzil

Developer
r13457 uses the KoL code from 2010 rather than 2007 for the right click menu.

Now the real question is, which pages actually have showplayer.php but not a right click menu in KoL, so that we can test the additional code? (I know the raid manager code adds it from ash, but that happens after this code, we're only adding to KoL code, not scripts)
 
Top