diff --git a/src/css/main.css b/src/css/main.css index a37bdbf..8221802 100644 --- a/src/css/main.css +++ b/src/css/main.css @@ -1,31 +1,37 @@ +html[global_enable="true"] #masthead-ad, +html[global_enable="true"] ytd-mealbar-promo-renderer, + /* Main */ html[global_enable="true"][remove_homepage="true"] ytd-browse[page-subtype="home"], html[global_enable="true"][remove_sidebar="true"] #secondary > div.circle, html[global_enable="true"][remove_sidebar="true"] #related, html[global_enable="true"][remove_end_of_video="true"] .html5-endscreen, -/* Site Navigation */ +/* Left Bar Navigation */ html[global_enable="true"][remove_home_link="true"] a:not(#logo)[href="/"], -html[global_enable="true"][remove_explore_link="true"] a[href="/feed/trending"], html[global_enable="true"][remove_shorts_link="true"] a[title="Shorts"], +html[global_enable="true"][remove_explore_link="true"] a[href="/feed/trending"], html[global_enable="true"][remove_shorts_link="true"] ytd-mini-guide-entry-renderer[aria-label="Shorts"], html[global_enable="true"][remove_explore_link="true"] a[href="/feed/explore"], -/* More Removal Options */ -html[global_enable="true"][remove_entire_sidebar="true"] #secondary, +/* Homepage */ html[global_enable="true"][remove_infinite_scroll="true"] ytd-rich-grid-renderer > #contents > ytd-continuation-item-renderer, html[global_enable="true"][remove_all_but_one="true"] ytd-rich-grid-renderer > #contents > ytd-rich-grid-row:nth-child(n+2), html[global_enable="true"][remove_all_but_one="true"] ytd-rich-grid-renderer > #contents > ytd-continuation-item-renderer, html[global_enable="true"][remove_extra_rows="true"] ytd-rich-grid-renderer > #contents > ytd-rich-grid-row + ytd-rich-section-renderer, -html[global_enable="true"][remove_thumbnail_mouseover_effect="true"] #mouseover-overlay, + +/* Video Player */ +html[global_enable="true"][remove_entire_sidebar="true"] #secondary, html[global_enable="true"][remove_play_next_button="true"] a.ytp-next-button, html[global_enable="true"][remove_comments="true"] #comments, html[global_enable="true"][remove_comments="true"] #comment-teaser, html[global_enable="true"][remove_comments="true"] ytd-engagement-panel-section-list-renderer[target-id="engagement-panel-comments-section"], -html[global_enable="true"][remove_chat="true"] #chat, html[global_enable="true"][remove_info_cards="true"] .ytp-ce-element.ytp-ce-element, +/* Search Results Page */ +html[global_enable="true"][remove_thumbnail_mouseover_effect="true"] #mouseover-overlay, + html[global_enable="true"][foo=bar] { diff --git a/src/css/options.css b/src/css/options.css index 4f09115..1350d30 100644 --- a/src/css/options.css +++ b/src/css/options.css @@ -17,6 +17,15 @@ html[dark_mode='true'] body { background-color: #393939 } html[dark_mode='true'] body * { color: #B9B9B9 } html[dark_mode='true'] .footer-path { fill: #B9B9B9 } +html[dark_mode='true'] { + --hover-box-shadow-color: rgba(0, 0, 0, 0.95); + --hover-fieldset-legend-color: white; +} +html[dark_mode='false'] { + --hover-box-shadow-color: rgba(0, 0, 0, 0.30); + --hover-fieldset-legend-color: black; +} + /* Begin Main styling */ html, body { height: 100% } @@ -28,7 +37,7 @@ body { min-width: 349px; max-width: 350px; height: fit-content; - max-height: 600px; + max-height: 700px; padding: 2px 2px 2px 2px; margin: 2px 2px 2px 2px; @@ -39,9 +48,23 @@ body, body * { font-family: Helvetica; } -.minor_text { - font-size: 10px; - font-style: italic; +label { + position: relative; +} + +.tooltip { + position: absolute; + height: 95%; + + /* center vertically */ + top: 50%; + -ms-transform: translateY(-50%); + transform: translateY(-50%); + + margin-left: 1px; +} +.tooltip:hover { + height: 110%; } /* Begin header */ @@ -113,20 +136,30 @@ body, body * { -moz-transition: box-shadow 0.1s; -o-transition: box-shadow 0.1s; transition: box-shadow 0.1s; - padding: 2px; -} -#primary_options:hover { - box-shadow: 0px 0px 10px 1px rgba(0, 0, 0, 0.30); + padding: 1px; } #primary_options div { - height: 16px; + height: 15px; } #primary_options fieldset:not(:nth-child(1)) { margin-top: 5px; } +fieldset { + padding-bottom: 5px; + box-sizing: border-box; +} +fieldset:hover legend, fieldset:hover legend * { + font-weight: bold; + color: var(--hover-fieldset-legend-color); +} +fieldset:hover { + box-shadow: 10px 5px 10px 1px var(--hover-box-shadow-color); + box-sizing: border-box; +} + .option_name_container { cursor: default; } diff --git a/src/css/search.css b/src/css/search.css index a739098..5ca6f75 100644 --- a/src/css/search.css +++ b/src/css/search.css @@ -1,6 +1,7 @@ /* Personalized search results. */ html[global_enable="true"][remove_extra_results="true"] ytd-shelf-renderer, + html[global_enable="true"][foo=bar] { diff --git a/src/images/tooltip.svg b/src/images/tooltip.svg new file mode 100644 index 0000000..1ace252 --- /dev/null +++ b/src/images/tooltip.svg @@ -0,0 +1,10 @@ + + diff --git a/src/js/content-script.js b/src/js/content-script.js index b631219..c9687d8 100644 --- a/src/js/content-script.js +++ b/src/js/content-script.js @@ -8,33 +8,43 @@ const HTML = document.documentElement; const SETTINGS_LIST = { "dark_mode": { defaultValue: false, eventType: 'click' }, "global_enable": { defaultValue: true, eventType: 'click' }, + "remove_homepage": { defaultValue: true, eventType: 'change' }, "remove_sidebar": { defaultValue: true, eventType: 'change' }, "remove_end_of_video": { defaultValue: true, eventType: 'change' }, + "remove_all_but_one": { defaultValue: false, eventType: 'change' }, "remove_infinite_scroll": { defaultValue: false, eventType: 'change' }, "remove_extra_rows": { defaultValue: false, eventType: 'change' }, + "remove_logo_link": { defaultValue: false, eventType: 'change' }, "remove_home_link": { defaultValue: false, eventType: 'change' }, - "remove_shorts_link": { defaultValue: false, eventType: 'change' }, "remove_explore_link": { defaultValue: false, eventType: 'change' }, - "remove_extra_results": { defaultValue: false, eventType: 'change' }, + "remove_shorts_link": { defaultValue: false, eventType: 'change' }, + + "auto_skip_ads": { defaultValue: true, eventType: 'change' }, "remove_entire_sidebar": { defaultValue: false, eventType: 'change' }, + "disable_autoplay": { defaultValue: false, eventType: 'change' }, "remove_info_cards": { defaultValue: false, eventType: 'change' }, "remove_play_next_button": { defaultValue: false, eventType: 'change' }, "remove_comments": { defaultValue: false, eventType: 'change' }, + + "remove_extra_results": { defaultValue: false, eventType: 'change' }, "remove_thumbnail_mouseover_effect": { defaultValue: false, eventType: 'change' }, - "remove_chat": { defaultValue: false, eventType: 'change' }, + "redirect_off": { defaultValue: true, eventType: 'change' }, "redirect_to_subs": { defaultValue: false, eventType: 'change' }, "redirect_to_wl": { defaultValue: false, eventType: 'change' }, + }; // Initialize HTML attributes with local settings, or default. +const cache = {}; try { browser.storage.local.get(localSettings => { Object.entries(SETTINGS_LIST).forEach(([key, { defaultValue }]) => { HTML.setAttribute(key, localSettings[key] ?? defaultValue); + cache[key] = localSettings[key] ?? defaultValue; }); }); } catch (e) { @@ -44,6 +54,30 @@ try { // Update HTML attributes in real time. // receive messages from options.js browser.runtime.onMessage.addListener((data, sender) => { - data.forEach(({ key, value }) => HTML.setAttribute(key, value)); + data.forEach(({ key, value }) => { + HTML.setAttribute(key, value); + cache[key] = value; + }); return true; }); + + +// Dynamic settings (i.e. js instead of css) +document.addEventListener("DOMContentLoaded", event => { + const observer = new MutationObserver(mutations => { + if (cache['global_enable'] !== true) return; + + if (cache['disable_autoplay'] === true) { + document.querySelectorAll('.ytp-autonav-toggle-button[aria-checked=true]')?.[0]?.click(); + } + + if (cache['auto_skip_ads'] === true) { + document.querySelectorAll('.ytp-ad-skip-button')?.[0]?.click(); + } + + // if (cache['change_playback_speed']) { + // document.getElementsByTagName("video")[0].playbackRate = Number(cache['change_playback_speed']); + // } + }); + observer.observe(document.body, { subtree: true, childList: true }); +}); diff --git a/src/js/events.js b/src/js/events.js index facd033..9eea9f0 100644 --- a/src/js/events.js +++ b/src/js/events.js @@ -2,14 +2,12 @@ if (typeof browser === 'undefined') { browser = typeof chrome !== 'undefined' ? chrome : null; } +const uninstallUrl = "http://lawrencehook.com/rys/👋"; +browser.runtime.setUninstallURL(uninstallUrl); -browser.runtime.onInstalled.addListener(function (object) { - const installUrl = "http://lawrencehook.com/rys/welcome"; - const uninstallUrl = "http://lawrencehook.com/rys/👋"; - +browser.runtime.onInstalled.addListener(object => { + const url = "http://lawrencehook.com/rys/welcome"; if (object.reason === browser.runtime.OnInstalledReason.INSTALL) { - browser.runtime.setUninstallURL(uninstallUrl); - browser.tabs.create({ url: installUrl }, tab => {}); + browser.tabs.create({ url }, tab => {}); } - }); diff --git a/src/js/options.js b/src/js/options.js index e666258..bf49d34 100644 --- a/src/js/options.js +++ b/src/js/options.js @@ -6,25 +6,32 @@ if (typeof browser === 'undefined') { // Some global constants. const HTML = document.documentElement; const SETTINGS_LIST = { - "dark_mode": { defaultValue: false, eventType: 'click' }, + "dark_mode": { defaultValue: false, eventType: 'click' }, "global_enable": { defaultValue: true, eventType: 'click' }, + "remove_homepage": { defaultValue: true, eventType: 'click' }, "remove_sidebar": { defaultValue: true, eventType: 'click' }, "remove_end_of_video": { defaultValue: true, eventType: 'click' }, - "remove_logo_link": { defaultValue: false, eventType: 'click' }, - "remove_home_link": { defaultValue: false, eventType: 'click' }, - "remove_shorts_link": { defaultValue: false, eventType: 'click' }, - "remove_explore_link": { defaultValue: false, eventType: 'click' }, + "remove_infinite_scroll": { defaultValue: false, eventType: 'click' }, "remove_all_but_one": { defaultValue: false, eventType: 'click' }, "remove_extra_rows": { defaultValue: false, eventType: 'click' }, - "remove_extra_results": { defaultValue: false, eventType: 'click' }, + + "remove_logo_link": { defaultValue: false, eventType: 'click' }, + "remove_home_link": { defaultValue: false, eventType: 'click' }, + "remove_explore_link": { defaultValue: false, eventType: 'click' }, + "remove_shorts_link": { defaultValue: false, eventType: 'click' }, + + "auto_skip_ads": { defaultValue: false, eventType: 'click' }, "remove_entire_sidebar": { defaultValue: false, eventType: 'click' }, + "disable_autoplay": { defaultValue: false, eventType: 'click' }, "remove_info_cards": { defaultValue: false, eventType: 'click' }, "remove_play_next_button": { defaultValue: false, eventType: 'click' }, "remove_comments": { defaultValue: false, eventType: 'click' }, + + "remove_extra_results": { defaultValue: false, eventType: 'click' }, "remove_thumbnail_mouseover_effect": { defaultValue: false, eventType: 'click' }, - "remove_chat": { defaultValue: false, eventType: 'click' }, + "redirect_off": { defaultValue: true, eventType: 'click' }, "redirect_to_subs": { defaultValue: false, eventType: 'click' }, "redirect_to_wl": { defaultValue: false, eventType: 'click' }, diff --git a/src/manifest.json b/src/manifest.json index a62a33b..66fc955 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -3,7 +3,7 @@ "description": "Stop the YouTube rabbit hole. Customize YouTube's user interface to be less engaging.", "homepage_url": "https://github.com/lawrencehook/remove-youtube-suggestions", "manifest_version": 2, - "version": "4.2.7", + "version": "4.2.8", "icons": { "16": "images/16.png", diff --git a/src/options.html b/src/options.html index d384945..46e1011 100644 --- a/src/options.html +++ b/src/options.html @@ -48,24 +48,30 @@