Skip to content

Commit 2415935

Browse files
author
JadeMin
committed
구조 최적화
1 parent f1530da commit 2415935

File tree

9 files changed

+24
-122
lines changed

9 files changed

+24
-122
lines changed

meta.json

Lines changed: 0 additions & 10 deletions
This file was deleted.

scripts/build.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import type { BuildOptions } from 'esbuild';
21
import type { BuildTypes } from "./@types/build.js";
32

3+
import { readFile } from 'fs/promises';
44
import { build, context } from 'esbuild';
55
import { copy } from 'esbuild-plugin-copy';
66
import { buildTyping, getCurrentType } from "./@types/build.js";
7-
import { getMetaString } from "./meta.js";
87

98
const buildArgv = process.argv.slice(2)[0] as BuildTypes;
109
const buildType = buildTyping(buildArgv);
@@ -17,7 +16,7 @@ await build({
1716
charset: 'utf8',
1817

1918
platform: 'browser',
20-
format: 'iife',
19+
format: 'esm',
2120

2221
bundle: true,
2322
minify: buildType.PUBLISH,
@@ -26,13 +25,13 @@ await build({
2625
treeShaking: true,
2726

2827
banner: {
29-
js: getMetaString()
28+
js: await readFile("./src/meta.ts", 'utf-8')
3029
},
3130

3231
plugins: [
3332
copy({
3433
assets: {
35-
from: ["./src/README.md"],
34+
from: ["./src/.page/CNAME", "./src/.page/README.md"],
3635
to: ["./"]
3736
}
3837
})

scripts/meta.ts

Lines changed: 0 additions & 17 deletions
This file was deleted.

CNAME renamed to src/.page/CNAME

File renamed without changes.

src/.page/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
### [다운로드](https://github.com/JadeMin-UserScripts/CodeUp-Plus/raw/dist/index.user.js)
2+
(`https://github.com/JadeMin-UserScripts/CodeUp-Plus/raw/dist/index.user.js`)

src/README.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/meta.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// ==UserScript==
2+
// @name CodeUp+
3+
// @description CodeUp+
4+
// @version 0.1.1
5+
// @icon https://icons.duckduckgo.com/ip2/codeup.kr.ico
6+
// @updateURL https://github.com/JadeMin-UserScripts/CodeUp-Plus/raw/dist/index.user.js
7+
// @downloadURL https://github.com/JadeMin-UserScripts/CodeUp-Plus/raw/dist/index.user.js
8+
// @match https://*.codeup.kr/*
9+
// @run-at document-end
10+
// ==/UserScript==

src/modules/saved.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,27 @@ const problemNumber = (document.querySelector("input#problem_id") as HTMLInputEl
88
const storageName = `editor_${problemNumber}`;
99
export const _getSaved = (): SavedWithExpires | null => JSON.parse(localStorage.getItem(storageName)!);
1010
export const _removeSaved = (): void => localStorage.removeItem(storageName);
11-
export const cleanSaved = (): true | null => {
11+
export const _cleanSaved = (): true | null => {
1212
const saved = _getSaved();
13-
if(saved === null) return null
13+
14+
if(saved === null) return null;
1415
if(Date.now() > saved.expires) {
1516
_removeSaved();
1617
return true;
1718
} else return null;
1819
};
19-
20-
cleanSaved();
2120
export const getSaved = (): Saved | null => {
2221
const saved = _getSaved();
2322
if(saved === null) return null;
2423

2524
return saved.value;
2625
};
27-
export const setSaved = (obj: {[key: string]: any}, expireDate: number): void => {
28-
const saved = getSaved();
29-
26+
export const setSaved = (obj: {[key: string]: any}, expireDate: number = 5000): void => {
3027
return localStorage.setItem(storageName, JSON.stringify({
3128
value: obj,
3229
expires: Date.now() + expireDate
3330
}));
34-
};
31+
};
32+
33+
// 초기화
34+
_cleanSaved();

src/original.user.js

Lines changed: 0 additions & 81 deletions
This file was deleted.

0 commit comments

Comments
 (0)