Eniro.se telephone number large type

Written . Tagged Firefox, Greasemonkey, JavaScript.

A brilliant, somewhat hidden feature in the OS X Address Book is that you can click a telephone number and select “Large Type” to enlarge the number in an OSD. The idea is presumably to enable you to see the number from across the room, where your phone might be.

I wrote a new userscript, Eniro.se telephone number large type, to bring this feature to the online Swedish telephone directory Eniro.se.

[Screenshot: Eniro.se large type]

Some nice features of this script is that the number remains centered on the screen until discarded (by clicking anywhere or pressing any key), and that the font is set to the maximum size that fits within the width of the window.

Sometime in the future, I plan on adding support for the directory Hitta.se as well. I haven’t done so yet because the site splits numbers up across several span tags, and does some other things different enough from Eniro.se to make things annoying.

I’m also considering making a general purpose “Large Type” userscript or bookmarklet, for any text you highlight.

Incidentally, when writing this script, I found that window.innerWidth would in fact include the width of the scrollbar, which messed up the centering. I hope there is some better solution out there, but this seemed to do the trick:

1
2
var bs = getComputedStyle(document.body, '');
var widthWithoutScrollbar = parseInt(bs.getPropertyValue("width"), 10) + parseInt(bs.getPropertyValue("margin-left"), 10) + parseInt(bs.getPropertyValue("margin-right"), 10);