BAC Live Entry Rating

Published on 12 December 2024 at 22:14

If you are in the San Francisco, Bay Area then you likely know of and have attended Bay Area Chess (BAC) tournaments.  I have no complaints about BAC except that their Live Entry page does not list the ratings of the players that have registered.  The list looks like the screenshot below.  There is a USCF ID, but no rating information.  You can manually lookup the USCF id's, but that takes a long time.

 

 

The ratings lookup can be automated by using Tampermonkey and Node.js scripts.  When active, the USCF rating will be displayed next to the USCF ID as seen below.  The USCF ID will also be converted to a link to the player page at uschess.org.

 

How does it work?

This tool requires two items

  • TamperMonkey script that runs when you load the BAC Live Entries page
  • Node.js script that is called by the TamperMonkey script and scrapes the USCF data the website
    • Node.js functions as a proxy to get the USCF data, as calling directly from the BAC Live Entries page would require cross site scripting.

 

 

Installation

 

  1. Install Tampermonkey extension.  Tampermonkey works with all major browsers including Chrome, FIrefox, Edge, Saffari, etc...
    1. https://www.tampermonkey.net/
  2. Install BAC script via this link
    1. https://greasyfork.org/en/scripts/520562-bay-area-chess-number-linkifier-with-rating-extraction
  3. Install Node.js
    1. https://nodejs.org/en/download/package-manager
  4. Copy the script below, save to a file, and run with node
    1. node "c:\bac-proxy-server.js"

 

Node.js script

===================================

const express = require('express');

const request = require('request');

const app = express();

const PORT = 3000;

 

// Middleware to handle CORS

app.use((req, res, next) => {

    res.header('Access-Control-Allow-Origin', '*');

    res.header('Access-Control-Allow-Methods', 'GET');

    res.header('Access-Control-Allow-Headers', 'Content-Type');

    next();

});

 

app.use((req, res) => {

    const url = `https://www.uschess.org${req.url}`;

console.log(`Request: ` + url);

    req.pipe(request(url)).pipe(res);

});

 

app.listen(PORT, () => {

    console.log(`Proxy server running on http://localhost:${PORT}`);

});

===============================================

 

5. Open the Bay Area Chess website and view live entries for an event.  When working you should see

  1. node window is showing the URL's it is connecting too
  2. BAC web page is showing the ratings of the players next to the USCF ID

What about other websites?

This tool can be easily extended to work on any website.  The TamperMonkey script is searching for all 8 digit numbers on the page and quering them against uschess.org.  To allow it to work on another website, just add the sites URL to the @match section at the top of the TamperMonkey script.