Depiq user script update

I've updated the depiq user script. I've solved the problem of disembodied "Read More" links (Slashdot's HTML is FUBAR; the first story on a page is encapsulated in a paragraph except for its "Read More" bits, while subsequent stories on a page do not have the same parent paragraph). Because I'm more confident about the script's capabilities now, I've also changed the include list to handle all slashdot categories. Internally, I removed the closure (closures are not memory-friendly in IE), refactored the code a bit into functions, and added some logging (through the GM_log() functionality, you'll see it either in the Turnabout console in IE or the Javascript console in Firefox) to track the editor that posted each story that was found and to give a total count of how many stories were removed. Finally, I can't seem to keep the filenames straight. I'm sticking with "depiq.user.js" for now. You may have to uninstall the previous script before installing this new one.

As always, the script has been tested with IE/Turnabout and Firefox/Greasemonkey. Since this script is just basic DOM walking and manipulation, it should work in Opera 8 as well, but I've not done any testing there.

Depiq user script

Since I created a "userscripts" category on my blog, I figured I should post my other user scripts (okay, "user script" singular for now) in this category for easy access.

Here's the depiq user script. It removes Roland Piquepaille-submitted stories from the Slashdot home page (exactly why you would want to remove these submissions is explained in the comments of pretty much every Roland-submitted story -- ie, if you have to ask, you probably don't care enough to remove them). The inclusion list is only the main Slashdot page, so Roland stories will still show up in other sections (you could change the inclusion list, but I haven't tested that). It's not perfect, thanks to Slashdot's horribly awful HTML code. You might see some parentless "Read More" links, for example. That just tells you that the script is working.

Since I'm an Internet Explorer user (gasp!), this script works with both Firefox/Greasemonkey and IE/Turnabout (Turnabout is now my choice of Greasemonkey-like IE plugins, since I killed GreasemonkIE -- I really liked that name; maybe Turnabout could rename themselves to GreasemonkIE?). It might work in Opera 8, but I haven't tested it there. Feel free to let me know if it does or doesn't work, or update the script to work with Opera.

Any future scripts will be Firefox/Greasemonkey- and IE/Turnabout-compatible. I'll do my best to support Opera 8, but it's secondary to the other two (sorry, Opera users).

Forza statistics user script update

I hacked around a little bit on the forza-stats user script, and ended up with this:

  • Added a "podium percentage" statistic. This takes the number of 1st, 2nd, and 3rd place finishes (or as I like to call them, "win, place, and show"), and divides them by the total number of races.
  • Added an onsubmit handler to the gamertag input form. If you hit enter on the input box, it will act as though you clicked "Set".
  • Changed the color and opacity of the statistics bar. I changed it to a greyish color that better fit the Forza theme, and added a slight transparency so that you can see the header graphic obscured by the bar. Strictly cosmetic, since the bar wasn't obscuring any clickable bits, but it's still a nice change.
  • Added some nasty browser-detection code so that the bar can be "position: fixed" on Mozilla. IE doesn't support "position: fixed", and the hacks to support a fixed-like layout assume you have full control over the web page. Since I really don't want to try to completely re-layout the Forza community pages, I did this hack so that at least Firefox users can have a fixed bar. I was very hesitant about adding this browser check, since it may completely fail if you've changed Firefox's userAgent string to mimic IE, but I decided it was worth doing because Firefox has reached the point where it's an accepted browser and only really stupid pages require it to identify itself as MSIE. Worst case, if you've changed Firefox's userAgent to look like MSIE, the statistic bar will be positioned abosolutely at the top of the page rather than as a "floating" fixed element.
  • Added some cleanup code to unhook onclick and onsubmit handlers. This is an attempt to help stem IE's javascript memory leaks. Memory is still leaked, but the forza-stats script should be nicer about not leaking as much memory.
I also spent some time seeing if I could make this script work with Opera 8's user scripting support, but reliance on GM_* functions makes this difficult. I tried using a script that implements the GM_* functions, but ran into several problems:
  1. The GM_getValue implementation in that script is broken. It's trying to eval the stored value, which doesn't work when storing simple strings.
  2. The GM_xmlhttpRequest "implementation" is simply an aliasing of Opera's XMLHttpRequest object. That's not enough for a proper implementation of GM_xmlhttpRequest.
If those two items in the compatibility script were fixed, or if a different compatibility library was used (I don't normally use Opera, so I don't know what exists in terms of mimicking Greasemonkey functions), forza-stats may work in Opera. However, given the differing CSS implementations across browsers, the bar itself probably wouldn't look right (Opera supports "position: fixed", but my browser check may not handle Opera properly; the width of the bar may be incorrect; Opera doesn't support the opacity style or the filter style which is used to do opacity in IE; etc).

As before, forza-stats is compatible with both Mozilla/Greasemonkey and IE/Turnabout.

Forza statistics user script

The Forza team recently launched their online stats for Forza Motorsports. The stats are still a bit rudimentary, and there's no way to log in to get a brief overview of your own statistics a la Bungie's Halo 2 stats. However, there is a GET interface to retrieve gamertag details.

Enter Greasemonkey/Turnabout. I wrote a user script to add a bar to the top of the Forza community pages displaying some information about a given gamertag.

The bar displays the current gamertag with a link to its statistic page, and the tag's ELO, 1st place races, 2nd place races, 3rd place races, and total races. You can refresh your statistics at any time (this currently works best in Firefox with Greasemonkey -- you may have to click Refresh multiple times in IE with Turnabout), check on the statistics of another gamertag (type the tag into the input box and click "Check" to navigate to that tag's stat page), or set your a different gamertag to track (type the tag into the input box and click "Set"). After installation, you'll notice that the bar says "No tag". You need to set a gamertag for it to watch.

