diff --git a/css/main.css b/css/main.css
index aac5db2..509d928 100644
--- a/css/main.css
+++ b/css/main.css
@@ -1,5 +1,13 @@
body {
background: url("../img/Background.png");
+ display: flex;
+ min-height: 100vh;
+ flex-direction: column;
+ min-width: 720px;
+}
+
+main {
+ flex: 1 0 auto;
}
#logo {
@@ -26,7 +34,8 @@ body {
color: #eeeeee;
}
-.input-field>input,.input-field>textarea {
+.input-field>input,
+.input-field>textarea {
color: #e0e0e0;
}
diff --git a/favicon.ico b/favicon.ico
new file mode 100644
index 0000000..1b43718
Binary files /dev/null and b/favicon.ico differ
diff --git a/index.html b/index.html
index ccfdb77..355c853 100644
--- a/index.html
+++ b/index.html
@@ -17,6 +17,9 @@
+
+
+
Steam Key Extension
@@ -27,61 +30,81 @@
-
-
-
+
+
+
+
-
-
-
-
-
-
-
-
+
diff --git a/js/main.js b/js/main.js
index e69de29..ac324df 100644
--- a/js/main.js
+++ b/js/main.js
@@ -0,0 +1,46 @@
+const txtBotName = document.getElementById("bot-name");
+const txtInput = document.getElementById("ske-input");
+const btnExtract = document.getElementById("ske-extract");
+const btnCopy = document.getElementById("ske-copy");
+const btnExport = document.getElementById("ske-export");
+const btnClear = document.getElementById("ske-clear");
+const txtOutput = document.getElementById("ske-output");
+const keyRegex = /(?:(?:([A-Z0-9])(?!\1{4})){5}-){2,5}[A-Z0-9]{5}/g;
+const unique = a => [...new Set(a)];
+
+btnExtract.onclick = () => {
+ txtOutput.value = "";
+
+ const keys = unique(txtInput.value.match(keyRegex));
+ if (keys.length > 0) {
+ txtOutput.value = "!redeem " + txtBotName.value + " " + keys.join(",");
+ txtOutput.focus();
+ } else {
+ M.toast({
+ html: '无 Steam Key!'
+ });
+ }
+ M.updateTextFields();
+ M.textareaAutoResize(txtOutput);
+ M.textareaAutoResize(txtInput);
+}
+
+btnCopy.onclick = () => {
+ txtOutput.select();
+ document.execCommand("Copy");
+ M.toast({
+ html: '已复制!'
+ });
+}
+
+btnClear.onclick = () => {
+ txtInput.value = "";
+ txtOutput.value = "";
+ M.updateTextFields();
+ M.textareaAutoResize(txtOutput);
+ M.textareaAutoResize(txtInput);
+
+ M.toast({
+ html: '已清空!'
+ });
+}
\ No newline at end of file