This repository was archived by the owner on Aug 10, 2026. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
305 lines (260 loc) · 11 KB
/
Copy pathindex.html
File metadata and controls
305 lines (260 loc) · 11 KB
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
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Banned-words Editor</title>
<style>
body { background: #121212; color: #fff; font-family: monospace; margin: 0; display: flex; flex-direction: column; height: 100vh; }
header { padding: 10px; background: #1e1e1e; border-bottom: 1px solid #333; display: flex; gap: 5px; flex-wrap: wrap; align-items: center; }
input, button { background: #333; color: #fff; border: 1px solid #555; padding: 6px; font-family: monospace; }
button { cursor: pointer; background: #007acc; border: none; font-weight: bold; }
button:hover { background: #005f9e; }
button:disabled { background: #555; cursor: not-allowed; }
.main { display: flex; flex: 1; overflow: hidden; }
.sidebar { width: 220px; border-right: 1px solid #333; overflow-y: auto; padding: 10px; background: #1a1a1a; }
.file { padding: 6px; cursor: pointer; word-break: break-all; margin-bottom: 2px; }
.file:hover { background: #333; }
.file.active { background: #007acc; }
.editor-wrap { flex: 1; display: flex; flex-direction: column; padding: 10px; }
.tools { margin-bottom: 10px; display: flex; gap: 5px; }
textarea { flex: 1; background: #1e1e1e; color: #ccc; border: 1px solid #333; padding: 10px; font-family: monospace; resize: none; outline: none; }
</style>
</head>
<body>
<header>
<input type="text" id="user" placeholder="User" value="readme-SVG">
<input type="text" id="repo" placeholder="Repo" value="Banned-words">
<input type="text" id="branch" value="main" style="width: 60px;">
<input type="password" id="token" placeholder="PAT Token">
<button onclick="loadRepo()">Load</button>
<span id="status" style="margin-left: 10px; color: #888;">Ready</span>
</header>
<div class="main">
<div class="sidebar" id="list">Files will appear here...</div>
<div class="editor-wrap">
<div class="tools" id="tools" style="display: none;">
<button onclick="processAll()" id="btnProcessAll" style="background: #e53935;">Process ALL (Clean & Sort)</button>
<button onclick="dedup()" style="background: #4caf50;">Remove Duplicates</button>
<button onclick="sortAsc()" style="background: #4caf50;">Sort A-Z</button>
<div style="margin-left: auto; display: flex; gap: 5px;">
<button onclick="saveFile()" id="btnSave">Save Current</button>
<button onclick="saveAll()" id="btnSaveAll" style="background: #ff9800;">Save ALL</button>
</div>
</div>
<textarea id="editor" disabled></textarea>
</div>
</div>
<script>
let currentFile = null;
let repoFiles = [];
let fileCache = {};
function b64EncodeUnicode(str) {
return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, function(match, p1) {
return String.fromCharCode('0x' + p1);
}));
}
function setStatus(msg, color = "#fff") {
const el = document.getElementById('status');
el.textContent = msg;
el.style.color = color;
}
async function loadRepo() {
const user = document.getElementById('user').value.trim();
const repo = document.getElementById('repo').value.trim();
const branch = document.getElementById('branch').value.trim() || 'main';
const token = document.getElementById('token').value.trim();
if (!user || !repo || !token) return alert("Fill User, Repo, and Token");
setStatus("Loading...", "yellow");
document.getElementById('list').innerHTML = '';
document.getElementById('tools').style.display = 'none';
document.getElementById('editor').value = '';
document.getElementById('editor').disabled = true;
fileCache = {};
currentFile = null;
try {
const res = await fetch(`https://api.github.com/repos/${user}/${repo}/git/trees/${branch}?recursive=1`, {
headers: { 'Authorization': `Bearer ${token}` }
});
if (!res.ok) throw new Error("Access error");
const data = await res.json();
repoFiles = data.tree.filter(f => f.type === 'blob' && f.path.endsWith('.txt'));
if (!repoFiles.length) return setStatus("No TXT files found", "red");
repoFiles.forEach(f => {
const div = document.createElement('div');
div.className = 'file';
div.textContent = f.path;
div.onclick = () => loadFile(f.path, f.sha, div);
document.getElementById('list').appendChild(div);
});
setStatus(`Loaded ${repoFiles.length} files structure`, "lime");
} catch (e) {
setStatus(e.message, "red");
}
}
async function loadFile(path, sha, el) {
document.querySelectorAll('.file').forEach(e => e.classList.remove('active'));
el.classList.add('active');
const user = document.getElementById('user').value.trim();
const repo = document.getElementById('repo').value.trim();
const branch = document.getElementById('branch').value.trim() || 'main';
const token = document.getElementById('token').value.trim();
setStatus("Loading file...", "yellow");
if (currentFile && fileCache[currentFile]) {
fileCache[currentFile].content = document.getElementById('editor').value;
}
try {
let data = fileCache[path];
if (!data) {
const res = await fetch(`https://api.github.com/repos/${user}/${repo}/contents/${path}?ref=${branch}`, {
headers: { 'Authorization': `Bearer ${token}`, 'Accept': 'application/vnd.github.v3.raw' }
});
if (!res.ok) throw new Error("Load failed");
data = { sha: sha, content: await res.text(), modified: false };
fileCache[path] = data;
}
document.getElementById('editor').value = data.content;
document.getElementById('editor').disabled = false;
document.getElementById('tools').style.display = 'flex';
currentFile = path;
setStatus(`Editing: ${path}`);
} catch (e) {
setStatus(e.message, "red");
}
}
function dedup() {
const ed = document.getElementById('editor');
// Приводим все к нижнему регистру для любых языков мира, убираем пробелы и пустые строки
const lines = ed.value.split('\n').map(line => line.trim().toLowerCase()).filter(line => line !== '');
ed.value = [...new Set(lines)].join('\n');
}
function sortAsc() {
const ed = document.getElementById('editor');
ed.value = ed.value.split('\n').sort((a, b) => a.localeCompare(b)).join('\n');
}
async function processAll() {
const btn = document.getElementById('btnProcessAll');
btn.disabled = true;
setStatus("Processing all files...", "yellow");
const user = document.getElementById('user').value.trim();
const repo = document.getElementById('repo').value.trim();
const branch = document.getElementById('branch').value.trim() || 'main';
const token = document.getElementById('token').value.trim();
try {
for (let i = 0; i < repoFiles.length; i++) {
const f = repoFiles[i];
setStatus(`Processing ${i+1}/${repoFiles.length}...`, "yellow");
let data = fileCache[f.path];
if (!data) {
const res = await fetch(`https://api.github.com/repos/${user}/${repo}/contents/${f.path}?ref=${branch}`, {
headers: { 'Authorization': `Bearer ${token}`, 'Accept': 'application/vnd.github.v3.raw' }
});
if (res.ok) {
data = { sha: f.sha, content: await res.text(), modified: false };
fileCache[f.path] = data;
}
}
if (data) {
// Очистка и удаление дубликатов для всех загруженных файлов
const lines = data.content.split('\n').map(l => l.trim().toLowerCase()).filter(l => l !== '');
const newContent = [...new Set(lines)].sort((a, b) => a.localeCompare(b)).join('\n');
if (data.content !== newContent) {
data.content = newContent;
data.modified = true;
}
}
}
if (currentFile && fileCache[currentFile]) {
document.getElementById('editor').value = fileCache[currentFile].content;
}
setStatus("All files processed! Click 'Save ALL' to upload.", "lime");
} catch (e) {
setStatus("Error: " + e.message, "red");
} finally {
btn.disabled = false;
}
}
async function saveFile() {
if (!currentFile) return;
const path = currentFile;
const edContent = document.getElementById('editor').value;
if (fileCache[path]) {
fileCache[path].content = edContent;
}
const user = document.getElementById('user').value.trim();
const repo = document.getElementById('repo').value.trim();
const branch = document.getElementById('branch').value.trim();
const token = document.getElementById('token').value.trim();
const btn = document.getElementById('btnSave');
btn.disabled = true;
setStatus(`Saving ${path}...`, "yellow");
try {
const res = await fetch(`https://api.github.com/repos/${user}/${repo}/contents/${path}`, {
method: 'PUT',
headers: { 'Authorization': `Bearer ${token}`, 'Content-Type': 'application/json' },
body: JSON.stringify({
message: `Update ${path}`,
content: b64EncodeUnicode(edContent),
sha: fileCache[path].sha,
branch: branch
})
});
if (!res.ok) throw new Error("Save error");
const data = await res.json();
fileCache[path].sha = data.content.sha;
fileCache[path].modified = false;
setStatus("Saved current file!", "lime");
} catch (e) {
setStatus(e.message, "red");
} finally {
btn.disabled = false;
}
}
async function saveAll() {
const btn = document.getElementById('btnSaveAll');
btn.disabled = true;
const user = document.getElementById('user').value.trim();
const repo = document.getElementById('repo').value.trim();
const branch = document.getElementById('branch').value.trim();
const token = document.getElementById('token').value.trim();
if (currentFile && fileCache[currentFile]) {
const edVal = document.getElementById('editor').value;
if (fileCache[currentFile].content !== edVal) {
fileCache[currentFile].content = edVal;
fileCache[currentFile].modified = true;
}
}
try {
let savedCount = 0;
const keys = Object.keys(fileCache);
for (let i = 0; i < keys.length; i++) {
const path = keys[i];
if (fileCache[path].modified) {
setStatus(`Saving ${path}...`, "yellow");
const res = await fetch(`https://api.github.com/repos/${user}/${repo}/contents/${path}`, {
method: 'PUT',
headers: { 'Authorization': `Bearer ${token}`, 'Content-Type': 'application/json' },
body: JSON.stringify({
message: `Global Update ${path}`,
content: b64EncodeUnicode(fileCache[path].content),
sha: fileCache[path].sha,
branch: branch
})
});
if (!res.ok) throw new Error(`Save error: ${path}`);
const data = await res.json();
fileCache[path].sha = data.content.sha;
fileCache[path].modified = false;
savedCount++;
}
}
setStatus(savedCount > 0 ? `Saved ${savedCount} files successfully!` : "No changes to save.", "lime");
} catch (e) {
setStatus("Error saving: " + e.message, "red");
} finally {
btn.disabled = false;
}
}
</script>
</body>
</html>