Limit del.icio.us description field to 255 characters

By Phil Wilson Last update Mar 31, 2009 — Installed 497 times. Daily Installs: 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0

There are 1 previous version of this script.

// ==UserScript==
// @name           Limit del.icio.us description field to 255 characters
// @namespace      http://philwilson.org/
// @include        http://del.icio.us/*
// ==/UserScript==

(function() {

  var desc = document.getElementById("description");
  desc.maxLength = "255";

   function setMaxLength()
   {
      var counter = document.createElement('span');
      counter.className = 'counter';
      counter.innerHTML = ' <span>'+desc.value.length+'</span>/'+desc.getAttribute('maxlength');
      desc.parentNode.insertBefore(counter,desc.nextSibling);

      document.addEventListener("keyup",checkMaxLength,true);
      desc.onKeyUp();
   }

   function checkMaxLength()
   {
      var maxLength = 255;
      var currentLength = desc.value.length;
      // stupid text nodes.
      desc.nextSibling.firstChild.nextSibling.firstChild.nodeValue = currentLength;
   }

   window.addEventListener("load", function(e) { setMaxLength(); }, false);   

})();