Skip to content

Commit 46178fb

Browse files
committed
update
1 parent d2f51ef commit 46178fb

8 files changed

+113
-173
lines changed

gwAddContextMenus.user.js

+15-13
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// ==UserScript==
22
// @name GlyphWiki: add context menus
3-
// @version 8
3+
// @version 2023.01.01
44
// @namespace szc
55
// @description -
66
// @match *://glyphwiki.org/wiki/*
@@ -10,9 +10,11 @@
1010
// @inject-into content
1111
// ==/UserScript==
1212

13-
function createIThumbMenu(event) {
13+
// https://developer.mozilla.org/en-US/docs/Mozilla/Firefox/Releases/85
14+
15+
function createThumbMenu(event) {
1416
let menu = document.createElement('menu');
15-
menu.id = 'iThumbMenu-' + event.target.dataset.name;
17+
menu.id = 'thumbMenu-' + event.target.dataset.name;
1618
menu.type = 'context';
1719

1820
let text;
@@ -72,7 +74,7 @@ function createBodyMenu(event) {
7274

7375
text = document.body.dataset.name;
7476
menuItem = document.createElement('menuitem');
75-
menuItem.icon = (document.querySelector('.glyphMain .iThumb50') ? document.querySelector('.glyphMain .iThumb50').src : false);
77+
menuItem.icon = (document.querySelector('.glyphMain [height="50"]') ? document.querySelector('.glyphMain [height="50"]').src : false);
7678
menuItem.innerText = 'グリフ名をコピー' + (text ? ':' + text : '');
7779
menuItem.disabled = (!text);
7880
menuItem.dataset.text = text;
@@ -125,17 +127,17 @@ function createBodyMenu(event) {
125127
document.body.appendChild(menu);
126128
}
127129

128-
function addIThumbMenu() {
129-
let iThumbs = document.getElementsByClassName('iThumb');
130+
function addThumbMenu() {
131+
let thumbs = document.getElementsByClassName('thumb');
130132

131-
for (let i = 0; i < iThumbs.length; i++) {
132-
let menuId = 'iThumbMenu-' + iThumbs[i].dataset.name;
133+
for (let i = 0; i < thumbs.length; i++) {
134+
let menuId = 'thumbMenu-' + thumbs[i].dataset.name;
133135

134-
if (iThumbs[i].dataset.name) {
135-
iThumbs[i].setAttribute('contextmenu', menuId);
136-
iThumbs[i].addEventListener('contextmenu', function(event) {
136+
if (thumbs[i].dataset.name) {
137+
thumbs[i].setAttribute('contextmenu', menuId);
138+
thumbs[i].addEventListener('contextmenu', function(event) {
137139
if (!document.getElementById(menuId)) {
138-
createIThumbMenu(event);
140+
createThumbMenu(event);
139141
}
140142
});
141143
}
@@ -147,7 +149,7 @@ function addBodyMenu() {
147149
createBodyMenu();
148150
}
149151

150-
addIThumbMenu();
152+
addThumbMenu();
151153
if (document.body.dataset.ns == 'glyph') {
152154
addBodyMenu();
153155
}

gwAddGlyphBoundingBoxes.user.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// ==UserScript==
22
// @name GlyphWiki: add glyph bounding boxes
3-
// @version 7
3+
// @version 2023.01.01
44
// @namespace szc
55
// @description Add bounding boxes to images, similar to the one in the Glyph Editor
66
// @match *://glyphwiki.org/wiki/*
@@ -10,7 +10,7 @@
1010
// @inject-into content
1111
// ==/UserScript==
1212

13-
let images = document.querySelectorAll('.iThumb50, .iThumb100, .iThumb200');
13+
let images = document.querySelectorAll('.glyph, .thumb');
1414
for (let i = 0; i < images.length; i++) {
1515
let image = images.item(i);
1616
let wrapper = document.createElement('div');
@@ -42,15 +42,15 @@ style.innerHTML = `
4242
pointer-events: none;
4343
}
4444
45-
.iThumb200 ~ .x-thumbBoundingBox {
45+
[height="200"] ~ .x-thumbBoundingBox {
4646
--target: 200px;
4747
}
4848
49-
.iThumb100 ~ .x-thumbBoundingBox {
49+
[height="100"] ~ .x-thumbBoundingBox {
5050
--target: 100px;
5151
}
5252
53-
.iThumb50 ~ .x-thumbBoundingBox {
53+
[height="50"] ~ .x-thumbBoundingBox {
5454
--target: 50px;
5555
}
5656
@@ -73,7 +73,7 @@ style.innerHTML = `
7373
/* 100 */
7474
7575
div.right_pane .thumb ~ .x-thumbBoundingBox,
76-
div.right_pane .thumb100 ~ .x-thumbBoundingBox {
76+
div.right_pane [height="100"] ~ .x-thumbBoundingBox {
7777
margin:
7878
calc((var(--margin)) + 2px)
7979
;

gwOpenProtectedGlyphInGlyphEditor.user.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// ==UserScript==
22
// @name GlyphWiki: open protected glyphs in the glyph editor
3-
// @version 3
3+
// @version 2023.01.01
44
// @namespace szc
55
// @description -
66
// @match *://glyphwiki.org/wiki/*

gwReplacePngWithSvg.user.js

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// ==UserScript==
22
// @name GlyphWiki: replace PNG with SVG
3-
// @version 7
3+
// @version 2023.01.01
44
// @namespace szc
55
// @description -
66
// @match *://glyphwiki.org/wiki/*
@@ -10,29 +10,28 @@
1010
// @inject-into content
1111
// ==/UserScript==
1212

13-
let pngs = document.querySelectorAll(".iThumbPng:not(.iThumbError)"); // querySelectorAll because it's not live and .length won't change...
13+
let pngs = document.querySelectorAll(".glyph, .thumb"); // querySelectorAll because it's not live and .length won't change...
1414
for (let i = 0; i < pngs.length; i++) {
1515
pngs[i].src = pngs[i].src.replace(/\.\d+px\./, ".").replace(/\.png$/, ".svg");
16-
pngs[i].classList.replace("iThumbPng", "iThumbSvg");
1716
}
1817

1918
let style = document.createElement('style');
2019
style.innerHTML = `
21-
.iThumbSvg {
20+
[src$=".svg"] {
2221
background: white;
2322
}
2423
25-
.iThumbSvg.iThumb50:hover {
24+
[src$=".svg"][height="50"]:hover {
2625
transform: scale(3);
2726
}
2827
29-
.glyphMain.pThumb200.pThumbSvg + .glyphMain.pThumb200.pThumbPng {
28+
.glyphMain:nth-of-type(2) {
3029
display: none;
3130
}
3231
3332
/* gwAddGlyphBoundingBoxes */
3433
35-
.iThumbSvg.iThumb50:hover ~ .x-thumbBoundingBox {
34+
[src$=".svg"][height="50"]:hover ~ .x-thumbBoundingBox {
3635
transform: scale(3);
3736
}
3837
`;

0 commit comments

Comments
 (0)