From 086cd14cc163b79f8905b44b3f2900ebcdf961af Mon Sep 17 00:00:00 2001 From: Victor Savinov Date: Mon, 28 Oct 2019 02:46:39 +0300 Subject: [PATCH] 2.0 pre-stable - Added shortcuts for video quality - Added OSD for shortcuts - Improved data migration - Core fixes - GUI fixes & optimizations --- manifest.json | 7 +- popup/header.js | 14 +- popup/template-parts/analyzer.js | 2 +- popup/template-parts/appearance.js | 2 +- popup/template-parts/blacklist.js | 6 +- popup/template-parts/channel.js | 2 +- popup/template-parts/general.js | 2 +- popup/template-parts/mixer.js | 2 +- popup/template-parts/player.js | 2 +- popup/template-parts/playlist.js | 2 +- popup/template-parts/settings.js | 12 +- popup/template-parts/shortcuts.js | 63 ++- popup/template-parts/themes.js | 2 +- satus/components/css/directory.css | 1 + satus/components/css/select.css | 2 +- youtube/css/shortcuts.css | 11 + youtube/js/core.js | 36 +- youtube/js/features/general.js | 2 +- youtube/js/features/player.js | 8 +- youtube/js/features/shortcuts.js | 106 ++++- youtube/js/features/themes.js | 2 +- youtube/js/migration.js | 633 ++++++++++++++--------------- 22 files changed, 527 insertions(+), 392 deletions(-) create mode 100644 youtube/css/shortcuts.css diff --git a/manifest.json b/manifest.json index 63b7efa62..adffad42c 100644 --- a/manifest.json +++ b/manifest.json @@ -1,8 +1,8 @@ { "manifest_version": 2, - "name": "ImprovedTube Beta", - "version": "2.0", - "version_name": "2.0 alpha", + "name": "ImprovedTube", + "version": "2.0.100", + "version_name": "2.0", "default_locale": "en", "description": "Make YouTube wonderful&Keep It clean! YouTube Player Size Playback Quality Auto HD Speed Style Adblock Volume Playlist Channel H.264", @@ -43,6 +43,7 @@ "youtube/css/channel.css", "youtube/css/blacklist.css", "youtube/css/settings.css", + "youtube/css/shortcuts.css", "youtube/css/themes/legacy.css", "youtube/css/themes/default.css", "youtube/css/themes/black.css", diff --git a/popup/header.js b/popup/header.js index f1c0de8f7..f511afa8d 100644 --- a/popup/header.js +++ b/popup/header.js @@ -7,7 +7,7 @@ Satus.prototype.menu.header = { back: { type: 'button', class: 'back', - icon: '', + icon: '', onclick: function(satus, component) { let status = satus.container.querySelector('main').goBack(); @@ -36,7 +36,7 @@ Satus.prototype.menu.header = { search: { type: 'button', - icon: '', + icon: '', onclick: function(satus, component) { let offset = component.offsetLeft - component.offsetWidth / 2; @@ -63,7 +63,7 @@ Satus.prototype.menu.header = { /*back: { type: 'button', - icon: '', + icon: '', onclick: function(satus, component) { component.parentNode.parentNode.querySelector('.satus-dialog__scrim').click(); } @@ -149,7 +149,7 @@ Satus.prototype.menu.header = { }, vert: { type: 'button', - icon: '', + icon: '', onclick: function(self, component) { if (self.container.querySelector('main').dataset.path === '/settings/about') { @@ -168,7 +168,7 @@ Satus.prototype.menu.header = { save_as: { type: 'button', label: 'saveAs', - icon: '', + icon: '', onclick: function(satus, component) { chrome.runtime.sendMessage({ name: 'download', @@ -194,12 +194,12 @@ Satus.prototype.menu.header = { github: { type: 'button', label: 'github', - icon: '' + icon: '' }, rate: { type: 'button', label: 'rateUs', - icon: '' + icon: '' } }); } diff --git a/popup/template-parts/analyzer.js b/popup/template-parts/analyzer.js index 67275a3e6..0640cbd88 100644 --- a/popup/template-parts/analyzer.js +++ b/popup/template-parts/analyzer.js @@ -1,7 +1,7 @@ Satus.prototype.menu.main.analyzer = { type: 'directory', label: 'analyzer', - icon: '', + icon: '', section: { type: 'section', diff --git a/popup/template-parts/appearance.js b/popup/template-parts/appearance.js index e1bb87a23..716179900 100644 --- a/popup/template-parts/appearance.js +++ b/popup/template-parts/appearance.js @@ -1,6 +1,6 @@ Satus.prototype.menu.main.appearance = { type: 'directory', - icon: '', + icon: '', header: { type: 'button', diff --git a/popup/template-parts/blacklist.js b/popup/template-parts/blacklist.js index 10920bf76..03430fac7 100644 --- a/popup/template-parts/blacklist.js +++ b/popup/template-parts/blacklist.js @@ -1,7 +1,7 @@ Satus.prototype.menu.main.blacklist = { type: 'directory', label: 'blacklist', - icon: '', + icon: '', channels: { type: 'directory', @@ -36,7 +36,7 @@ Satus.prototype.menu.main.blacklist = { delete: { type: 'button', - icon: '', + icon: '', onclick: function (satus, component) { satus.storage.set(item, false, '/blacklist/channels/'); component.parentNode.parentNode.classList.add('removing'); @@ -89,7 +89,7 @@ Satus.prototype.menu.main.blacklist = { delete: { type: 'button', - icon: '', + icon: '', onclick: function (satus, component) { satus.storage.set(item, false, '/blacklist/videos/'); component.parentNode.parentNode.classList.add('removing'); diff --git a/popup/template-parts/channel.js b/popup/template-parts/channel.js index 0ea0345f7..7d3b2d66c 100644 --- a/popup/template-parts/channel.js +++ b/popup/template-parts/channel.js @@ -1,6 +1,6 @@ Satus.prototype.menu.main.channel = { type: 'directory', - icon: '', + icon: '', channel_default_tab: { type: 'select', diff --git a/popup/template-parts/general.js b/popup/template-parts/general.js index 9e852f830..9fdc90672 100644 --- a/popup/template-parts/general.js +++ b/popup/template-parts/general.js @@ -1,6 +1,6 @@ Satus.prototype.menu.main.general = { type: 'directory', - icon: '', + icon: '', legacy_youtube: { type: 'switch', diff --git a/popup/template-parts/mixer.js b/popup/template-parts/mixer.js index 82cb2c0a5..6fa151ab1 100644 --- a/popup/template-parts/mixer.js +++ b/popup/template-parts/mixer.js @@ -1,7 +1,7 @@ Satus.prototype.menu.main.mixer = { type: 'directory', label: 'mixer', - icon: '', + icon: '', section: { type: 'section', diff --git a/popup/template-parts/player.js b/popup/template-parts/player.js index fe389af42..66809162a 100644 --- a/popup/template-parts/player.js +++ b/popup/template-parts/player.js @@ -1,6 +1,6 @@ Satus.prototype.menu.main.player = { type: 'directory', - icon: '', + icon: '', section: { type: 'section', diff --git a/popup/template-parts/playlist.js b/popup/template-parts/playlist.js index a9eaec119..3ba5e3c73 100644 --- a/popup/template-parts/playlist.js +++ b/popup/template-parts/playlist.js @@ -1,6 +1,6 @@ Satus.prototype.menu.main.playlist = { type: 'directory', - icon: '', + icon: '', playlist_autoplay: { type: 'switch', diff --git a/popup/template-parts/settings.js b/popup/template-parts/settings.js index 7dc0bcd93..51182f7a3 100644 --- a/popup/template-parts/settings.js +++ b/popup/template-parts/settings.js @@ -1,10 +1,10 @@ Satus.prototype.menu.main.settings = { type: 'directory', - icon: '', + icon: '', appearance: { type: 'directory', - icon: '', + icon: '', improvedtube_youtube_icon: { label: 'improvedtubeIconOnYoutube', @@ -41,7 +41,7 @@ Satus.prototype.menu.main.settings = { }, languages: { type: 'directory', - icon: '', + icon: '', language: { label: 'improvedtubeLanguage', type: 'select', @@ -530,7 +530,7 @@ Satus.prototype.menu.main.settings = { backup_and_reset: { type: 'directory', label: 'backupAndReset', - icon: '', + icon: '', import_settings: { type: 'button', @@ -665,7 +665,7 @@ Satus.prototype.menu.main.settings = { date_and_time: { type: 'directory', label: 'dateAndTime', - icon: '', + icon: '', use_24_hour_format: { type: 'switch', @@ -675,7 +675,7 @@ Satus.prototype.menu.main.settings = { }, about: { type: 'directory', - icon: '', + icon: '', extension_section: { type: 'section', diff --git a/popup/template-parts/shortcuts.js b/popup/template-parts/shortcuts.js index a78852d7b..5dbc7dcb5 100644 --- a/popup/template-parts/shortcuts.js +++ b/popup/template-parts/shortcuts.js @@ -1,7 +1,48 @@ Satus.prototype.menu.main.shortcuts = { type: 'directory', - icon: '', + icon: '', + shortcut_qualuty: { + type: 'directory', + label: 'quality', + + shortcut_240p: { + type: 'shortcut', + label: '240p' + }, + shortcut_360p: { + type: 'shortcut', + label: '360p' + }, + shortcut_480p: { + type: 'shortcut', + label: '480p' + }, + shortcut_720p: { + type: 'shortcut', + label: '720p' + }, + shortcut_1080p: { + type: 'shortcut', + label: '1080p' + }, + shortcut_1440p: { + type: 'shortcut', + label: '1440p' + }, + shortcut_2160p: { + type: 'shortcut', + label: '2160p' + }, + shortcut_2880p: { + type: 'shortcut', + label: '2880p' + }, + shortcut_4320p: { + type: 'shortcut', + label: '4320p' + } + }, shortcut_picture_in_picture: { type: 'shortcut', label: 'pictureInPicture' @@ -10,7 +51,7 @@ Satus.prototype.menu.main.shortcuts = { type: 'shortcut', label: 'playPause', value: { - key: ' ' + key: ' ' } }, shortcut_stop: { @@ -21,30 +62,30 @@ Satus.prototype.menu.main.shortcuts = { type: 'shortcut', label: 'nextVideo', value: { - key: 'N', - shiftKey: true + key: 'N', + shiftKey: true } }, shortcut_prev_video: { type: 'shortcut', label: 'previousVideo', value: { - key: 'P', - shiftKey: true + key: 'P', + shiftKey: true } }, shortcut_seek_backward: { type: 'shortcut', label: 'seekBackward10Seconds', value: { - key: 'J' + key: 'J' } }, shortcut_seek_forward: { type: 'shortcut', label: 'seekForward10Seconds', value: { - key: 'I' + key: 'I' } }, shortcut_increase_volume: { @@ -67,21 +108,21 @@ Satus.prototype.menu.main.shortcuts = { type: 'shortcut', label: 'goToSearchBox', value: { - key: '/' + key: '/' } }, shortcut_activate_fullscreen: { type: 'shortcut', label: 'activateFullscreen', value: { - key: 'F' + key: 'F' } }, shortcut_activate_captions: { type: 'shortcut', label: 'activateCaptions', value: { - key: 'C' + key: 'C' } }, shortcut_like_shortcut: { diff --git a/popup/template-parts/themes.js b/popup/template-parts/themes.js index 0434a8619..52fd1e571 100644 --- a/popup/template-parts/themes.js +++ b/popup/template-parts/themes.js @@ -1,6 +1,6 @@ Satus.prototype.menu.main.themes = { type: 'directory', - icon: '', + icon: '', filters: { type: 'section', diff --git a/satus/components/css/directory.css b/satus/components/css/directory.css index 5a8d41160..ac67314d7 100644 --- a/satus/components/css/directory.css +++ b/satus/components/css/directory.css @@ -5,6 +5,7 @@ box-sizing: border-box; width: 100%; height: 48px; + min-height: 48px; padding: 0 16px; cursor: pointer; diff --git a/satus/components/css/select.css b/satus/components/css/select.css index fe3d7722b..f9c38dcd4 100644 --- a/satus/components/css/select.css +++ b/satus/components/css/select.css @@ -28,7 +28,7 @@ { display: flex; - margin: 0 0 4px 0; + margin: 0 8px 0 0; align-items: center; } diff --git a/youtube/css/shortcuts.css b/youtube/css/shortcuts.css new file mode 100644 index 000000000..88c698b80 --- /dev/null +++ b/youtube/css/shortcuts.css @@ -0,0 +1,11 @@ +#it-status +{ + font-size: 5rem; + + position: absolute; + top: 2rem; + right: 3rem; + + color: #0ff; + text-shadow: 1px 1px 2px #000; +} diff --git a/youtube/js/core.js b/youtube/js/core.js index 17d6b8c6a..77ad0644b 100644 --- a/youtube/js/core.js +++ b/youtube/js/core.js @@ -77,26 +77,26 @@ ImprovedTube.playerUpdate = function(node) { player = document.querySelector('.html5-video-player'); } - if (ImprovedTube.videoUrl !== this.src) { - ImprovedTube.videoUrl = this.src; + if (ImprovedTube.videoUrl !== location.href) { + ImprovedTube.videoUrl = location.href; ImprovedTube.playingTime = 0; - } - ImprovedTube.player_hd_thumbnail(); - ImprovedTube.player_quality(player); - ImprovedTube.player_volume(player); - ImprovedTube.player_playback_speed(player); - ImprovedTube.up_next_autoplay(); - ImprovedTube.player_autofullscreen(); - ImprovedTube.player_repeat_button(); - ImprovedTube.player_screenshot_button(); - ImprovedTube.player_rotate_button(); - ImprovedTube.player_popup_button(); - - ImprovedTube.playlist_repeat(); - ImprovedTube.playlist_shuffle(); - - ImprovedTube.dim(); + ImprovedTube.player_hd_thumbnail(); + ImprovedTube.player_quality(player); + ImprovedTube.player_volume(player); + ImprovedTube.player_playback_speed(player); + ImprovedTube.up_next_autoplay(); + ImprovedTube.player_autofullscreen(); + ImprovedTube.player_repeat_button(); + ImprovedTube.player_screenshot_button(); + ImprovedTube.player_rotate_button(); + ImprovedTube.player_popup_button(); + + ImprovedTube.playlist_repeat(); + ImprovedTube.playlist_shuffle(); + + ImprovedTube.dim(); + } }; diff --git a/youtube/js/features/general.js b/youtube/js/features/general.js index 2e99bf5ca..a4537a047 100644 --- a/youtube/js/features/general.js +++ b/youtube/js/features/general.js @@ -106,7 +106,7 @@ ImprovedTube.add_scroll_to_top = function(is_update) { var button = document.createElement('div'); button.id = 'it-scroll-to-top'; - button.innerHTML = ''; + button.innerHTML = ''; button.addEventListener('click', function() { window.scrollTo(0, 0); diff --git a/youtube/js/features/player.js b/youtube/js/features/player.js index 89f840607..c1f80348b 100644 --- a/youtube/js/features/player.js +++ b/youtube/js/features/player.js @@ -642,7 +642,7 @@ ImprovedTube.player_repeat_button = function(node) { this.createPlayerButton(node, { id: 'it-repeat-button', - html: '', + html: '', onclick: function() { if (node.querySelector('video').hasAttribute('loop')) { node.querySelector('video').removeAttribute('loop'); @@ -669,7 +669,7 @@ ImprovedTube.player_screenshot_button = function() { this.createPlayerButton(node, { id: 'it-screenshot-button', - html: '', + html: '', opacity: 1, onclick: function() { document.body.style.opacity = '0'; @@ -723,7 +723,7 @@ ImprovedTube.player_rotate_button = function() { this.createPlayerButton(node, { id: 'it-rotate-button', - html: '', + html: '', opacity: 1, onclick: function() { var video = document.querySelector('.html5-video-player video'), @@ -763,7 +763,7 @@ ImprovedTube.player_popup_button = function() { this.createPlayerButton(node, { id: 'it-popup-player-button', - html: '', + html: '', opacity: 1, onclick: function() { node.pauseVideo(); diff --git a/youtube/js/features/shortcuts.js b/youtube/js/features/shortcuts.js index 05ffe4144..14311cc30 100644 --- a/youtube/js/features/shortcuts.js +++ b/youtube/js/features/shortcuts.js @@ -9,7 +9,31 @@ ImprovedTube.shortcuts = function() { var self = this, keys = {}, wheel = 0, - hover = false; + hover = false, + status_timer; + + function showStatus(player, volume) { + if (!player.querySelector('#it-status')) { + var element = document.createElement('div'); + + element.id = 'it-status'; + element.innerHTML = volume; + + document.querySelector('.html5-video-container').appendChild(element); + } else { + player.querySelector('#it-status').innerHTML = volume; + } + + if (status_timer) { + clearTimeout(status_timer); + } + + status_timer = setTimeout(function() { + if (player.querySelector('#it-status')) { + player.querySelector('#it-status').remove(); + } + }, 500); + } function start(type = 'keys') { if (document.activeElement && ['EMBED', 'INPUT', 'OBJECT', 'TEXTAREA', 'IFRAME'].indexOf(document.activeElement.tagName) !== -1 || event.target.isContentEditable) { @@ -17,6 +41,78 @@ ImprovedTube.shortcuts = function() { } var features = { + shortcut_240p: function() { + var player = document.querySelector('#movie_player'); + + if (player) { + player.setPlaybackQualityRange('small'); + player.setPlaybackQuality('small'); + } + }, + shortcut_360p: function() { + var player = document.querySelector('#movie_player'); + + if (player) { + player.setPlaybackQualityRange('medium'); + player.setPlaybackQuality('medium'); + } + }, + shortcut_480p: function() { + var player = document.querySelector('#movie_player'); + + if (player) { + player.setPlaybackQualityRange('large'); + player.setPlaybackQuality('large'); + } + }, + shortcut_720p: function() { + var player = document.querySelector('#movie_player'); + + if (player) { + player.setPlaybackQualityRange('hd720'); + player.setPlaybackQuality('hd720'); + } + }, + shortcut_1080p: function() { + var player = document.querySelector('#movie_player'); + + if (player) { + player.setPlaybackQualityRange('hd1080'); + player.setPlaybackQuality('hd1080'); + } + }, + shortcut_1440p: function() { + var player = document.querySelector('#movie_player'); + + if (player) { + player.setPlaybackQualityRange('hd1440'); + player.setPlaybackQuality('hd1440'); + } + }, + shortcut_2160p: function() { + var player = document.querySelector('#movie_player'); + + if (player) { + player.setPlaybackQualityRange('hd2160'); + player.setPlaybackQuality('hd2160'); + } + }, + shortcut_2880p: function() { + var player = document.querySelector('#movie_player'); + + if (player) { + player.setPlaybackQualityRange('hd2880'); + player.setPlaybackQuality('hd2880'); + } + }, + shortcut_4320p: function() { + var player = document.querySelector('#movie_player'); + + if (player) { + player.setPlaybackQualityRange('highres'); + player.setPlaybackQuality('highres'); + } + }, shortcut_picture_in_picture_shortcut: function() { var video = document.querySelector('#movie_player video'); @@ -76,6 +172,8 @@ ImprovedTube.shortcuts = function() { if (player && player.setVolume && player.getVolume) { player.setVolume(player.getVolume() + 5); } + + showStatus(player, player.getVolume()); }, shortcut_decrease_volume: function() { var player = document.querySelector('.html5-video-player'); @@ -83,6 +181,8 @@ ImprovedTube.shortcuts = function() { if (player && player.setVolume && player.getVolume) { player.setVolume(player.getVolume() - 5); } + + showStatus(player, player.getVolume()); }, shortcut_increase_playback_speed: function() { var player = document.querySelector('#movie_player'); @@ -90,6 +190,8 @@ ImprovedTube.shortcuts = function() { if (player && player.setPlaybackRate && player.getPlaybackRate) { player.setPlaybackRate(player.getPlaybackRate() + .05); } + + showStatus(player, player.getPlaybackRate()); }, shortcut_decrease_playback_speed: function() { var player = document.querySelector('#movie_player'); @@ -97,6 +199,8 @@ ImprovedTube.shortcuts = function() { if (player && player.setPlaybackRate && player.getPlaybackRate) { player.setPlaybackRate(player.getPlaybackRate() - .05); } + + showStatus(player, player.getPlaybackRate()); }, shortcut_go_to_search_box: function() { var search = document.querySelector('#search'); diff --git a/youtube/js/features/themes.js b/youtube/js/features/themes.js index 5c37d4e68..eff63896b 100644 --- a/youtube/js/features/themes.js +++ b/youtube/js/features/themes.js @@ -18,7 +18,7 @@ ImprovedTube.bluelight = function() { var container = document.createElement('div'); container.id = 'it-bluelight'; - container.innerHTML = ''; + container.innerHTML = ''; document.documentElement.appendChild(container); } else { diff --git a/youtube/js/migration.js b/youtube/js/migration.js index a07d96a50..ee60ad584 100644 --- a/youtube/js/migration.js +++ b/youtube/js/migration.js @@ -41,448 +41,425 @@ 6.0 Channel 6.1 Default tab 6.2 Trailer autoplay + 6.3 Hide featured content -----------------------------------------------------------------------------*/ chrome.storage.local.get(function(object) { - for (var key in object) { - var value = object[key]; - - if (value === true) { - object[key] = true; - } - - if (value === false) { - object[key] = false; - } - - /*--------------------------------------------------------------------- - 1.0 General - ---------------------------------------------------------------------*/ - - /*--------------------------------------------------------------------- - 1.1 Legacy YouTube - ---------------------------------------------------------------------*/ - - if (key === 'youtube_version') { - if (value === 'old') { - object.legacy_youtube = true; - } else { - object.legacy_youtube = false; + if (object.migrated !== true) { + for (var key in object) { + var value = object[key]; + + if (value === 'true') { + object[key] = true; + } else if (value === 'false') { + object[key] = false; } - delete object[key]; - } + /*--------------------------------------------------------------------- + 1.0 General + ---------------------------------------------------------------------*/ + /*--------------------------------------------------------------------- + 1.1 Legacy YouTube + ---------------------------------------------------------------------*/ - /*--------------------------------------------------------------------- - 1.2 YouTube Home Page - ---------------------------------------------------------------------*/ + if (key === 'youtube_version') { + if (value === 'old') { + object.legacy_youtube = true; + } else { + object.legacy_youtube = false; + } - else if (key === 'youtube_home_page') { - if (value === 'normal') { - object[key] = '/'; - } else if (value === 'trending') { - object[key] = '/feed/trending'; - } else if (value === 'subscriptions') { - object[key] = '/feed/subscriptions'; - } else if (value === 'history') { - object[key] = '/feed/history'; - } else if (value === 'watch_later') { - object[key] = '/playlist?list=WL'; + delete object[key]; } - delete object[key]; - } - - /*--------------------------------------------------------------------- - 1.3 Add «Scroll to top» - ---------------------------------------------------------------------*/ - - else if (key === 'scroll_to_top') { - if (value === true) { - object.add_scroll_to_top = true; - } else { - object.add_scroll_to_top = false; + /*--------------------------------------------------------------------- + 1.2 YouTube Home Page + ---------------------------------------------------------------------*/ + else if (key === 'youtube_home_page') { + if (value === 'normal') { + object[key] = '/'; + } else if (value === 'trending') { + object[key] = '/feed/trending'; + } else if (value === 'subscriptions') { + object[key] = '/feed/subscriptions'; + } else if (value === 'history') { + object[key] = '/feed/history'; + } else if (value === 'watch_later') { + object[key] = '/playlist?list=WL'; + } } - delete object[key]; - } - - /*--------------------------------------------------------------------- - 1.4 Hide animated thumbnails - ---------------------------------------------------------------------*/ + /*--------------------------------------------------------------------- + 1.3 Add «Scroll to top» + ---------------------------------------------------------------------*/ + else if (key === 'scroll_to_top') { + if (value === 'true') { + object.add_scroll_to_top = true; + } else { + object.add_scroll_to_top = false; + } - else if (key === 'play_videos_by_hovering_the_thumbnails') { - if (value === false) { - object.hide_animated_thumbnails = true; - } else { - object.hide_animated_thumbnails = false; + delete object[key]; } - delete object[key]; - } - - /*--------------------------------------------------------------------- - 1.5 Confirmation before closing - ---------------------------------------------------------------------*/ + /*--------------------------------------------------------------------- + 1.4 Hide animated thumbnails + ---------------------------------------------------------------------*/ + else if (key === 'play_videos_by_hovering_the_thumbnails') { + if (value === 'false') { + object.hide_animated_thumbnails = true; + } else { + object.hide_animated_thumbnails = false; + } - else if (key === 'youtube_prevent_closure') { - if (value === true) { - object.confirmation_before_closing = true; + delete object[key]; } - delete object[key]; - } - - - /*--------------------------------------------------------------------- - 2.0 Appearance - ---------------------------------------------------------------------*/ - - /*--------------------------------------------------------------------- - 2.1 Header - ---------------------------------------------------------------------*/ - /*--------------------------------------------------------------------- - 2.1.1 Header style - ---------------------------------------------------------------------*/ + /*--------------------------------------------------------------------- + 1.5 Confirmation before closing + ---------------------------------------------------------------------*/ + else if (key === 'youtube_prevent_closure') { + if (value === 'true') { + object.confirmation_before_closing = true; + } - else if (key === 'header') { - if (value === 'top_of_page') { - object.header_position = 'static'; - } else { - object.header_position = value; + delete object[key]; } - delete object[key]; - } - - /*--------------------------------------------------------------------- - 2.1.2 Improve logo - ---------------------------------------------------------------------*/ - - else if (key === 'improve_youtube_logo') { - object.header_improve_logo = value; + /*--------------------------------------------------------------------- + 2.0 Appearance + ---------------------------------------------------------------------*/ - delete object[key]; - } + /*--------------------------------------------------------------------- + 2.1 Header + ---------------------------------------------------------------------*/ + /*--------------------------------------------------------------------- + 2.1.1 Header style + ---------------------------------------------------------------------*/ + else if (key === 'header') { + if (value === 'top_of_page') { + object.header_position = 'static'; + } else { + object.header_position = value; + } - /*--------------------------------------------------------------------- - 2.2 Player - ---------------------------------------------------------------------*/ - - /*--------------------------------------------------------------------- - 2.2.1 Annotations - ---------------------------------------------------------------------*/ - - else if (key === 'annotations') { - object.player_hide_annotations = value; - - delete object[key]; - } - - /*--------------------------------------------------------------------- - 2.2.2 Cards - ---------------------------------------------------------------------*/ - - else if (key === 'cards') { - object.player_hide_cards = value; - - delete object[key]; - } - - /*--------------------------------------------------------------------- - 2.2.3 Transparent background - ---------------------------------------------------------------------*/ - - else if (key === 'transparent_background') { - object.player_transparent_background = value; - - delete object[key]; - } - - /*--------------------------------------------------------------------- - 2.2.4 Endscreen - ---------------------------------------------------------------------*/ - - else if (key === 'endscreen') { - object.player_hide_endscreen = value; - - delete object[key]; - } - - /*--------------------------------------------------------------------- - 2.3 Footer - ---------------------------------------------------------------------*/ - - /*--------------------------------------------------------------------- - 2.3.5 Hide footer - ---------------------------------------------------------------------*/ + delete object[key]; + } - else if (key === 'footer') { - object.hide_footer = value === 'hidden' ? true : false; - delete object[key]; - } + /*--------------------------------------------------------------------- + 2.1.2 Improve logo + ---------------------------------------------------------------------*/ + else if (key === 'improve_youtube_logo') { + object.header_improve_logo = value; + delete object[key]; + } - /*--------------------------------------------------------------------- - 3.0 Themes - ---------------------------------------------------------------------*/ - else if (key === 'it_theme') { - object.theme = value; + /*--------------------------------------------------------------------- + 2.2 Player + ---------------------------------------------------------------------*/ - delete object[key]; - } + /*--------------------------------------------------------------------- + 2.2.1 Annotations + ---------------------------------------------------------------------*/ + else if (key === 'annotations') { + object.player_hide_annotations = value; + delete object[key]; + } - /*--------------------------------------------------------------------- - 4.0 Player - ---------------------------------------------------------------------*/ + /*--------------------------------------------------------------------- + 2.2.2 Cards + ---------------------------------------------------------------------*/ + else if (key === 'cards') { + object.player_hide_cards = value; - /*--------------------------------------------------------------------- - 4.1 Quality - ---------------------------------------------------------------------*/ + delete object[key]; + } - else if (key === 'video_quality') { - object.player_quality = value; + /*--------------------------------------------------------------------- + 2.2.3 Transparent background + ---------------------------------------------------------------------*/ + else if (key === 'transparent_background') { + object.player_transparent_background = value; - delete object[key]; - } + delete object[key]; + } + /*--------------------------------------------------------------------- + 2.2.4 Endscreen + ---------------------------------------------------------------------*/ + else if (key === 'endscreen') { + object.player_hide_endscreen = value; - /*--------------------------------------------------------------------- - 4.2 Volume - ---------------------------------------------------------------------*/ + delete object[key]; + } - else if (key === 'video_volume') { - object.player_volume = value; + /*--------------------------------------------------------------------- + 2.3 Footer + ---------------------------------------------------------------------*/ - delete object[key]; - } + /*--------------------------------------------------------------------- + 2.3.5 Hide footer + ---------------------------------------------------------------------*/ + else if (key === 'footer') { + object.hide_footer = value === 'hidden' ? true : false; + delete object[key]; + } - /*--------------------------------------------------------------------- - 4.3 Playback speed - ---------------------------------------------------------------------*/ - else if (key === 'video_playback_speed') { - object.player_playback_speed = value; + /*--------------------------------------------------------------------- + 3.0 Themes + ---------------------------------------------------------------------*/ + else if (key === 'it_theme') { + object.theme = value; - delete object[key]; - } + delete object[key]; + } - /*--------------------------------------------------------------------- - 4.4 Autoplay - ---------------------------------------------------------------------*/ + /*--------------------------------------------------------------------- + 4.0 Player + ---------------------------------------------------------------------*/ - else if (key === 'video_autoplay') { - object.player_autoplay = value; + /*--------------------------------------------------------------------- + 4.1 Quality + ---------------------------------------------------------------------*/ + else if (key === 'video_quality') { + object.player_quality = value; - delete object[key]; - } + delete object[key]; + } - /*--------------------------------------------------------------------- - 4.5 Allow 60fps - ---------------------------------------------------------------------*/ + /*--------------------------------------------------------------------- + 4.2 Volume + ---------------------------------------------------------------------*/ + else if (key === 'video_volume') { + object.player_volume = value; - else if (key === 'allow_60fps') { - object.player_60fps = value; + delete object[key]; + } - delete object[key]; - } + /*--------------------------------------------------------------------- + 4.3 Playback speed + ---------------------------------------------------------------------*/ + else if (key === 'video_playback_speed') { + object.player_playback_speed = value; - /*--------------------------------------------------------------------- - 4.6 Video codec h.264 - ---------------------------------------------------------------------*/ + delete object[key]; + } - else if (key === 'video_encode') { - object.player_h264 = value; - delete object[key]; - } + /*--------------------------------------------------------------------- + 4.4 Autoplay + ---------------------------------------------------------------------*/ + else if (key === 'video_autoplay') { + object.player_autoplay = value; + delete object[key]; + } - /*--------------------------------------------------------------------- - 4.7 Allow subtitles - ---------------------------------------------------------------------*/ - else if (key === 'allow_subtitles') { - object.player_subtitles = value; + /*--------------------------------------------------------------------- + 4.5 Allow 60fps + ---------------------------------------------------------------------*/ + else if (key === 'allow_60fps') { + object.player_60fps = value; - delete object[key]; - } + delete object[key]; + } - /*--------------------------------------------------------------------- - 4.8 Loudness normalization - ---------------------------------------------------------------------*/ + /*--------------------------------------------------------------------- + 4.6 Video codec h.264 + ---------------------------------------------------------------------*/ + else if (key === 'video_encode') { + object.player_h264 = value; - else if (key === 'allow_loudness') { - object.player_loudness_normalization = value; + delete object[key]; + } - delete object[key]; - } + /*--------------------------------------------------------------------- + 4.7 Allow subtitles + ---------------------------------------------------------------------*/ + else if (key === 'allow_subtitles') { + object.player_subtitles = value; - /*--------------------------------------------------------------------- - 4.8 Mini player - ---------------------------------------------------------------------*/ + delete object[key]; + } - else if (key === 'mini_player_b') { - object.mini_player = value; - delete object[key]; - } + /*--------------------------------------------------------------------- + 4.8 Loudness normalization + ---------------------------------------------------------------------*/ + else if (key === 'allow_loudness') { + object.player_loudness_normalization = value; + delete object[key]; + } - /*--------------------------------------------------------------------- - 4.9 Ads - ---------------------------------------------------------------------*/ - else if (key === 'allow_video_ads') { - object.player_ads = 'all_videos'; + /*--------------------------------------------------------------------- + 4.8 Mini player + ---------------------------------------------------------------------*/ + else if (key === 'mini_player_b') { + object.mini_player = value; - delete object[key]; - } else if (key === 'subscribed_channel_player_ads' && value === true) { - object.player_ads = 'subscribed_channels'; + delete object[key]; + } - delete object[key]; - } + /*--------------------------------------------------------------------- + 4.9 Ads + ---------------------------------------------------------------------*/ + else if (key === 'allow_video_ads') { + object.player_ads = 'all_videos'; - /*--------------------------------------------------------------------- - 4.10 Autopause - ---------------------------------------------------------------------*/ + delete object[key]; + } else if (key === 'subscribed_channel_player_ads' && value === true) { + object.player_ads = 'subscribed_channels'; - else if (key === 'video_autopause') { - object.player_autopause = value; + delete object[key]; + } - delete object[key]; - } + /*--------------------------------------------------------------------- + 4.10 Autopause + ---------------------------------------------------------------------*/ + else if (key === 'video_autopause') { + object.player_autopause = value; - /*--------------------------------------------------------------------- - 4.11 Auto-fullscreen - ---------------------------------------------------------------------*/ + delete object[key]; + } - else if (key === 'video_autofullscreen') { - object.player_autofullscreen = value; - delete object[key]; - } + /*--------------------------------------------------------------------- + 4.11 Auto-fullscreen + ---------------------------------------------------------------------*/ + else if (key === 'video_autofullscreen') { + object.player_autofullscreen = value; + delete object[key]; + } - /*--------------------------------------------------------------------- - 4.12 Repeat button - ---------------------------------------------------------------------*/ - else if (key === 'video_repeat_button') { - object.player_repeat_button = value; + /*--------------------------------------------------------------------- + 4.12 Repeat button + ---------------------------------------------------------------------*/ + else if (key === 'video_repeat_button') { + object.player_repeat_button = value; - delete object[key]; - } + delete object[key]; + } - /*--------------------------------------------------------------------- - 4.13 Screenshot button - ---------------------------------------------------------------------*/ + /*--------------------------------------------------------------------- + 4.13 Screenshot button + ---------------------------------------------------------------------*/ + else if (key === 'screenshot_button') { + object.player_screenshot_button = value; - else if (key === 'screenshot_button') { - object.player_screenshot_button = value; + delete object[key]; + } - delete object[key]; - } + /*--------------------------------------------------------------------- + 4.14 Rotate button + ---------------------------------------------------------------------*/ + else if (key === 'video_rotate_button') { + object.player_rotate_button = value; - /*--------------------------------------------------------------------- - 4.14 Rotate button - ---------------------------------------------------------------------*/ + delete object[key]; + } - else if (key === 'video_rotate_button') { - object.player_rotate_button = value; - delete object[key]; - } + /*--------------------------------------------------------------------- + 4.15 Popup button + ---------------------------------------------------------------------*/ + else if (key === 'popup_player_button') { + object.player_popup_button = value; + delete object[key]; + } - /*--------------------------------------------------------------------- - 4.15 Popup button - ---------------------------------------------------------------------*/ - else if (key === 'popup_player_button') { - object.player_popup_button = value; + /*--------------------------------------------------------------------- + 5.0 Playlist + ---------------------------------------------------------------------*/ - delete object[key]; - } + /*--------------------------------------------------------------------- + 5.1 Repeat + ---------------------------------------------------------------------*/ + else if (key === 'playlist_repeat') { + if (value === 'enabled') { + object.playlist_repeat = true; + } else if (value === 'disabled') { + object.playlist_repeat = false; + } + } + /*--------------------------------------------------------------------- + 5.2 Shuffle + ---------------------------------------------------------------------*/ + else if (key === 'playlist_shuffle') { + if (value === 'enabled') { + object.playlist_repeat = true; + } else if (value === 'disabled') { + object.playlist_repeat = false; + } + } - /*--------------------------------------------------------------------- - 5.0 Playlist - ---------------------------------------------------------------------*/ - /*--------------------------------------------------------------------- - 5.1 Repeat - ---------------------------------------------------------------------*/ + /*--------------------------------------------------------------------- + 6.0 Channel + ---------------------------------------------------------------------*/ - else if (key === 'playlist_repeat') { - if (value === 'enabled') { - object.playlist_repeat = true; - } else if (value === 'disabled') { - object.playlist_repeat = false; + /*--------------------------------------------------------------------- + 6.1 Default tab + ---------------------------------------------------------------------*/ + else if (key === 'channel_default_page') { + if (value === 'normal') { + object.channel_default_tab = '/'; + } else { + object.channel_default_tab = '/' + value; + } } - } - /*--------------------------------------------------------------------- - 5.2 Shuffle - ---------------------------------------------------------------------*/ + /*--------------------------------------------------------------------- + 6.2 Trailer autoplay + ---------------------------------------------------------------------*/ + else if (key === 'channel_autoplay') { + object.channel_trailer_autoplay = value; - else if (key === 'playlist_shuffle') { - if (value === 'enabled') { - object.playlist_repeat = true; - } else if (value === 'disabled') { - object.playlist_repeat = false; + delete object[key]; } - } + /*--------------------------------------------------------------------- + 6.3 Hide featured content + ---------------------------------------------------------------------*/ + else if (key === 'channel_featured_content') { + object.channel_hide_featured_content = value; - /*--------------------------------------------------------------------- - 6.0 Channel - ---------------------------------------------------------------------*/ - - /*--------------------------------------------------------------------- - 6.1 Default tab - ---------------------------------------------------------------------*/ - - else if (key === 'channel_default_page') { - if (value === 'normal') { - object.channel_default_tab = '/'; - } else { - object.channel_default_tab = '/' + value; + delete object[key]; } - - delete object[key]; } - /*--------------------------------------------------------------------- - 6.2 Trailer autoplay - ---------------------------------------------------------------------*/ + object.migrated = true; - else if (key === 'channel_autoplay') { - object.channel_trailer_autoplay = value; - - delete object[key]; - } + chrome.storage.local.clear(); + chrome.storage.local.set(object); } - - chrome.storage.local.set(object); }); \ No newline at end of file