├── .gitignore ├── LICENSE ├── README.md └── youtube-element-blocker.js /.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Kamen Mladenov 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # min-youtube-element-blocker 2 | 3 | Block specific elements of YouTube, like the Feed, Comments, Merch and more. **Made for [Min](https://github.com/minbrowser/min) browser**, although it can be used with any other userscript manager (tested with [Tampermonkey](https://www.tampermonkey.net/)). 4 | 5 | ## How to install 6 | 7 | If you are using Min: 8 | 9 | 1. Enable userscripts in Min's preferences and create a `userscripts` directory, following [these instructions](https://github.com/minbrowser/min/wiki/userscripts) 10 | 2. Save the [`youtube-element-blocker.js`](https://raw.githubusercontent.com/Syndamia/min-youtube-element-blocker/master/youtube-element-blocker.js) file (with the `.js` extension) in the `userscripts` folder 11 | 3. Restart Min 12 | 13 | If you are using some other browser, you'll need to install a userscript manager, like [Tampermonkey](https://www.tampermonkey.net/), with which to install (and use) the script ([this link to the file](https://raw.githubusercontent.com/Syndamia/min-youtube-element-blocker/master/youtube-element-blocker.js) should work). 14 | 15 | ## How to update 16 | 17 | Updating the script is done manually, meaning you'll have to manually check for updates and replace your file with the latest release (or master, it never gets too ahead of releases). 18 | 19 | **IMPORTANT**: updating the script could "erase" your settings, especially if you are using Min 20 | 21 | Users of Linux and Min can use this command for updating (which can also be used for steps 1 and 2 of the installation): 22 | ``` 23 | mkdir -p ~/.config/Min/userscripts && wget -q https://raw.githubusercontent.com/Syndamia/min-youtube-element-blocker/master/youtube-element-blocker.js -O ~/.config/Min/userscripts/youtube-element-blocker.js 24 | ``` 25 | 26 | ## Changing settings 27 | 28 | Changing settings is done through **modifying the file**. By default, nothing is enabled. If you are using Min, restart the browser after changing a setting. 29 | 30 | ### General settings 31 | 32 | In the beginning of the file you'll find this: 33 | 34 | ``` 35 | var settings = { 36 | // The feed is the collection of videos, shown on the home page 37 | "hideFeed" : false, 38 | 39 | // The guide drawer is the drawer (sidebar) to the left 40 | // which you use for navigating Playlists, Subscriptions, ... 41 | "hideGuideDrawer" : false, 42 | 43 | "hideGuideHomeTab" : false, 44 | 45 | "hideGuideTrendingTab" : false, 46 | 47 | "hideGuideMoreFromYouTube" : false, 48 | 49 | // The last section is the part under "More from YouTube", 50 | // where you can find the buttons for "Help", "Send Feedback", ... 51 | "hideGuideLastSection" : false, 52 | 53 | // The footer is the part at the very bottom of the guide drawer 54 | // that shows links like "About", "Terms", "Contact us", ... 55 | "hideGuideFooter" : false, 56 | 57 | // Related videos are the recommendations at the end of a video 58 | "hideRelated" : false, 59 | 60 | "hideChat" : false, 61 | 62 | // The sidebar is the section to the right of a video 63 | // where you can find video and playlist suggestions 64 | "hideSidebar" : false, 65 | 66 | "hideMerch" : false, 67 | 68 | "hideComments" : false, 69 | 70 | // Makes comments at the top of the page visible when printing 71 | // Note: also loses navigation button. Can hide 'skip navigation' button only. 72 | "hideMasthead": false, 73 | 74 | "hideSkipNavButton": false, 75 | }; 76 | ``` 77 | 78 | Here, you change the words `false` to `true` if you want the setting to be enabled. Leaving it, or changing it back to `false` will disable the setting. 79 | 80 | ### Timeout 81 | 82 | Below it you'll find the "Timeout" settings. Through Timeout, you can set a specific time duration, during which the whole YouTube website will be blocked. 83 | 84 | ``` 85 | var timeout = { 86 | "enabled" : false, 87 | // Determines days, in which the timeout will be active. Each day is separated 88 | // by a comma. Can be 0 to 6, where 0 is Sunday, 1 is Monday and 6 is Saturday. 89 | "activeDays" : [0, 1, 2, 3, 4, 5, 6], 90 | 91 | // Determines time from which the timeout will block YouTube. 92 | // Must be numbers, from 0 to 24 for hour and from 0 to 59 for minutes. 93 | "startHour" : 09, 94 | "startMinutes" : 00, 95 | 96 | // Determines end of time from which the timeout will block YouTube. 97 | // Must be numbers, from 0 to 24 for hour and from 0 to 59 for minutes. 98 | "endHour" : 17, 99 | "endMinutes" : 00, 100 | }; 101 | ``` 102 | 103 | Change the word `false` to `true` to activate the feature and change it back to `false` to deactivate it. 104 | 105 | After that you'll need to set on which days it should be active. 106 | 107 | Following are the settings from when the feature should be active (`startHour`, `startMinutes`) and when it should stop (`endHour`, `endMinutes`). 108 | 109 | -------------------------------------------------------------------------------- /youtube-element-blocker.js: -------------------------------------------------------------------------------- 1 | // ==UserScript== 2 | // @name YouTube element blocker 3 | // @description Block specific elements of YouTube, like the Feed, Comments, Subscriptions bar and more 4 | // 5 | // @version 1.5.2 6 | // @license MIT 7 | // @author Syndamia 8 | // 9 | // @source https://github.com/Syndamia/min-youtube-element-blocker 10 | // @supportURL https://github.com/Syndamia/min-youtube-element-blocker/issues 11 | // @homepage https://greasyfork.org/en/scripts/419701-youtube-element-blocker 12 | // @icon https://upload.wikimedia.org/wikipedia/commons/1/1a/YouTube_play_button_dark_rounded_square_%282013-2017%29.svg 13 | // 14 | // @namespace Syndamia 15 | // @match *://*.youtube.com/* 16 | // @run-at document-start 17 | // ==/UserScript== 18 | 19 | /* Change the word after the name of a setting (and after the column character) to 20 | * true to enable it and to false to disable it (DO NOT REMOVE THE COMMA AFTER THE WORD) 21 | * For example, enabled hideFeed will look like this: "hideFeed" : true, 22 | */ 23 | 24 | var generalSettings = { 25 | // The feed is the collection of videos, shown on the home page 26 | "hideFeed" : false, 27 | 28 | // The guide drawer is the drawer (sidebar) to the left 29 | // which is used for navigating Playlists, Subscriptions, ... 30 | "hideGuideDrawer" : false, 31 | 32 | "hideGuideHomeTab" : false, 33 | 34 | "hideGuideTrendingTab" : false, 35 | 36 | "hideGuideShortsTab" : false, 37 | 38 | "hideGuideLibraryTab" : false, 39 | 40 | "hideGuideMoreFromYouTube" : false, 41 | 42 | // The last section is the part under "More from YouTube", 43 | // where you can find the buttons for "Help", "Send Feedback", ... 44 | "hideGuideLastSection" : false, 45 | 46 | // The footer is the part at the very bottom of the guide drawer 47 | // that shows links like "About", "Terms", "Contact us", ... 48 | "hideGuideFooter" : false, 49 | 50 | // Related videos are the recommendations at the end of a video 51 | "hideRelated" : false, 52 | 53 | "hideChat" : false, 54 | 55 | // The sidebar is the section to the right of a video 56 | // where you can find video and playlist suggestions 57 | "hideSidebar" : false, 58 | 59 | "hideMerch" : false, 60 | 61 | "hideComments" : false, 62 | 63 | // Makes comments at the top of the page visible when printing 64 | // Note: also loses navigation button. Can hide 'skip navigation' button only. 65 | "hideMasthead": false, 66 | 67 | "hideSkipNavButton": false, 68 | }; 69 | 70 | /* The whole YouTube website can also be blocked (independently of the other settings) 71 | * depending on the time of day and the day in the week. This feature is called timeout. 72 | */ 73 | 74 | var timeout = { 75 | "enabled" : false, 76 | // Determines days, in which the timeout will be active. Each day is separated 77 | // by a comma. Can be 0 to 6, where 0 is Sunday, 1 is Monday and 6 is Saturday. 78 | "activeDays" : [0, 1, 2, 3, 4, 5, 6], 79 | 80 | // Determines time from which the timeout will block YouTube. 81 | // Must be numbers, from 0 to 24 for hour and from 0 to 59 for minutes. 82 | "startHour" : 9, 83 | "startMinutes" : 0, 84 | 85 | // Determines end of time from which the timeout will block YouTube. 86 | // Must be numbers, from 0 to 24 for hour and from 0 to 59 for minutes. 87 | "endHour" : 17, 88 | "endMinutes" : 0, 89 | }; 90 | 91 | /************************************/ 92 | /* END OF USER CONFIGURABLE OPTIONS */ 93 | /************************************/ 94 | 95 | /* CSS that is added to page for hiding the elements */ 96 | 97 | var css = { 98 | "hideFeed": ` 99 | #feed, ytd-browse[page-subtype=home] { 100 | display: none !important; 101 | }`, 102 | 103 | "hideGuideDrawer": ` 104 | #appbar-guide-menu { 105 | width: 0; 106 | } 107 | app-drawer#guide { 108 | display: none !important; 109 | } 110 | ytd-mini-guide-renderer { 111 | display: none !important; 112 | } 113 | #guide-button { 114 | display: none !important; 115 | }`, 116 | 117 | "hideGuideHomeTab": ` 118 | #home-guide-item { 119 | display: none !important; 120 | } 121 | ytd-guide-section-renderer:first-child #items > ytd-guide-entry-renderer:first-child { 122 | display: none !important; 123 | } 124 | #appbar-nav li:first-child { 125 | display: none !important; 126 | } 127 | ytd-mini-guide-renderer #items ytd-mini-guide-entry-renderer:first-child { 128 | display: none !important; 129 | }`, 130 | 131 | "hideGuideTrendingTab": ` 132 | #trending-guide-item { 133 | display: none !important; 134 | } 135 | #appbar-nav li:nth-child(2) { 136 | display: none !important; 137 | } 138 | ytd-mini-guide-renderer #items ytd-mini-guide-entry-renderer:nth-child(2) { 139 | display: none !important; 140 | }`, 141 | 142 | "hideGuideShortsTab": ` 143 | ytd-guide-section-renderer:first-child #items > ytd-guide-entry-renderer:nth-child(2) { 144 | display: none !important; 145 | } 146 | #appbar-nav li:nth-child(3) { 147 | display: none !important; 148 | } 149 | ytd-mini-guide-renderer #items ytd-mini-guide-entry-renderer:nth-child(3) { 150 | display: none !important; 151 | }`, 152 | 153 | "hideGuideLibraryTab" : ` 154 | ytd-guide-section-renderer:first-child #items > ytd-guide-collapsible-section-entry-renderer > #header { 155 | display: none !important; 156 | }`, 157 | 158 | "hideGuideMoreFromYouTube": ` 159 | ytd-guide-section-renderer:nth-last-child(2) { 160 | display: none !important; 161 | }`, 162 | 163 | "hideGuideLastSection": ` 164 | ytd-guide-section-renderer:last-child { 165 | display: none !important; 166 | }`, 167 | 168 | "hideGuideFooter": ` 169 | #footer { 170 | display: none !important; 171 | }`, 172 | 173 | "hideRelated": ` 174 | .ytp-endscreen-content { 175 | display: none !important; 176 | } 177 | .ytp-ce-video { 178 | display: none !important; 179 | }`, 180 | 181 | "hideChat": ` 182 | ytd-live-chat-frame { 183 | display: none !important; 184 | }`, 185 | 186 | "hideSidebar": ` 187 | #watch7-sidebar-contents, #related { 188 | display: none !important; 189 | }`, 190 | 191 | "hideMerch": ` 192 | .ytd-merch-shelf-renderer { 193 | display: none !important; 194 | }`, 195 | 196 | "hideComments": ` 197 | #watch-discussion, #comments { 198 | display: none !important; 199 | }`, 200 | "hideSkipNavButton": ` 201 | #skip-navigation.ytd-masthead { 202 | display: none !important; 203 | }`, 204 | 205 | "hideMasthead": ` 206 | #container.ytd-masthead { 207 | display: none !important; 208 | }`, 209 | }; 210 | 211 | // Element, that will contain CSS of activated settings 212 | var style = document.createElement('style'); 213 | 214 | if(timeout.enabled) { 215 | var now = new Date(), 216 | start = new Date(), 217 | end = new Date(); 218 | 219 | start.setHours(timeout.startHour, timeout.startMinutes, 0); 220 | end.setHours(timeout.endHour, timeout.endMinutes, 0); 221 | 222 | if (now >= start && now < end && timeout.activeDays.includes(now.getDay())) { 223 | style.textContent = "body { display: none !important; }" 224 | } 225 | } 226 | 227 | // Execute general settings, only if the timeout isn't active 228 | if (style.textContent === "") { 229 | for (var setting in generalSettings) { 230 | if (!generalSettings[setting]) continue; 231 | 232 | style.textContent += css[setting]; 233 | } 234 | } 235 | 236 | document.head.appendChild(style); 237 | --------------------------------------------------------------------------------