Skip to content

Commit

Permalink
Improved Loudness normalization
Browse files Browse the repository at this point in the history
  • Loading branch information
adokseo committed Feb 17, 2021
1 parent a00ea77 commit 618ce31
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
4 changes: 2 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"name": "Improve YouTube! (testing)",
"short_name": "ImprovedTube",
"description": "Make YouTube tidy & powerful! YouTube Player Size Theme Quality Colors ad-block Playback Speed Style Playlist Channel H.264 Auto HD",
"version": "3.162",
"version_name": "3.162-testing",
"version": "3.163",
"version_name": "3.163-testing",
"default_locale": "en",
"icons": {
"128": "assets/icons/128.png",
Expand Down
23 changes: 14 additions & 9 deletions youtube-scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -1637,15 +1637,20 @@ ImprovedTube.playerVolume = function(node) {
4.13 LOUDNESS NORMALIZATION
------------------------------------------------------------------------------*/

ImprovedTube.onvolumechange = function(event) {
if (document.querySelector('.ytp-volume-panel') && ImprovedTube.storage.player_loudness_normalization === false) {
var volume = Number(document.querySelector('.ytp-volume-panel').getAttribute('aria-valuenow'));

this.volume = volume / 100;
}
};

ImprovedTube.playerLoudnessNormalization = function() {
if (document.querySelector('video')) {
document.querySelector('video').onvolumechange = function(event) {
if (document.querySelector('.ytp-volume-panel') && ImprovedTube.storage.player_loudness_normalization === false) {
var volume = Number(document.querySelector('.ytp-volume-panel').getAttribute('aria-valuenow'));
var video = document.querySelector('video');

document.querySelector('video').volume = volume / 100;
}
};
if (video) {
video.removeEventListener('volumechange', ImprovedTube.onvolumechange);
video.addEventListener('volumechange', ImprovedTube.onvolumechange);
}

if (ImprovedTube.storage.player_loudness_normalization === false) {
Expand All @@ -1658,9 +1663,9 @@ ImprovedTube.playerLoudnessNormalization = function() {
local_storage = JSON.parse(JSON.parse(local_storage).data);
local_storage = Number(local_storage.volume);

document.querySelector('video').volume = local_storage / 100;
video.volume = local_storage / 100;
} else {
document.querySelector('video').volume = 100;
video.volume = 100;
}
} catch (err) {}
}
Expand Down

0 comments on commit 618ce31

Please sign in to comment.