Skip to content

Instantly share code, notes, and snippets.

@rjp
Created February 5, 2010 11:55
Show Gist options
  • Save rjp/295733 to your computer and use it in GitHub Desktop.
Save rjp/295733 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name BBC Date Highlighter
// @namespace rjp
// @description highlight old dates on the BBC
// @include http://news.bbc.co.uk/*
// ==/UserScript==
var snapTextNodes = null;
var lu_date = null;
var now = new Date();
snapTextNodes = document.evaluate("//div[@class='ds']", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
if (snapTextNodes.snapshotLength > 0) {
alert("before");
var elm = snapTextNodes.snapshotItem(0);
var lu = elm.textContent.replace(/^.* at /,'');
lu_date = Date.parse(lu.replace(/^(.*T), (.*)$/,"$2 $1"));
if (now - lu_date > 3*86400*1000) {
elm.innerHTML = "Page last updated at <span style='color:white;font-weight:bold;background-color:red;font-size:x-large'>"+lu+"</span>";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment