5

Description

This is a small userscript I made that shows the amount of characters in a code block above it. It is mainly for the http://codegolf.stackexchange.com site.

Screenshot

(This is just some random answer on codegolf.SE.)

image

Code

(minified)

$("pre code").each(function(){$(this).parent().before('<div style="border: 1px dotted #C0D4DB; border-bottom: none; border-radius: 5px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; padding: 3px; font: 12px monospace; display: inline; background-color: #F7FDFF; margin-left: 5px">'+$(this).text().trim().replace(/&amp;|&lt;|&gt;|&quot;|&#039;/g," ").length+" chars</div>")})

Type javascript: in the URL bar, and paste this after it. (or just paste it into the console)

Userscript

http://userscripts.org/scripts/show/178565

6
  • I wrote a similar script a long time back but later abandoned it. I like the style of yours. Oct 19, 2013 at 3:57
  • Just a bit of clarification if you don't mind: /&amp;|&lt;|&gt;|&quot;|&#039;/g. Wouldn't this not count characters when someone uses html entities for codegolf?
    – Mohammad
    Feb 15, 2014 at 18:08
  • @user689 It replaces them with spaces, so it still counts them.
    – Doorknob
    Feb 15, 2014 at 18:10
  • But it would count them as a 1 character and not 4. Why are you using this in the first place?
    – Mohammad
    Feb 15, 2014 at 18:12
  • @user689 Because they are one character, not 4. If I didn't have that they would be counted as 4.
    – Doorknob
    Feb 15, 2014 at 18:12
  • Userscript link is b0rked - where can we obtain this? Jan 16, 2019 at 15:15

0

You must log in to answer this question.

Browse other questions tagged .