diff --git a/_locales/en/messages.json b/_locales/en/messages.json
index 488ba60f..ddb91234 100644
--- a/_locales/en/messages.json
+++ b/_locales/en/messages.json
@@ -246,5 +246,17 @@
"noticeUpdate": {
"message": "The notice has been upgraded! If you still don't like it, hit the never show button.",
"description": "The message displayed after the notice was upgraded."
+ },
+ "setStartSponsorShortcut": {
+ "message": "Set key for start sponsor keybind"
+ },
+ "setSubmitKeybind": {
+ "message": "Set key for submission keybind"
+ },
+ "keybindDescription": {
+ "message": "Select a key by typing it"
+ },
+ "keybindDescriptionComplete": {
+ "message": "The keybind has been set to: "
}
}
diff --git a/content.js b/content.js
index 5283354c..7b3fbc09 100644
--- a/content.js
+++ b/content.js
@@ -204,18 +204,32 @@ function messageListener(request, sender, sendResponse) {
}
//check for hotkey pressed
-document.onkeydown = function(e){
+document.onkeydown = async function(e){
e = e || window.event;
var key = e.key;
let video = document.getElementById("movie_player");
+ let startSponsorKey = await new Promise((resolve, reject) => {
+ chrome.storage.sync.get(["startSponsorKeybind"], (result) => resolve(result));
+ });
+ let submitKey = await new Promise((resolve, reject) => {
+ chrome.storage.sync.get(["submitKeybind"], (result) => resolve(result));
+ });
+
+ if (startSponsorKey.startSponsorKeybind === undefined) {
+ startSponsorKey.startSponsorKeybind = ";"
+ }
+ if (submitKey.submitKeybind === undefined) {
+ submitKey.submitKeybind = "'"
+ }
+
//is the video in focus, otherwise they could be typing a comment
if (document.activeElement === video) {
- if(key == ';'){
+ if(key == startSponsorKey.startSponsorKeybind){
//semicolon
startSponsorClicked();
- } else if (key == "'") {
+ } else if (key == submitKey.submitKeybind) {
//single quote
submitSponsorTimes();
}
diff --git a/popup.html b/popup.html
index ac89c9b5..a2923eb0 100644
--- a/popup.html
+++ b/popup.html
@@ -172,6 +172,19 @@