// ==UserScript==
// @name        Dingbat Display
// @namespace   http://www.scss.com.au/family/andrew/opera/userjs/
// @version     1.0
// @date        2005-04-25
// @author      Andrew Gregory <andrew at scss dot com dot au>
// @description Converts attempts to use Windows dingbat fonts into
//              correct Unicode usage.
// @include     *
// ==/UserScript==
// License:     http://creativecommons.org/licenses/by-nc-sa/2.0/
document.addEventListener('load', function() {
  var i, j, txt, font, fonts = document.getElementsByTagName('font');
  for (i = 0; i < fonts.length; i++) {
    font = fonts[i];
    if (font.hasAttribute('face') && font.getAttribute('face').toLowerCase() == 'wingdings') {
      font.setAttribute('face', 'Arial');
      for (j = 0; j < font.childNodes.length; j++) {
        if (font.childNodes[j].nodeType == 3) {
          txt = font.childNodes[j].nodeValue;
          txt = txt.replace(/J/, String.fromCharCode(0x263a));
          txt = txt.replace(/K/, '-');
          txt = txt.replace(/L/, String.fromCharCode(0x2639));
          txt = txt.replace(/s/, String.fromCharCode(0x25c6));
          font.childNodes[j].nodeValue = txt;
        }
      }
    }
  }
}, false);
