-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgwAddGlyphBoundingBoxes.user.js
94 lines (79 loc) · 2.23 KB
/
gwAddGlyphBoundingBoxes.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// ==UserScript==
// @name GlyphWiki: add glyph bounding boxes
// @version 2023.01.01
// @namespace szc
// @description Add bounding boxes to images, similar to the one in the Glyph Editor
// @match *://glyphwiki.org/wiki/*
// @match *://*.glyphwiki.org/wiki/*/*
// @run-at document-idle
// @grant none
// @inject-into content
// ==/UserScript==
let images = document.querySelectorAll('.glyph, .thumb');
for (let i = 0; i < images.length; i++) {
let image = images.item(i);
let wrapper = document.createElement('div');
let boundingBox = document.createElement('div');
wrapper.classList.add('x-thumbWrapper');
boundingBox.classList.add('x-thumbBoundingBox');
wrapper.innerHTML = image.outerHTML + boundingBox.outerHTML;
image.outerHTML = wrapper.outerHTML;
}
let style = document.createElement('style');
style.innerHTML = `
.x-thumbWrapper {
position: relative;
display: inline-block;
}
.x-thumbBoundingBox{
--margin: calc((12/200) * var(--target));
position: absolute;
top: 0;
border: 1px dotted crimson;
content: "";
height: calc(var(--target) - (var(--margin)) * 2);
width: calc(var(--target) - (var(--margin)) * 2);
margin: calc((var(--margin)));
pointer-events: none;
}
[height="200"] ~ .x-thumbBoundingBox {
--target: 200px;
}
[height="100"] ~ .x-thumbBoundingBox {
--target: 100px;
}
[height="50"] ~ .x-thumbBoundingBox {
--target: 50px;
}
/* グリフの当ページ、最初にリストアップされる奴ら */
div.right_pane img.glyph ~ .x-thumbBoundingBox {
margin:
calc((var(--margin)) + 1em)
calc((var(--margin)) + 0em)
;
}
div.right_pane img.page ~ .x-thumbBoundingBox {
margin:
calc((var(--margin)) + 0em)
calc((var(--margin)) + 0.5em)
;
}
/* 100 */
div.right_pane .thumb ~ .x-thumbBoundingBox,
div.right_pane [height="100"] ~ .x-thumbBoundingBox {
margin:
calc((var(--margin)) + 2px)
;
}
/* 「引用する旧部品の更新」(グリフのページの下に出現する奴) */
div.right_pane img.compare ~ .x-thumbBoundingBox {
font-size: 90%;
margin:
calc((var(--margin)) + 1em)
calc((var(--margin)) + 1em)
calc((var(--margin)) + 0.5em)
calc((var(--margin)) + 1em)
;
}
`;
document.head.appendChild(style);