Replace symbol font tags with Greek HTML entities (2015-11-05)
- // ==UserScript==
- // @name Symbol Font to Greek Entities
- // @author Jefferson "jscher2000" Scher
- // @namespace JeffersonScher
- // @description Replace symbol font tags with Greek HTML entities (2015-11-05)
- // @version 0.2
- // @include http://www.wildwinds.com/coins/greece/*
- // @copyright Copyright 2015 Jefferson Scher
- // @license BSD 3-clause
- // @grant none
- // ==/UserScript==
- // CHARACTERS NOT FOUND IN THE OBJECT REMAIN UNCHANGED IN THE CONVERTED STRING
- var ge = {
- "A": "Α",
- "B": "Β",
- "G": "Γ",
- "D": "Δ",
- "E": "Ε",
- "Z": "Ζ",
- "H": "Η",
- "Q": "Θ",
- "I": "Ι",
- "K": "Κ",
- "L": "Λ",
- "M": "Μ",
- "N": "Ν",
- "X": "Ξ",
- "O": "Ο",
- "P": "Π",
- "R": "Ρ",
- "S": "Σ",
- "T": "Τ",
- "U": "Υ",
- "F": "Φ",
- "C": "Χ",
- "Y": "Ψ",
- "W": "Ω",
- "a": "α",
- "b": "β",
- "g": "γ",
- "d": "δ",
- "e": "ε",
- "z": "ζ",
- "h": "η",
- "q": "θ",
- "i": "ι",
- "k": "κ",
- "l": "λ",
- "m": "μ",
- "n": "ν",
- "x": "ξ",
- "o": "ο",
- "p": "π",
- "r": "ρ",
- "V": "ς",
- "s": "σ",
- "t": "τ",
- "u": "υ",
- "f": "φ",
- "c": "χ",
- "y": "ψ",
- "w": "ω",
- "J": "ϑ",
- "j": "ϕ",
- "v": "ϖ"
- }
- // define a new tag for the greek entity string, insert style rules
- var getag = document.createElement("sftgetag");
- var sty = document.createElement("style");
- sty.type = "text/css";
- sty.appendChild(document.createTextNode("font[SFTGE]{display:none;} sftgetag{display:inline;} sftgetag:hover{background:#cff;}"));
- document.body.appendChild(sty);
- // Read symbol font tags and built greek entity tags to replace them
- var gf = document.querySelectorAll('font[face="SYMBOL"],font[face="symbol"]');
- for (var i=0; i<gf.length;i++){
- if (!gf[i].hasAttribute("SFTGE")){
- var txt = gf[i].textContent, txtnew = "";
- for (var j=0; j<txt.length; j++){
- txtnew += ge[txt.substr(j,1)] || txt.substr(j,1);
- }
- var txttag = getag.cloneNode(true);
- txttag.innerHTML = txtnew;
- txttag.setAttribute("title", txt);
- gf[i].parentNode.insertBefore(txttag, gf[i]);
- gf[i].setAttribute("SFTGE", "done");
- }
- }