Guest User

Untitled

a guest
Jan 4th, 2015
374
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         Facebook real time time
  3. // @match        https://www.facebook.com/*
  4. // @grant        none
  5. // ==/UserScript==
  6.  
  7. function update_timestamps () {
  8.     function pretty_time (time) {
  9.       hours = Math.floor(time / 3600)
  10.       minutes = Math.floor(time / 60) - hours * 60;
  11.       seconds = time % 60;
  12.       function pad (n) {return ('0' + n).substr(-2)};
  13.       pretty = pad(hours) + ':' + pad(minutes) + ':' + pad(seconds);
  14.       return pretty;
  15.     }
  16.     abbrs = document.getElementsByTagName('abbr');
  17.     current = new Date().getTime() / 1000 | 0;
  18.     for (i in abbrs) {
  19.       try {
  20.         abbrs[i].attributes['data-utime']
  21.       } catch (e) {
  22.         continue;
  23.       }
  24.       diff = current - parseInt(abbrs[i].attributes['data-utime'].value);
  25.       if (diff < 3 * 60 * 60)
  26.         abbrs[i].innerHTML = pretty_time(diff);
  27.     }
  28.     setTimeout(update_timestamps, 1000);
  29. }
  30. update_timestamps();
RAW Paste Data