|
1 | 1 | // ==UserScript== |
2 | 2 | // @name Fuck YouTube Ads w/o Lubricant |
3 | 3 | // @namespace https://www.github.com/vippium/ |
4 | | -// @version 1.7.0 |
| 4 | +// @version 1.7.1 |
5 | 5 | // @description Very Useful for Ad-free experience (M*therF@ckers are not allowed to use this) |
6 | 6 | // @author vippium |
7 | 7 | // @match https://www.youtube.com/* |
|
254 | 254 | init_disable_play_on_hover(); |
255 | 255 | init_disable_end_cards(); |
256 | 256 | init_interruptions_remover(); |
| 257 | + init_miniplayer_button(); |
257 | 258 |
|
258 | 259 | const hoverToggleListener = (key, _oldValue, newValue) => { |
259 | 260 | if (key !== channel_id || !newValue) return; |
@@ -3028,7 +3029,7 @@ label{ |
3028 | 3029 | ].includes(page_type) && (win_config = home_watch_config); |
3029 | 3030 | ["yt_shorts"].includes(page_type) && (win_config = shorts_config); |
3030 | 3031 |
|
3031 | | - // YouTube Music - has its own config, doesn't use common_config |
| 3032 | + // YouTube Music config panel config |
3032 | 3033 | if (["yt_music_home", "yt_music_watch"].includes(page_type)) { |
3033 | 3034 | win_config = music_config; |
3034 | 3035 | } else { |
@@ -3350,8 +3351,104 @@ ytd-video-secondary-info-renderer .yt-chip-cloud-chip-renderer, |
3350 | 3351 | attributes: false, |
3351 | 3352 | characterData: false, |
3352 | 3353 | }); |
3353 | | - } catch (e) { |
| 3354 | + } catch (e) {} |
| 3355 | + } |
| 3356 | + |
| 3357 | + async function init_miniplayer_button() { |
| 3358 | + if ( |
| 3359 | + document.querySelector( |
| 3360 | + "#cpfyt-miniplayer-button, .ytp-chrome-bottom .ytp-miniplayer-button", |
| 3361 | + ) |
| 3362 | + ) |
| 3363 | + return; |
| 3364 | + |
| 3365 | + let $sizeButton = null; |
| 3366 | + const maxAttempts = 50; |
| 3367 | + let attempts = 0; |
| 3368 | + |
| 3369 | + while (!$sizeButton && attempts < maxAttempts) { |
| 3370 | + $sizeButton = document.querySelector( |
| 3371 | + ".ytp-chrome-bottom .ytp-size-button", |
| 3372 | + ); |
| 3373 | + if ($sizeButton) break; |
| 3374 | + await new Promise((r) => setTimeout(r, 100)); |
| 3375 | + attempts++; |
3354 | 3376 | } |
| 3377 | + |
| 3378 | + if (!$sizeButton) return; |
| 3379 | + |
| 3380 | + const supportsAnchorPositioning = |
| 3381 | + "anchorName" in document.documentElement.style; |
| 3382 | + const style = $sizeButton.parentElement.classList.contains( |
| 3383 | + "ytp-right-controls-right", |
| 3384 | + ) |
| 3385 | + ? "new" |
| 3386 | + : "old"; |
| 3387 | + |
| 3388 | + const buttonHTML = `<button id="cpfyt-miniplayer-button" class="ytp-button" aria-keyshortcuts="i" ${!supportsAnchorPositioning ? `title="Miniplayer (i)"` : ""}> |
| 3389 | + ${ |
| 3390 | + style == "new" |
| 3391 | + ? ` |
| 3392 | + <svg fill="none" height="24" viewBox="0 0 24 24" width="24"> |
| 3393 | + <path d="M21.20 3.01C21.66 3.05 22.08 3.26 22.41 3.58C22.73 3.91 22.94 4.33 22.98 4.79L23 5V19C23.00 19.49 22.81 19.97 22.48 20.34C22.15 20.70 21.69 20.93 21.20 20.99L21 21H3L2.79 20.99C2.30 20.93 1.84 20.70 1.51 20.34C1.18 19.97 .99 19.49 1 19V13H3V19H21V5H11V3H21L21.20 3.01ZM1.29 3.29C1.10 3.48 1.00 3.73 1.00 4C1.00 4.26 1.10 4.51 1.29 4.70L5.58 9H3C2.73 9 2.48 9.10 2.29 9.29C2.10 9.48 2 9.73 2 10C2 10.26 2.10 10.51 2.29 10.70C2.48 10.89 2.73 11 3 11H9V5C9 4.73 8.89 4.48 8.70 4.29C8.51 4.10 8.26 4 8 4C7.73 4 7.48 4.10 7.29 4.29C7.10 4.48 7 4.73 7 5V7.58L2.70 3.29C2.51 3.10 2.26 3.00 2 3.00C1.73 3.00 1.48 3.10 1.29 3.29ZM19.10 11.00L19 11H12L11.89 11.00C11.66 11.02 11.45 11.13 11.29 11.29C11.13 11.45 11.02 11.66 11.00 11.89L11 12V17C10.99 17.24 11.09 17.48 11.25 17.67C11.42 17.85 11.65 17.96 11.89 17.99L12 18H19L19.10 17.99C19.34 17.96 19.57 17.85 19.74 17.67C19.90 17.48 20.00 17.24 20 17V12L19.99 11.89C19.97 11.66 19.87 11.45 19.70 11.29C19.54 11.13 19.33 11.02 19.10 11.00ZM13 16V13H18V16H13Z" fill="white"></path> |
| 3394 | + </svg> |
| 3395 | + ` |
| 3396 | + : ` |
| 3397 | + <svg height="100%" version="1.1" viewBox="0 0 36 36" width="100%"> |
| 3398 | + <use xlink:href="#cpfyt-id-1" class="ytp-svg-shadow"></use> |
| 3399 | + <path id="cpfyt-id-1" d="M25,17 L17,17 L17,23 L25,23 L25,17 L25,17 Z M29,25 L29,10.98 C29,9.88 28.1,9 27,9 L9,9 C7.9,9 7,9.88 7,10.98 L7,25 C7,26.1 7.9,27 9,27 L27,27 C28.1,27 29,26.1 29,25 L29,25 Z M27,25.02 L9,25.02 L9,10.97 L27,10.97 L27,25.02 L27,25.02 Z" fill="#fff" fill-rule="evenodd"></path> |
| 3400 | + </svg> |
| 3401 | + ` |
| 3402 | + } |
| 3403 | + </button>${ |
| 3404 | + supportsAnchorPositioning |
| 3405 | + ? `<div class="ytp-tooltip ytp-bottom"> |
| 3406 | + <div class="ytp-tooltip-text-wrapper" aria-hidden="true"> |
| 3407 | + <div class="ytp-tooltip-bottom-text${style == "old" ? " ytp-tooltip-text-no-title" : ""}"> |
| 3408 | + <span class="ytp-tooltip-text">Miniplayer${style == "old" ? " (i)" : ""}</span> |
| 3409 | + ${style == "new" ? '<div class="ytp-tooltip-keyboard-shortcut">I</div>' : ""} |
| 3410 | + </div> |
| 3411 | + </div> |
| 3412 | + </div>` |
| 3413 | + : "" |
| 3414 | + }`; |
| 3415 | + |
| 3416 | + $sizeButton.insertAdjacentHTML("beforebegin", buttonHTML); |
| 3417 | + |
| 3418 | + const $button = document.querySelector("#cpfyt-miniplayer-button"); |
| 3419 | + |
| 3420 | + $button.style.display = "inline-block"; |
| 3421 | + |
| 3422 | + if (supportsAnchorPositioning) { |
| 3423 | + $button.style.anchorName = "--cpfyt-miniplayer-anchor"; |
| 3424 | + } |
| 3425 | + |
| 3426 | + if (!supportsAnchorPositioning) { |
| 3427 | + const $tooltip = $button.nextElementSibling; |
| 3428 | + if ($tooltip && $tooltip.classList.contains("ytp-tooltip")) { |
| 3429 | + $button.addEventListener("mouseenter", () => { |
| 3430 | + $tooltip.style.display = "block"; |
| 3431 | + }); |
| 3432 | + $button.addEventListener("mouseleave", () => { |
| 3433 | + $tooltip.style.display = "none"; |
| 3434 | + }); |
| 3435 | + } |
| 3436 | + } |
| 3437 | + |
| 3438 | + $button.addEventListener("click", (e) => { |
| 3439 | + e.preventDefault(); |
| 3440 | + e.stopPropagation(); |
| 3441 | + document.dispatchEvent( |
| 3442 | + new KeyboardEvent("keydown", { |
| 3443 | + bubbles: true, |
| 3444 | + cancelable: true, |
| 3445 | + code: "KeyI", |
| 3446 | + key: "i", |
| 3447 | + keyCode: 73, |
| 3448 | + which: 73, |
| 3449 | + }), |
| 3450 | + ); |
| 3451 | + }); |
3355 | 3452 | } |
3356 | 3453 |
|
3357 | 3454 | function display_update_win() { |
@@ -4651,6 +4748,7 @@ ytd-video-secondary-info-renderer .yt-chip-cloud-chip-renderer, |
4651 | 4748 | hide_end_cards: "off", |
4652 | 4749 | hide_fullscreen_controls: "off", |
4653 | 4750 | hide_ai_summary: "off", |
| 4751 | + hide_microphone_icon: "off", |
4654 | 4752 | disable_saturated_hover: "off", |
4655 | 4753 | login: false, |
4656 | 4754 | }; |
@@ -6081,6 +6179,64 @@ ytd-video-secondary-info-renderer .yt-chip-cloud-chip-renderer, |
6081 | 6179 | ); |
6082 | 6180 | } |
6083 | 6181 |
|
| 6182 | + if (user_data.hide_microphone_icon === "on") { |
| 6183 | + rules.push( |
| 6184 | + 'button[aria-label*="Search with your voice" i] { display: none !important; }', |
| 6185 | + ); |
| 6186 | + rules.push( |
| 6187 | + 'button[aria-label*="Voice search" i] { display: none !important; }', |
| 6188 | + ); |
| 6189 | + rules.push( |
| 6190 | + '.ytd-topbar-logo-button-renderer button[aria-label*="mic" i] { display: none !important; }', |
| 6191 | + ); |
| 6192 | + rules.push( |
| 6193 | + "ytm-topbar-search-input-renderer .search-microphone { display: none !important; }", |
| 6194 | + ); |
| 6195 | + } |
| 6196 | + |
| 6197 | + if (user_data.hide_microphone_icon === "on") { |
| 6198 | + rules.push( |
| 6199 | + 'button[aria-label*="Search with your voice" i] { display: none !important; }', |
| 6200 | + ); |
| 6201 | + rules.push( |
| 6202 | + 'button[aria-label*="Voice search" i] { display: none !important; }', |
| 6203 | + ); |
| 6204 | + rules.push( |
| 6205 | + '.ytd-topbar-logo-button-renderer button[aria-label*="mic" i] { display: none !important; }', |
| 6206 | + ); |
| 6207 | + rules.push( |
| 6208 | + "ytm-topbar-search-input-renderer .search-microphone { display: none !important; }", |
| 6209 | + ); |
| 6210 | + } |
| 6211 | + |
| 6212 | + rules.push(` |
| 6213 | + #cpfyt-miniplayer-button { |
| 6214 | + display: inline-block !important; |
| 6215 | + anchor-name: --cpfyt-miniplayer-anchor; |
| 6216 | + } |
| 6217 | + #cpfyt-miniplayer-button + .ytp-tooltip { |
| 6218 | + display: block !important; |
| 6219 | + position: fixed !important; |
| 6220 | + position-anchor: --cpfyt-miniplayer-anchor; |
| 6221 | + bottom: anchor(top); |
| 6222 | + left: anchor(center); |
| 6223 | + translate: -50% -14px; |
| 6224 | + opacity: 0; |
| 6225 | + pointer-events: none; |
| 6226 | + transition: opacity 0.2s ease; |
| 6227 | + } |
| 6228 | + .ytp-delhi-modern #cpfyt-miniplayer-button + .ytp-tooltip { |
| 6229 | + translate: -50% -22px; |
| 6230 | + } |
| 6231 | + #cpfyt-miniplayer-button:hover + .ytp-tooltip { |
| 6232 | + opacity: 1; |
| 6233 | + } |
| 6234 | + #cpfyt-miniplayer-button + .ytp-tooltip .ytp-tooltip-text { |
| 6235 | + font-size: 13px; |
| 6236 | + white-space: pre; |
| 6237 | + } |
| 6238 | + `); |
| 6239 | + |
6084 | 6240 | let css = rules.join("\n"); |
6085 | 6241 | let styleEl = unsafeWindow.document.getElementById("yt-hide-buttons-style"); |
6086 | 6242 | if (!styleEl) { |
@@ -6358,6 +6514,7 @@ ytd-video-secondary-info-renderer .yt-chip-cloud-chip-renderer, |
6358 | 6514 | row("hb_livechat_replay", "Live chat replay teaser"), |
6359 | 6515 | row("hb_fullscreen_controls", "Hide fullscreen controls"), |
6360 | 6516 | row("hb_ai_summary", "Hide AI summaries"), |
| 6517 | + row("hb_microphone", "Hide microphone icon"), |
6361 | 6518 | ]; |
6362 | 6519 |
|
6363 | 6520 | const rows = [...actionRows, ...otherRows]; |
@@ -6433,6 +6590,7 @@ ytd-video-secondary-info-renderer .yt-chip-cloud-chip-renderer, |
6433 | 6590 | ["hb_endcards", "hide_end_cards"], |
6434 | 6591 | ["hb_fullscreen_controls", "hide_fullscreen_controls"], |
6435 | 6592 | ["hb_ai_summary", "hide_ai_summary"], |
| 6593 | + ["hb_microphone", "hide_microphone_icon"], |
6436 | 6594 | ]; |
6437 | 6595 |
|
6438 | 6596 | const checkboxById = {}; |
|
0 commit comments