Skip to content

Commit 67b7fc5

Browse files
authored
최적화
1 parent 20a5d33 commit 67b7fc5

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

index.user.js

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
// @run-at document-end
1010
// ==/UserScript==
1111
if(location.pathname !== "/submitpage.php") return;
12-
1312
const { editor } = unsafeWindow;
1413

1514
const editorElement = editor.textInput.getElement();
@@ -33,24 +32,20 @@ const setSaved = (obj, expireDate) => {
3332
expires: Date.now() + expireDate
3433
}));
3534
};
36-
/*unsafeWindow.clearSaved = ()=> localStorage.clear();
37-
const createAlert = (message) => {
38-
return '';
39-
35+
//unsafeWindow.clearSaved = ()=> localStorage.clear();
36+
/*const createAlert = (message) => {
4037
const title = "CodeUp-Plus";
4138
return `\n\n\n\n#!${title}: ${message}`;
4239
};
4340
const removeAlert = (code) => {
44-
return code;
45-
4641
const re = /\n*(\#\!.*)\n*$/i;
4742
return code.replace(re, '');
4843
};*/
4944

5045

5146

5247
const saved = getSaved();
53-
const onChange = event => {
48+
const onInput = event => {
5449
const { row, column } = editor.selection.getCursor();
5550
const currentCode = editor.session.getValue();
5651

@@ -65,8 +60,10 @@ const onChange = event => {
6560
}
6661
};
6762
editor.setOptions({useSoftTabs: false});
68-
editor.on('click', onChange);
69-
editorElement.addEventListener('keydown', onChange);
63+
editor.on('click', onInput);
64+
//editor.on('change', onInput);
65+
editorElement.addEventListener('keydown', onInput);
66+
editor.focus();
7067

7168
if(saved === null) {
7269
const code = `#include <stdio.h>
@@ -82,4 +79,3 @@ int main() {
8279
editor.session.setValue(`${saved.code}`);
8380
editor.gotoLine(saved.cursor.row + 1, saved.cursor.column);
8481
}
85-
editor.focus();

0 commit comments

Comments
 (0)