Caveat: Like Bungie's Halo 2 statistics, the Forza statistics may occasionally be out of sync with the actual Xbox Live data. This can manifest itself a simply not finding any statistics at all, or finding only partial statistics (ELO, but no race numbers), or it might just not reflect your most recent races (ELO changes, race count increases). You can try Refreshing the stat bar data, or Checking your gamertag's statistic page to see if the data has been synced up yet.

Hopefully a more robust data source will be available for Forza stats (RSS, please!), and hopefully even more statistics will be forthcoming.

GreasemonkIE replacement

  • Posted on
  • by
  • in

For those who haven't found it yet, Trixie looks like a good replacement for the now-dead GreasemonkIE. I have no affiliation with the Trixie project, and found it through Michael's comment. Thanks for the pointer.

I just played around with Trixie a little bit (fixed the google image no-frame script installed with Trixie). It looks like it has the same page refresh bug GMIE had. Maybe that'll be fixed in IE7. The config options are both better (scripts are automatically installed simply by downloading them into the scripts directory) and worse (scripts seem to be stored globally in program files, which won't work well on multi-user systems or with non-admin users; I couldn't find a way to edit includes/excludes without editing the files directly), but at version 0.2.2 it's looking very good.

Congrats to whoever's behind the Trixie project (I'll reiterate, it's not me), and good luck with the project.

Goodbye to GreasemonkIE

  • Posted on
  • by
  • in

I have to kill this project. I have no time to work on it, and I can't open the source, so I'm going to let it die. The concepts behind GreasemonkIE are not novel (considering it's a "port" of Greasemonkey), and building a managed BHO is well-documented already. Joe's Apt has a good set of links on this topic, most of which I found independently to help me build a managed BHO. If you're interested in building your own managed BHOs, those links are an excellent place to start.

Hopefully some other enterprising developer can make user scripts for IE a reality, but unfortunately that developer cannot be me.

GreasemonkIE update

  • Posted on
  • by
  • in

New update for GreasemonkIE!


  • Added an interface to load user scripts. No more XML modification. Download your script first, and then open "Tools ->Add User Script..." to load the script into GreasemonkIE. I still haven't hooked up to the context menu.
  • Added Tony Juricic's mscoree.dll wrapper, so now explorer.exe doesn't hold onto the GreasemonkIE assembly.
To upgrade, remove the old MSI (either using "msiexec /x greasemonkie.msi" from wherever you downloaded the MSI, or through Add/Remove Programs) and install this new one.

As a bonus, I've written my first brand-new user script: De-Piquepaille Slashdot. This script removes Roland Piquepaille-submitted stories from the Slashdot front page (I wrote it on a whim). Tested with Greasemonkey and GreasemonkIE.

Lately, I've been working on a side project to bring the Greasemonkey concept of user scripts to Internet Explorer. Thus, GreasemonkIE. It's still in a very early state, and I haven't had a chance to get in all of the functionality that I'd like. However, I feel that it's far enough along that I can put out there for others to use. You can download it here. It's packaged as a Windows Installer. You'll need to restart IE after it's installed (you may need to close IE before installation). There's no gui interaction so once the progress dialog goes away, it's done.

Known issues:

  • There's no nice way to install user scripts. For now, you'll have to do that by hand (see below). I'm working on adding an entry to the IE context menu for anchor tags, but that's not as clean as I'd like (only scripts can be added to IE context menus, so rather than adding an entry that calls a method in the BHO directly, I have to add an entry that calls a script that instantiates a COM class in the BHO that adds a script, and that's been causing some problems). Alternatively, I may just provide a GUI that will let you add already-downloaded scripts to GreasemonkIE.
  • GreasemonkIE is written as a BHO, so you may get warnings from some anti-spyware software. If it prompts you for confirmation, allow it to install.
  • Since GreasemonkIE is written in C#, you'll need to install the .NET framework if you don't already have it.
  • Also because GreasemonkIE is written in C#, I haven't yet found a good way to stop explorer.exe from loading the BHO. This means that you may have problems uninstalling GreasemonkIE if you've opened any Explorer windows (iexplore.exe will release the assembly reference when it's closed, but explorer.exe will not because it doesn't close until you log out or reboot). Logging out or rebooting will allow you to uninstall GreasemonkIE.
  • User scripts aren't re-applied if you refresh a web page. Internet Explorer doesn't fire the OnDocumentComplete event for page reloads, and I haven't had a chance to investigate other options.

