aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMichael C <[email protected]>2022-01-27 01:43:40 -0500
committerMichael C <[email protected]>2022-01-27 01:43:40 -0500
commit876b55dcc1d07ac58ed0bf684120434c354162a9 (patch)
treecf28b6389451b3db4154d8b735b7e172be3552e1
parent6d0d533fa7236edbd723f07d95d87502ba1a7d96 (diff)
downloadSponsorBlock-876b55dcc1d07ac58ed0bf684120434c354162a9.tar.gz
SponsorBlock-876b55dcc1d07ac58ed0bf684120434c354162a9.zip
add bindMediaKey to options
-rw-r--r--public/_locales/en/messages.json6
-rw-r--r--public/options/options.html14
-rw-r--r--src/config.ts4
-rw-r--r--src/content.ts3
4 files changed, 25 insertions, 2 deletions
diff --git a/public/_locales/en/messages.json b/public/_locales/en/messages.json
index b1be0523..711667c3 100644
--- a/public/_locales/en/messages.json
+++ b/public/_locales/en/messages.json
@@ -918,5 +918,11 @@
},
"youtubeKeybindWarning": {
"message": "This is a built-in YouTube shortcut. Are you sure you want to use it?"
+ },
+ "bindMediaKey": {
+ "message": "Play/Pause Current Video with Media Keys"
+ },
+ "bindMediaKeyDescription": {
+ "message": "Enable this if your media keys stop working after the audio notification is played."
}
}
diff --git a/public/options/options.html b/public/options/options.html
index 189f23ad..e302802f 100644
--- a/public/options/options.html
+++ b/public/options/options.html
@@ -263,6 +263,20 @@
<div class="small-description">__MSG_audioNotificationDescription__</div>
</div>
+
+ <div data-type="toggle" data-sync="bindMediaKey" data-dependent-on="audioNotificationOnSkip">
+ <div class="switch-container">
+ <label class="switch">
+ <input id="bindMediaKey" type="checkbox" checked>
+ <span class="slider round"></span>
+ </label>
+ <label class="switch-label" for="bindMediaKey">
+ __MSG_bindMediaKey__
+ </label>
+ </div>
+
+ <div class="small-description">__MSG_bindMediaKeyDescription__</div>
+ </div>
<div data-type="toggle" data-sync="showTimeWithSkips">
<div class="switch-container">
diff --git a/src/config.ts b/src/config.ts
index a890f94a..42192b73 100644
--- a/src/config.ts
+++ b/src/config.ts
@@ -36,7 +36,8 @@ interface SBConfig {
serverAddress: string,
minDuration: number,
skipNoticeDuration: number,
- audioNotificationOnSkip,
+ audioNotificationOnSkip: boolean,
+ bindMediaKey: boolean,
checkForUnlistedVideos: boolean,
testingServer: boolean,
refetchWhenNotFound: boolean,
@@ -198,6 +199,7 @@ const Config: SBObject = {
minDuration: 0,
skipNoticeDuration: 4,
audioNotificationOnSkip: false,
+ bindMediaKey: false,
checkForUnlistedVideos: false,
testingServer: false,
refetchWhenNotFound: true,
diff --git a/src/content.ts b/src/content.ts
index d7b55dd9..7ff811d7 100644
--- a/src/content.ts
+++ b/src/content.ts
@@ -1273,7 +1273,8 @@ function skipToTime({v, skipTime, skippingSegments, openNotice, forceAutoSkip, u
const beep = new Audio(chrome.runtime.getURL("icons/beep.ogg"));
beep.volume = video.volume * 0.1;
beep.play();
- window.addEventListener("keydown", mediaPauseListener);
+ if (Config.config.audioNotificationOnSkip && Config.config.bindMediaKey)
+ window.addEventListener("keydown", mediaPauseListener);
}
if (!autoSkip