YouTube Shorts Blocker Ultra + Blocking Youtube Shorts GUI On Homepage And Videos

Blocks YouTube Shorts

目前为 2024-12-30 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name YouTube Shorts Blocker Ultra + Blocking Youtube Shorts GUI On Homepage And Videos
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.1
  5. // @description Blocks YouTube Shorts
  6. // @author You
  7. // @match https://www.youtube.com/*
  8. // @grant none
  9. // @license All Rights Reserved.
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. let lastValidUrl = window.location.href;
  16. let isRedirecting = false;
  17.  
  18.  
  19. setInterval(function() {
  20. const currentUrl = window.location.href;
  21.  
  22.  
  23. if (!currentUrl.includes('/shorts/')) {
  24. lastValidUrl = currentUrl;
  25. } else if (!isRedirecting) {
  26.  
  27. isRedirecting = true;
  28.  
  29.  
  30. let userResponse = confirm("This video is a YouTube Shorts. To view it as a regular video, click OK. If you click Cancel, you will be redirected to the previous URL.");
  31.  
  32.  
  33. if (userResponse) {
  34. window.location.href = currentUrl.replace('/shorts/', '/watch?v=');
  35. } else {
  36.  
  37. if (lastValidUrl.includes('youtube.com/shorts')) {
  38. window.location.href = 'https://www.youtube.com';
  39. } else {
  40. window.location.href = lastValidUrl;
  41. }
  42. }
  43.  
  44.  
  45. setTimeout(function() {
  46. isRedirecting = false;
  47. }, 5000);
  48. }
  49. }, 1);
  50. })();
  51.  
  52. (function () {
  53. 'use strict';
  54.  
  55. setInterval(function () {
  56. const elementsToRemove = document.querySelectorAll(
  57. '.yt-core-image.shortsLockupViewModelHostThumbnail.yt-core-image--fill-parent-height.yt-core-image--fill-parent-width.yt-core-image--content-mode-scale-aspect-fill.yt-core-image--loaded,' +
  58. '.shortsLockupViewModelHostThumbnailContainer.shortsLockupViewModelHostThumbnailContainerRounded.shortsLockupViewModelHostThumbnailContainerCustomDimensions,' +
  59. '.shortsLockupViewModelHostThumbnailContainer.shortsLockupViewModelHostThumbnailContainerAspectRatioTwoByThree.shortsLockupViewModelHostThumbnailContainerRounded.shortsLockupViewModelHostThumbnailContainerCustomDimensions,' +
  60. '.shortsLockupViewModelHostOutsideMetadata.shortLockupViewModelHostMetadataRounded.image-overlay-text,' +
  61. 'ytd-rich-section-renderer.style-scope.ytd-rich-grid-renderer,' +
  62. 'a.shortsLockupViewModelHostEndpoint.shortsLockupViewModelHostOutsideMetadataEndpoint,' +
  63. 'ytm-shorts-lockup-view-model-v2.shortsLockupViewModelHost.yt-horizontal-list-renderer,' +
  64. 'ytm-shorts-lockup-view-model.shortsLockupViewModelHost.yt-horizontal-list-renderer,' +
  65. '#title-container.style-scope.ytd-reel-shelf-renderer'
  66. );
  67.  
  68. elementsToRemove.forEach(function (element) {
  69. element.remove();
  70. });
  71. }, 1);
  72. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址