Page Age

By Vaughan Chandler Last update Jun 8, 2007 — Installed 540 times.

Tweaks I've made to the script

in
Subscribe to Tweaks I've made to the script 2 posts, 2 voices



ns4tne Scriptwright
FirefoxWindows

Vaughan, I don't know if you (or anyone else) are still interested in this script, but I figured I'd share some tweaks I made to the script.

// ==UserScript==
// @name		Page Age
// @namespace	http://userscripts.org/people/14536
// @description	Shows the "age" of a web page.
// @include		*
// @author		Vaughan Chandler, ns4tne
// ==/UserScript==

// Last edited June 8 2007
// Edited by user 2008-12-10 to change time formatting, opacity; make clean with Facebook
// Edited by user 2009-03-05, 2009-05-04, and 2009-05-05 to change tooltip formatting
//    (dates are always good, and UTC is even better)

if (top.location == location) {
    
    function switchMode() {
        if (timing) {
            window.clearTimeout(timer);
            d.innerHTML = timeString;
        } else { updateElapsed(); }
        timing = !timing;
        if (GM_setValue) { GM_setValue('timing',timing); }
    }
   
    function updateElapsed() {
        var n = new Date();
        var x = (n.getTime() - t.getTime())/1000;
        if (x<60) { d.innerHTML = Math.floor(x) + 's'; }
        else if (x<3600) { d.innerHTML = Math.floor(x/60) + 'm'; }
        else { d.innerHTML = Math.floor(x/3600) + 'h'; }
        timer=setTimeout(updateElapsed, 1000);
    }
   
    var t = new Date();
    var timer;
    var timing;
    if (GM_getValue) { timing = GM_getValue('timing',true); }
    else { timing = true; }
   
    var head = document.getElementsByTagName('head')[0];
    if (!head) { return; }
    var style = document.createElement("style");
    style.type = "text/css";
    style.innerHTML = '#pageAgeTimer { position:fixed; bottom:30px; right:15px; text-align:right; '+
        ' font-family:monospaced; font-size:12px; color:#888888; background:#ffffff; opacity:0.9; '+
        ' border:1px solid #dddddd; padding:2px; cursor:default; z-index:999999; }'+
        '#pageAgeTimer:hover { background:#eef6ff; font-size:16px; opacity: 1; }';
    head.appendChild(style);
   
    var timeString = (new Date()).toLocaleTimeString();
    var dateString = (new Date()).toLocaleString();
    var dateStringUTC = (new Date()).toUTCString();
   
    var d = document.createElement('div');
    d.id = 'pageAgeTimer';
    d.addEventListener("click",switchMode,true);
    d.addEventListener("dblclick",function(){document.getElementById('pageAgeTimer').style.display='none';},true);
    d.title = 'Page loaded ' + dateString + " (" + dateStringUTC + ")";
    document.body.appendChild(d);

    if (timing) {
        d.innerHTML = '--';
        updateElapsed();
    } else { d.innerHTML = timeString; }
   
}

 
Vaughan Chan... Script's Author
FirefoxX11

Hi ns4tne, I'll check out your modifications as soon as I can.

Cross
Presentational HTML allowed.
Use <code> for inline code and <pre> for code blocks. Use &lt; and &gt; for literal < and >.
We help break paragraphs and link your links.
or cancel