Installing user scripts: GreasemonkIE should write an XML file under your user's application data directory ("C:\Documents and Settings\username\Application Data\GreasemonkIE\greasemonkie.xml", for example). If the folder or XML file doesn't exist, you can create them by hand. To install a new user script, add a new <script> node to greasemonkie.xml under the <scripts> node. For example, to install a user script "inline.player.user.js" that was downloaded to "C:\documents and settings\username\Application Data\GreasemonkIE\scripts\", add the following XML:

<script fileName="c:\documents and settings\username\Application Data\GreasemonkIE\scripts\inline.player.user.js" enabled="true" />
GreasemonkIE will pick up any changes to the greasemonkie.xml file and load them on the next page load. Once you've installed some user scripts, you can manage them (includes, excludes, enabled, uninstall) from the "Manage User Scripts..." entry in IE's Tool menu.

I've included Dimitri Glazkov's html-xpath.js script with GreasemonkIE, which supports a good bit of the DOM Level 3 XPath implementation, but it's by no means perfect. It's also quite slow, so I'd recommend avoiding user scripts that use xpath queries. Also, due to inherent differences in the Javascript implementation between IE and FireFox, many user scripts simply will not work with GreasemonkIE. I've tested some, and here's what I've found:

Scripts that work:

Scripts that don't work:
  • Gmail: Adding Persistent Searches
  • Google Suggest - A previous version worked using setTimeout, but this script was recently updated to use addEventListener instead, which IE's scripting model doesn't support. I ran into this on a few other scripts, and I may be able to build a work-around to support addEventListener.
  • (I didn't try a whole lot of scripts, so just because this section is small doesn't mean most scripts work)
In general, scripts that use XPath queries may work but slowly. Scripts that don't use any FireFox-specific script code should work perfectly. Scripts that do won't work at all. As with xpath support, I may be able to build work-arounds for many of these issues, but others will never work.


XBox Live!, Linux, NAT, and UPNP

  • Posted on
  • by
  • in

A little bit of background first. I've been a subscriber to XBox Live! since its launch in November of 2002. For a while, I was on DSL (at my old apartment), and had a nice static IP dedicated solely to the XBox. Later, I bought a house and could no longer get DSL, so I switched to cable. No more nice static IPs, but I paid for a second dynamic IP and strung a looooong ethernet cable across my entire house and hooked up the XBox that way. In both of these cases, life was good. Of course, I couldn't just leave well enough alone. I was annoyed by the long ethernet cable, and Microsoft had just shipped the XBox Wireless Adapter, so I bought it. Now, a bit of background on my wireless setup: I use a Linux machine to do Network Address Translation (NAT) for my internal network (a wired desktop, a wireless laptop, a wireless TiVO, and now a wireless XBox). I've used a similar setup since college, oh so many years ago (I believe the first time I set this up was 1998). Anyway, back to the story. I plugged in the XBox wireless adapter, set it up, and things worked great. The XBox could connect to Live!, and I could play games. Then I noticed that there were some games I couldn't connect to. I lived with it, because there was usually an abundance of games to choose from (btw, my poison of choice is Project Gotham Racing 2 (PGR2)). Now that the game has been out for more than a year, the number of available online games or "rooms" has dwindled, and the "This session is no longer available" message is much more annoying. When there are only four or five available games in the list, and I can only connect to one of those if I'm lucky, my gaming time is spent more on searching for games than actually playing.

Well, I finally decided to do something about it. I was told to check out this page to help diagnose my problem. The key metric here was the "NT" value, or NAT Type. My XBox reported that value as 1, or "open", which means I shouldn't have any problems connecting to online games. And yet, I was. The description of NAT Type 1 is as follows, and gave me my first clue:

Open NAT means that either the port assignment policy is minimal or the router has a fully compliant version of UPnP (Universal Plug and Play) enabled by default.

Get your TiVO ready!

  • Posted on
  • by
  • in

The first two hours of season 4 of 24 air on Sunday night, January 9th, at 8pm PST. The next two hours air on the following Monday. At 9pm on Sunday night, the second season of Carnivale starts up as well. Thankfully, HBO likes to rebroadcast episodes througout the week, so I'll be able to catch Carnivale without having to sacrifice hour two of 24. Now if only The Sopranos would get going with season 6, I'd be a very satisfied television viewer.

Somewhat related, I am now a "digital crack" dealer. I loaned out my DVDs of seasons one and two of 24 to my manager, and now she's complaining about lack of sleep. Just one more hour! As with any drug dealer, I held off on giving her season three at the same time, so she'll be coming back for more.