Spaces:
Build error
Build error
Create userscript.js
Browse files
src/addons/addons/ScratchHighlightFullwidthNumber/userscript.js
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
const target = document.querySelectorAll('.blocklyBlockCanvas');
|
2 |
+
const regexp = /[0-9]/;
|
3 |
+
|
4 |
+
const observer = new MutationObserver(records => {
|
5 |
+
document.querySelectorAll('*[data-argument-type~="text"] text, *[data-argument-type~="number"] text').forEach(e => {
|
6 |
+
if (regexp.test(e.textContent)){
|
7 |
+
e.style.fill = 'red';
|
8 |
+
} else {
|
9 |
+
e.style.fill = '';
|
10 |
+
}
|
11 |
+
});
|
12 |
+
});
|
13 |
+
|
14 |
+
target.forEach(e => {
|
15 |
+
observer.observe(e, {
|
16 |
+
attributes: true,
|
17 |
+
characterData: true,
|
18 |
+
childList: true,
|
19 |
+
subtree: true
|
20 |
+
});
|
21 |
+
});
|