Skip to content

Commit

Permalink
Closes #944
Browse files Browse the repository at this point in the history
  • Loading branch information
ParticleCore committed Mar 2, 2024
1 parent 36cb103 commit b2f0903
Show file tree
Hide file tree
Showing 12 changed files with 130 additions and 22 deletions.
1 change: 1 addition & 0 deletions src/chrome/css/options.css
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ pre {
border-radius: 6px;
border: 0 none;
margin-bottom: 6px;
min-width: 120px;
}

.settingDescription {
Expand Down
39 changes: 29 additions & 10 deletions src/chrome/html/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -366,16 +366,6 @@
<div class="settingDescription">Allows the creator merch to be shown below the video details</div>
</div>
</div>
<div class="setting" data-id="superTheater">
<label class="switch">
<input data-setting="superTheater" type="checkbox">
<span class="slider"></span>
</label>
<div class="settingDescription">
<div class="settingDescription highlight">Super theater</div>
<div class="settingDescription">Switching to theater mode will make the player cover the full browser while allowing the page to be scrolled</div>
</div>
</div>
</div>
</div>
<div class="settingGroup">
Expand Down Expand Up @@ -429,6 +419,16 @@
<div class="settingGroup">
<div class="settingLabel">Player</div>
<div class="settingOptions">
<div class="setting" data-id="superTheater">
<label class="switch">
<input data-setting="superTheater" type="checkbox">
<span class="slider"></span>
</label>
<div class="settingDescription">
<div class="settingDescription highlight">Super theater</div>
<div class="settingDescription">Switching to theater mode will make the player cover the full browser while allowing the page to be scrolled</div>
</div>
</div>
<div class="setting" data-id="alwaysVisible">
<label class="switch">
<input data-setting="alwaysVisible" type="checkbox">
Expand Down Expand Up @@ -479,6 +479,25 @@
<div class="settingDescription">Change the video volume by holding the shift key and scrolling on the video page</div>
</div>
</div>
<div class="setting" data-id="scrollVolumeStep">
<div class="settingDescription">
<label>
<select data-setting="scrollVolumeStep">
<option value="10">10</option>
<option value="9">9</option>
<option value="8">8</option>
<option value="7">7</option>
<option value="6">6</option>
<option value="5" selected="selected">5</option>
<option value="4">4</option>
<option value="3">3</option>
<option value="2">2</option>
<option value="1">1</option>
</select>
</label>
<div class="settingDescription">Number of volume steps each scroll will change at once</div>
</div>
</div>
<div class="setting" data-id="infoCards">
<label class="switch">
<input data-setting="infoCards" type="checkbox">
Expand Down
3 changes: 2 additions & 1 deletion src/chrome/js/background-inject.js
Original file line number Diff line number Diff line change
Expand Up @@ -1961,7 +1961,8 @@ function mainScript(extensionId, SettingData, defaultSettings) {

const direction = event.deltaY;
const oldVolume = api?.["getVolume"]?.() || 0;
let newVolume = oldVolume - (Math.sign(direction) * 5);
const steps = Math.max(1, Math.min(iridiumSettings.scrollVolumeStep || 5, 10));
let newVolume = oldVolume - (Math.sign(direction) * steps);

if (newVolume < 0) {
newVolume = 0;
Expand Down
4 changes: 4 additions & 0 deletions src/chrome/js/chrome-wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@
id: "scrollVolume",
default: true,
},
scrollVolumeStep: {
id: "scrollVolumeStep",
default: 5,
},
infoCards: {
id: "infoCards",
default: false,
Expand Down
4 changes: 4 additions & 0 deletions src/chrome/js/content-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ const SettingData = {
id: "scrollVolume",
default: true,
},
scrollVolumeStep: {
id: "scrollVolumeStep",
default: 5,
},
infoCards: {
id: "infoCards",
default: false,
Expand Down
25 changes: 25 additions & 0 deletions src/chrome/js/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,28 @@ const Manager = {
ui.checked = newState;
}

const dependents = document.querySelectorAll(`[data-id="${SettingData.scrollVolumeStep.id}"]`);

if (newState) {
dependents.forEach(value => value.classList.remove("disabled"));
} else {
dependents.forEach(value => value.classList.add("disabled"));
}

if (!userInteraction) return;

Util.updateSingleSetting(settingId, newState);

},
updateScrollVolumeStep: (newState, userInteraction) => {

const settingId = SettingData.scrollVolumeStep.id;
const ui = document.querySelector(`[data-setting=${settingId}]`);

if (ui != null && ui.value !== newState) {
ui.value = newState;
}

if (!userInteraction) return;

Util.updateSingleSetting(settingId, newState);
Expand Down Expand Up @@ -702,6 +724,9 @@ const Util = {
case SettingData.scrollVolume.id:
Manager.updateScrollVolume(value, userInteraction);
break;
case SettingData.scrollVolumeStep.id:
Manager.updateScrollVolumeStep(value, userInteraction);
break;
case SettingData.infoCards.id:
Manager.updateInfoCards(value, userInteraction);
break;
Expand Down
4 changes: 4 additions & 0 deletions src/chrome/js/setting-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ const SettingData = {
id: "scrollVolume",
default: true,
},
scrollVolumeStep: {
id: "scrollVolumeStep",
default: 5,
},
infoCards: {
id: "infoCards",
default: false,
Expand Down
1 change: 1 addition & 0 deletions src/firefox/css/options.css
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ pre {
border-radius: 6px;
border: 0 none;
margin-bottom: 6px;
min-width: 120px;
}

.settingDescription {
Expand Down
39 changes: 29 additions & 10 deletions src/firefox/html/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -366,16 +366,6 @@
<div class="settingDescription">Allows the creator merch to be shown below the video details</div>
</div>
</div>
<div class="setting" data-id="superTheater">
<label class="switch">
<input data-setting="superTheater" type="checkbox">
<span class="slider"></span>
</label>
<div class="settingDescription">
<div class="settingDescription highlight">Super theater</div>
<div class="settingDescription">Switching to theater mode will make the player cover the full browser while allowing the page to be scrolled</div>
</div>
</div>
</div>
</div>
<div class="settingGroup">
Expand Down Expand Up @@ -429,6 +419,16 @@
<div class="settingGroup">
<div class="settingLabel">Player</div>
<div class="settingOptions">
<div class="setting" data-id="superTheater">
<label class="switch">
<input data-setting="superTheater" type="checkbox">
<span class="slider"></span>
</label>
<div class="settingDescription">
<div class="settingDescription highlight">Super theater</div>
<div class="settingDescription">Switching to theater mode will make the player cover the full browser while allowing the page to be scrolled</div>
</div>
</div>
<div class="setting" data-id="alwaysVisible">
<label class="switch">
<input data-setting="alwaysVisible" type="checkbox">
Expand Down Expand Up @@ -479,6 +479,25 @@
<div class="settingDescription">Change the video volume by holding the shift key and scrolling on the video page</div>
</div>
</div>
<div class="setting" data-id="scrollVolumeStep">
<div class="settingDescription">
<label>
<select data-setting="scrollVolumeStep">
<option value="10">10</option>
<option value="9">9</option>
<option value="8">8</option>
<option value="7">7</option>
<option value="6">6</option>
<option value="5" selected="selected">5</option>
<option value="4">4</option>
<option value="3">3</option>
<option value="2">2</option>
<option value="1">1</option>
</select>
</label>
<div class="settingDescription">Number of volume steps each scroll will change at once</div>
</div>
</div>
<div class="setting" data-id="infoCards">
<label class="switch">
<input data-setting="infoCards" type="checkbox">
Expand Down
3 changes: 2 additions & 1 deletion src/firefox/js/background-inject.js
Original file line number Diff line number Diff line change
Expand Up @@ -1961,7 +1961,8 @@ function mainScript(extensionId, SettingData, defaultSettings) {

const direction = event.deltaY;
const oldVolume = api?.["getVolume"]?.() || 0;
let newVolume = oldVolume - (Math.sign(direction) * 5);
const steps = Math.max(1, Math.min(iridiumSettings.scrollVolumeStep || 5, 10));
let newVolume = oldVolume - (Math.sign(direction) * steps);

if (newVolume < 0) {
newVolume = 0;
Expand Down
25 changes: 25 additions & 0 deletions src/firefox/js/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,28 @@ const Manager = {
ui.checked = newState;
}

const dependents = document.querySelectorAll(`[data-id="${SettingData.scrollVolumeStep.id}"]`);

if (newState) {
dependents.forEach(value => value.classList.remove("disabled"));
} else {
dependents.forEach(value => value.classList.add("disabled"));
}

if (!userInteraction) return;

Util.updateSingleSetting(settingId, newState);

},
updateScrollVolumeStep: (newState, userInteraction) => {

const settingId = SettingData.scrollVolumeStep.id;
const ui = document.querySelector(`[data-setting=${settingId}]`);

if (ui != null && ui.value !== newState) {
ui.value = newState;
}

if (!userInteraction) return;

Util.updateSingleSetting(settingId, newState);
Expand Down Expand Up @@ -702,6 +724,9 @@ const Util = {
case SettingData.scrollVolume.id:
Manager.updateScrollVolume(value, userInteraction);
break;
case SettingData.scrollVolumeStep.id:
Manager.updateScrollVolumeStep(value, userInteraction);
break;
case SettingData.infoCards.id:
Manager.updateInfoCards(value, userInteraction);
break;
Expand Down
4 changes: 4 additions & 0 deletions src/firefox/js/setting-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ const SettingData = {
id: "scrollVolume",
default: true,
},
scrollVolumeStep: {
id: "scrollVolumeStep",
default: 5,
},
infoCards: {
id: "infoCards",
default: false,
Expand Down

0 comments on commit b2f0903

Please sign in to comment.