Created
February 5, 2010 11:55
-
-
Save rjp/295733 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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