🏠 Home 

Symbol Font to Greek Entities

Replace symbol font tags with Greek HTML entities (2015-11-05)


Install this script?
  1. // ==UserScript==
  2. // @name Symbol Font to Greek Entities
  3. // @author Jefferson "jscher2000" Scher
  4. // @namespace JeffersonScher
  5. // @description Replace symbol font tags with Greek HTML entities (2015-11-05)
  6. // @version 0.2
  7. // @include http://www.wildwinds.com/coins/greece/*
  8. // @copyright Copyright 2015 Jefferson Scher
  9. // @license BSD 3-clause
  10. // @grant none
  11. // ==/UserScript==
  12. // CHARACTERS NOT FOUND IN THE OBJECT REMAIN UNCHANGED IN THE CONVERTED STRING
  13. var ge = {
  14. "A": "Α",
  15. "B": "Β",
  16. "G": "Γ",
  17. "D": "Δ",
  18. "E": "Ε",
  19. "Z": "Ζ",
  20. "H": "Η",
  21. "Q": "Θ",
  22. "I": "Ι",
  23. "K": "Κ",
  24. "L": "Λ",
  25. "M": "Μ",
  26. "N": "Ν",
  27. "X": "Ξ",
  28. "O": "Ο",
  29. "P": "Π",
  30. "R": "Ρ",
  31. "S": "Σ",
  32. "T": "Τ",
  33. "U": "Υ",
  34. "F": "Φ",
  35. "C": "Χ",
  36. "Y": "Ψ",
  37. "W": "Ω",
  38. "a": "α",
  39. "b": "β",
  40. "g": "γ",
  41. "d": "δ",
  42. "e": "ε",
  43. "z": "ζ",
  44. "h": "η",
  45. "q": "θ",
  46. "i": "ι",
  47. "k": "κ",
  48. "l": "λ",
  49. "m": "μ",
  50. "n": "ν",
  51. "x": "ξ",
  52. "o": "ο",
  53. "p": "π",
  54. "r": "ρ",
  55. "V": "ς",
  56. "s": "σ",
  57. "t": "τ",
  58. "u": "υ",
  59. "f": "φ",
  60. "c": "χ",
  61. "y": "ψ",
  62. "w": "ω",
  63. "J": "ϑ",
  64. "j": "ϕ",
  65. "v": "ϖ"
  66. }
  67. // define a new tag for the greek entity string, insert style rules
  68. var getag = document.createElement("sftgetag");
  69. var sty = document.createElement("style");
  70. sty.type = "text/css";
  71. sty.appendChild(document.createTextNode("font[SFTGE]{display:none;} sftgetag{display:inline;} sftgetag:hover{background:#cff;}"));
  72. document.body.appendChild(sty);
  73. // Read symbol font tags and built greek entity tags to replace them
  74. var gf = document.querySelectorAll('font[face="SYMBOL"],font[face="symbol"]');
  75. for (var i=0; i<gf.length;i++){
  76. if (!gf[i].hasAttribute("SFTGE")){
  77. var txt = gf[i].textContent, txtnew = "";
  78. for (var j=0; j<txt.length; j++){
  79. txtnew += ge[txt.substr(j,1)] || txt.substr(j,1);
  80. }
  81. var txttag = getag.cloneNode(true);
  82. txttag.innerHTML = txtnew;
  83. txttag.setAttribute("title", txt);
  84. gf[i].parentNode.insertBefore(txttag, gf[i]);
  85. gf[i].setAttribute("SFTGE", "done");
  86. }
  87. }