Have you ever noticed how some animals just have more comedy potential than others? I'm not entirely certain why this should be, but it's definitely the case. Cows, for example, are automatically funny. Just ask Gary Larson. Monkeys, too, are funny, as are iguanas. So are sloths. Mice are sometimes the cause of comedy in others, but they're not inherently funny in themselves; chinchillas are funny, labradors are not. The list goes on, and I imagine there's a certain amount of personal preference involved.
There are two principles, however, that I want to stand by firmly. These are:
- Squirrels are funny;
- The world could use more surreality.
With these principles in mind, I embarked on a little adventure into programming. This was the result.
click to expand
If you'd like to perform the same trick yourself (or modify it), you'll need to be running Mozilla Firefox with the Greasemonkey extension. I've included the code behind the cut below. I'm very new to Greasemonkey, so the code's pretty ugly - if you'd like to tidy it up, please feel free. Install at your leisure, and enjoy the weirdness.
UPDATE: Almost forgot to mention that the idea for this is largely based on the CNN Fortune Cookie, created by Ironic Sans, and uses sample code from Dive Into Greasemonkey. Wouldn't want you to entirely blame me...
// ==UserScript==
// @name BBC News Headline Editor
// @namespace http://philonoism.blogspot.com
// @description Adds a custom text string to the end of BBC News headlines.
// @include http://news.bbc.co.uk/*
// ==/UserScript==
var prefix = ''
var phrase = ' with a squirrel' //change the prefix and phrase to whatever you want
var allA, thisA; //to append to the headlines
allA = document.evaluate(
"//a[@class='tsh']",
document,
null,
XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
null);
for (var i = 0; i < allA.snapshotLength; i++) {
thisA = allA.snapshotItem(i);
// do something with thisA
thisA.innerHTML = prefix + thisA.innerHTML + phrase
}
allA = document.evaluate(
"//a[@class='shl']",
document,
null,
XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
null);
for (var i = 0; i < allA.snapshotLength; i++) {
thisA = allA.snapshotItem(i);
// do something with thisA
thisA.innerHTML = prefix + thisA.innerHTML + phrase
}
allA = document.evaluate(
"//a[@class='tsl']",
document,
null,
XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
null);
for (var i = 0; i < allA.snapshotLength; i++) {
thisA = allA.snapshotItem(i);
// do something with thisA
thisA.innerHTML = prefix + thisA.innerHTML + phrase
}
var allDiv, thisDiv;
allDiv = document.evaluate(
"//div[@class='arr']",
document,
null,
XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
null);
for (var i = 0; i < allDiv.snapshotLength; i++) {
thisDiv = allDiv.snapshotItem(i);
// do something with thisDiv
var a_list = thisDiv.getElementsByTagName('a')
for (var j = 0; j < a_list.length; j++){
thisA = a_list[j];
thisA.innerHTML = prefix + thisA.innerHTML + phrase
}
}
allA = document.evaluate(
"//a[@class='pbl']",
document,
null,
XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
null);
for (var i = 0; i < allA.snapshotLength; i++) {
thisA = allA.snapshotItem(i);
// do something with thisDiv
var b_list = thisA.getElementsByTagName('b')
for (var j = 0; j < b_list.length; j++){
thisB = b_list[j];
thisB.innerHTML = prefix + thisB.innerHTML + phrase
}
}
var allUL, thisUL, thisLI;
allUL = document.evaluate(
"//ul[@class='popstoryList']",
document,
null,
XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
null);
for (var i = 0; i < allUL.snapshotLength; i++) {
thisUL = allUL.snapshotItem(i);
// do something with thisDiv
var li_list = thisUL.getElementsByTagName('li')
for (var j = 0; j < li_list.length; j++){
thisLI = li_list[j]
var a_list = thisLI.getElementsByTagName('a')
for (var k = 0; k < a_list.length; k++){
thisA = a_list[k];
thisA.innerHTML = prefix + thisA.innerHTML + phrase
}
}
}
No comments:
Post a Comment