-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.html
254 lines (245 loc) · 6.97 KB
/
index.html
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
<script src="https://unpkg.com/vue@next/dist/vue.global.js"></script>
<div class="navbar"><h1>Extension Store Description Tool</h1></div>
<div id="app">
<div v-for="lang in languages" class="lang-container">
<p class="lang">{{ lang }}</p>
<button @click="copy(lang)">{{ strings[lang]?.copied ? "Copied!" : "Copy" }}</button>
<button @click="copyEdge(lang)">{{ strings[lang]?.copiedEdge ? "Copied Edge!" : "Copy Edge" }}</button>
<span
v-if="strings[lang]"
:style="{color: strings[lang].scratchCount > 6 ? 'red' : 'inherit'}"
> "scratch" count: {{ strings[lang].scratchCount }}</span
>
</div>
</div>
<script>
const vue = Vue.createApp({
data() {
return {
languages: [
"en", // Must be on top
"de",
"es",
"fr",
"hu",
"it",
"ja",
"ko",
"nl",
"pl",
"pt_BR",
"pt_PT",
"ro",
"ru",
"sl",
"th",
"tr",
"zh_CN",
"zh_TW",
],
strings: {},
text: {},
};
},
async mounted() {
for (const lang of this.languages) {
this.strings[lang] = {};
this.text[lang] = {};
const res = await fetch(
`https://raw.githubusercontent.com/ScratchAddons/ScratchAddons/master/_locales/${lang}/messages.json`
);
const json = await res.json();
const keys = [
"extensionDescription",
"extensionStoreDescription1",
"extensionStoreDescription2",
"extensionStoreDescription3",
"extensionStoreDescription4",
];
this.strings[lang].scratchCount = 0;
for (const key of keys) {
this.strings[lang][key] = json[key]?.message || this.strings.en[key];
this.strings[lang].scratchCount += (
this.strings[lang][key].match(/scratch/gi) || []
).length;
}
}
},
methods: {
copy(lang) {
if (this.strings[lang].scratchCount > 6) {
const res = confirm("Are you sure? This goes over the keyword limit")
if (!res) return;
}
const s = this.strings[lang];
s.copied = true;
setTimeout(() => (s.copied = false), 2000);
const str = `${s.extensionStoreDescription1}
${s.extensionStoreDescription2}
${s.extensionStoreDescription3}
${s.extensionStoreDescription4}`;
navigator.clipboard.writeText(str);
},
copyEdge(lang) {
if (this.strings[lang].scratchCount > 6) {
const res = confirm("Are you sure? This goes over the keyword limit")
if (!res) return;
}
const s = this.strings[lang];
s.copiedEdge = true;
setTimeout(() => (s.copiedEdge = false), 2000);
const str = `${s.extensionDescription}
${s.extensionStoreDescription2}
${s.extensionStoreDescription3}
${s.extensionStoreDescription4}`;
navigator.clipboard.writeText(str);
},
},
}).mount("#app");
</script>
<style>
html {
background: #2a2a2a;
}
body {
background: #222;
font-family: "Sora", sans-serif;
margin: 0;
color: white;
font-size: 12px;
}
button {
color: #fff;
background: #222222;
border: 1px solid #000;
padding: 8px 12px;
border-radius: 4px;
transition: 0.25s ease;
outline: none;
height: 32px;
font-family: inherit;
font-size: 12px;
}
button:hover {
outline: none;
background: #151515;
}
#app {
margin: 1em;
}
.navbar {
height: 60px;
background: #ff7b26;
color: #fff;
display: flex;
align-items: center;
padding: 0 20px;
filter: drop-shadow(0 0 5px rgba(0, 0, 0, 0.5));
user-select: none;
}
.lang {
width: 75px;
display: inline-block;
}
h1 {
font-size: 18px;
margin: 0;
font-weight: 400;
}
.lang-container {
font-size: 22px;
margin-bottom: 8px;
}
/* latin-ext */
@font-face {
font-family: "Sora";
font-style: normal;
font-weight: 300;
font-display: swap;
src: url(https://fonts.gstatic.com/s/sora/v1/xMQbuFFYT72XzQspDre2.woff2)
format("woff2");
unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB,
U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
font-family: "Sora";
font-style: normal;
font-weight: 300;
font-display: swap;
src: url(https://fonts.gstatic.com/s/sora/v1/xMQbuFFYT72XzQUpDg.woff2)
format("woff2");
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212,
U+2215, U+FEFF, U+FFFD;
}
/* latin-ext */
@font-face {
font-family: "Sora";
font-style: normal;
font-weight: 400;
font-display: swap;
src: url(https://fonts.gstatic.com/s/sora/v1/xMQbuFFYT72XzQspDre2.woff2)
format("woff2");
unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB,
U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
font-family: "Sora";
font-style: normal;
font-weight: 400;
font-display: swap;
src: url(https://fonts.gstatic.com/s/sora/v1/xMQbuFFYT72XzQUpDg.woff2)
format("woff2");
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212,
U+2215, U+FEFF, U+FFFD;
}
/* latin-ext */
@font-face {
font-family: "Sora";
font-style: normal;
font-weight: 500;
font-display: swap;
src: url(https://fonts.gstatic.com/s/sora/v1/xMQbuFFYT72XzQspDre2.woff2)
format("woff2");
unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB,
U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
font-family: "Sora";
font-style: normal;
font-weight: 500;
font-display: swap;
src: url(https://fonts.gstatic.com/s/sora/v1/xMQbuFFYT72XzQUpDg.woff2)
format("woff2");
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212,
U+2215, U+FEFF, U+FFFD;
}
/* latin-ext */
@font-face {
font-family: "Sora";
font-style: normal;
font-weight: 600;
font-display: swap;
src: url(https://fonts.gstatic.com/s/sora/v1/xMQbuFFYT72XzQspDre2.woff2)
format("woff2");
unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB,
U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
font-family: "Sora";
font-style: normal;
font-weight: 600;
font-display: swap;
src: url(https://fonts.gstatic.com/s/sora/v1/xMQbuFFYT72XzQUpDg.woff2)
format("woff2");
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212,
U+2215, U+FEFF, U+FFFD;
}
</style>