Skip to content

Instantly share code, notes, and snippets.

@xk
Created December 21, 2013 19:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xk/8073619 to your computer and use it in GitHub Desktop.
Save xk/8073619 to your computer and use it in GitHub Desktop.
Pone la hora de finalización al lado del artículo
javascript:[].filter.call(document.getElementsByClassName("g-clTRght"), function (e) {
return /^[0-9]+[hHmMsM]/.test(e.innerHTML);
}).forEach(function (e) {
var r, h, p, hora, minuto, segundo;
var txt= e.innerHTML;
if (/^[0-9]+[hH]/.test(txt)) {
r= /^([0-9]+)[hH] ([0-9]+)[mM]/.exec(txt);
h= new Date(Date.now() + (r[1]*60*60*1000) + (r[2]*60*1000));
}
else if (/^[0-9]+[mM]/.test(txt)) {
r= /^([0-9]+)[mM]/.exec(txt);
h= new Date(Date.now() + (r[1]*60*1000));
}
else if (/^[0-9]+[sS]/.test(txt)) {
r= /^([0-9]+)[sS]/.exec(txt);
h= new Date(Date.now() + (r[1]*1000));
}
hora= h.getHours() < 10 ? "0" + h.getHours() : h.getHours();
minuto= h.getMinutes() < 10 ? "0" + h.getMinutes() : h.getMinutes();
segundo= h.getSeconds() < 10 ? "0" + h.getSeconds() : h.getSeconds();
p= e.parentNode.appendChild(document.createElement('p'));
p.className= "g-abcc66 g-clTRght";
p.style.color= "red";
p.innerHTML= hora + ":" + minuto + ":" + segundo;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment