diff --git a/src/manifest.json b/src/manifest.json
index 3f69e36..ad6efd1 100644
--- a/src/manifest.json
+++ b/src/manifest.json
@@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "__MSG_extensionName__",
- "version": "1.2.0",
+ "version": "1.3.0",
"description": "__MSG_extensionDescription__",
"homepage_url": "https://github.com/onozaty/chrome-shortcutkey2url",
"icons": {
diff --git a/src/options/options.css b/src/options/options.css
index c4e456c..738c16d 100644
--- a/src/options/options.css
+++ b/src/options/options.css
@@ -1,3 +1,7 @@
+.container {
+ padding-bottom: 15px;
+}
+
h1 {
border-bottom: 1px solid #eee;
margin-bottom: 10px;
diff --git a/src/options/options.html b/src/options/options.html
index 0b85a32..a21ae02 100644
--- a/src/options/options.html
+++ b/src/options/options.html
@@ -54,11 +54,16 @@
ShortcutKey2URL
Shortcut keys
-
+
+
+
+
+
+
-
+
diff --git a/src/options/options.js b/src/options/options.js
index 74ec0b3..1569cf1 100644
--- a/src/options/options.js
+++ b/src/options/options.js
@@ -316,6 +316,45 @@ function startup(settings) {
shortcutKeys.append(null, true);
});
+ $('#importButton').on('click', () => {
+ const fileInput = document.createElement('input');
+ fileInput.type = 'file';
+ fileInput.setAttribute('hidden', true);
+
+ fileInput.addEventListener('change', (e) => {
+ const file = e.target.files[0];
+
+ const reader = new FileReader();
+ reader.onload = (e) => {
+ const fileContents = e.target.result;
+
+ try {
+ const importShortcutKeys = JSON.parse(fileContents);
+ importShortcutKeys.forEach((shortcutKey) => shortcutKeys.append(shortcutKey));
+ } catch (error) {
+ console.log(error);
+ alert('Could not import due to invalid format.');
+ }
+ }
+ reader.readAsText(file);
+ }, false);
+
+ document.body.appendChild(fileInput);
+ fileInput.click();
+ fileInput.remove();
+ });
+
+ $('#exportButton').on('click', () => {
+ const downloadLink = document.createElement('a');
+ downloadLink.download = 'shortcutkeys.json';
+ downloadLink.href = URL.createObjectURL(new Blob([JSON.stringify(shortcutKeys.data(), null, 2)], { 'type' : 'text/plain' }));
+ downloadLink.setAttribute('hidden', true);
+
+ document.body.appendChild(downloadLink);
+ downloadLink.click();
+ downloadLink.remove();
+ });
+
$('#saveButton').on('click', () => {
$("#successMessage").hide();
$("#errorMessage").hide();