imdb runtimes in hours and minutes

By znerp Last update Nov 15, 2009 — Installed 1,334 times.

Archived Comments (locked)

in
Subscribe to Archived Comments 8 posts, 6 voices



Jesse Andrews Admin

The following is an archive of comments made before threaded discussions was implemented (November 16th, 2008)

 
znerp Script's Author

@Chicago_gangster: Glad that you like the script, and I can understand why you'd want change it, but I'll leave the script as it is here. I would recommend however that you change the return line to the following instead though;

return (hours + ":" + (minutes < 10 ? "0" : "") + minutes);
This way, titles under an hour will show eg. 0:30 instead of just 30, and films with minutes less than 10 over the hour will show as eg. 3:08 instead of 3:8 (this is for the Green Mile, if you wish to test this).

 
Chicago_gang... Scriptwright

Thanks.

I switched to the 0:00 format (i.e. "2:15" instead of "2 hours, 15 minutes"). If anyone else wants to do it, replace
return (hours > 0 ? hours + pl(hours, " hour") + ", " : "") + minutes + pl(minutes, " minute");
with:
(edited out - see the next reply; thanks znerp)
and delete the "pl" function.

 
Hiromacu Scriptwright

Nice! Your modified script is much more better than my! I'm not a programmer, I know just a little bit. :P

 
Dink Scriptwright

Thanks!!....Another great IMDB script!!!

 
Hiromacu Scriptwright

And need to add an include: http://us.imdb.com/title/tt*

 
Hiromacu Scriptwright

Hi znerp!

I changed your script I don't like the abbreviations. So I replaced the 'hrs' and 'mins' abbreviations to the full hour - hours and minute - minutes words.
But this script is great!

Modified full script:

// ==UserScript==
// @name IMDB runtimes in hours and minutes (changed by Hiromacu)
// @namespace znerp
// @description Converts the runtime for films on IMDB from minutes into hours and minutes.
// @include http://www.imdb.com/title/tt*
// ==/UserScript==

/***********************************************************************
* I don't like the abbreviations.
* So I replaced the 'hrs' and 'mins' abbreviations to the full hour - hours and minute - minutes words.
* But this script is great!
*
* - Hiromacu -
*/

infos = document.evaluate("//div[@id='tn15content']/div[@class='info']",
document,
null,
XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
null)

for (i = infos.snapshotLength - 1; i >= 0; i--) {
if (/Runtime:/.test((time = infos.snapshotItem(i)).innerHTML)) {
time.innerHTML = time.innerHTML.replace(/(\d+) min/g, hourize);
break;
}
}

function hourize(str, p1, offset, s) {
var htxt;
var mtxt;
minutes = parseInt(p1)
hours = Math.floor(p1 / 60);
if (hours > 1) {
htxt = "hours";
}
else {
htxt = "hour";
}
minutes = p1 % 60;
if (minutes > 1) {
mtxt = "minutes";
}
else {
mtxt = "minute";
}
return (hours > 0 ? hours + " " + htxt+ ", " : "") + minutes + " " + mtxt;
}

 
Neewb Scriptwright

Niccccce !

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