(or emacs irrelevant)

Monkeying around with JavaScript

Exciting encounter

Recently, I happened upon a wonderful blog called The Axis of Eval. I knew that I'd love it just when I read the name. (or emacs pales in comparison, but I couldn't just sit on my hands for months or years while thinking up a perfect blog name. If you think of a blog name as awesome as "The Axis of Eval" and are willing to let me use it, I'll probably make the switch.

The blog did not disappoint, featuring gems like this:

In the Lisp world, new languages are built by combining large, battle-tested building blocks, and polishing or updating them when needed, instead of starting over from toothpicks and double-sided duct tape. A large Lisp like Common Lisp is like a toolchain of decades-old tools that have proven their worth, and have been codified in standards, folklore, and implementations.

The only thing in the way of extracting information and enjoyment from this blog was the horrendous theme of black background, white foreground and magenta links. Plus the RSS was kind of quirky, and I couldn't just feed all of it into Elfeed.

Greasemonkey to the rescue!

In the previous post I've mentioned that, in addition to using the best editor, I'm using the best browser. Well, this particular best browser has an extension called Greasemonkey that allows you to automatically run your own JavaScript on certain websites.

I'm not very proficient in JavaScript, the following code I just found by searching around. The part to note is the @include - the pattern of website names for which this script should be run automatically.

// ==UserScript==
// @name        background
// @namespace   abo-abo
// @include     http://axisofeval.blogspot.nl/*
// @version     1
// @grant       none
// ==/UserScript==
(function () {
    document
        .body
        .setAttribute("style",
                      "background-color: #ffffff; color:#000");
    var nodesArray = document.getElementsByTagName('a');
    for (var i = 0; i < nodesArray.length; i++) {
        nodesArray[i].style.color = 'red';
    }
})();

I can barely stand to look at it. How could you take Scheme and turn it into this monstrosity? Such a shame. But it works, so I guess everyone should learn JavaScript. All hail the mighty HypnoToad JavaScript!