-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgwUnicodeGlyphNames.user.js
46 lines (38 loc) · 1.13 KB
/
gwUnicodeGlyphNames.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// ==UserScript==
// @name GlyphWiki: convert Unicode codepoints to Unicode in glyph names
// @version 2023.01.01
// @namespace szc
// @description -
// @match *://glyphwiki.org/wiki/*
// @match *://*.glyphwiki.org/wiki/*
// @run-at document-idle
// @grant none
// @inject-into content
// ==/UserScript==
let as = document.querySelectorAll('a[data-name^="u"], a[data-user-glyph-name^="u"], a[data-name*="-u"]');
for (let i = 0; i < as.length; i++) {
for (let j = 0; j < as[i].childNodes.length; j++) {
let textOrig = as[i].childNodes[j].textContent;
let textUni = textOrig;
textUni = unsafeWindow.SH.nameToUnicode(textUni);
if (textOrig != textUni) {
let ruby = document.createElement('ruby');
let rt = document.createElement('rt');
ruby.classList.add('uniRuby');
ruby.innerText = textOrig;
rt.innerText = textUni;
ruby.appendChild(rt);
as[i].childNodes[j].replaceWith(ruby);
}
}
}
let style = document.createElement('style');
style.innerHTML = `
ruby.uniRuby rt {
font-size: inherit;
color: black;
opacity: 0.75;
ruby-align: center;
}
`;
document.head.appendChild(style);