YouTube Redirect

Working 2023 adblock for YouTube video. Redirects all "youtube.com" links to yout-ube.com.

安裝腳本?
作者推薦腳本

您可能也會喜歡 YouTube DeBlock

安裝腳本
  1. // ==UserScript==
  2. // @name YouTube Redirect
  3. // @description Working 2023 adblock for YouTube video. Redirects all "youtube.com" links to yout-ube.com.
  4. // @author YelloNox
  5. // @version 0.2
  6. // @date 2023-10-10
  7. // @namespace https://yello.zip
  8. // @homepage https://github.com/YelloNox/YouTube-Adblock
  9. // @match *://www.youtube.com/*
  10. // @match *://www.yout-ube.com/*
  11. // @match *://www.youtube-nocookie.com/*
  12. // @grant none
  13. // ==/UserScript==
  14.  
  15. (function () {
  16. 'use strict';
  17. // Redirect clicked links to new tab and from "youtube.com" to "yout-ube.com"
  18. document.addEventListener('click', function (event) {
  19. let target = event.target;
  20. while (target && target.nodeName !== 'A') {
  21. target = target.parentElement;
  22. }
  23.  
  24. if (target && target.href) {
  25. const youtubeVideoRegex = /https:\/\/www\.youtube\.com\/watch\?v=[^&]+/;
  26. if (youtubeVideoRegex.test(target.href)) {
  27. event.preventDefault();
  28. event.stopPropagation();
  29.  
  30. const modifiedUrl = target.href.replace('youtube.com', 'yout-ube.com');
  31. window.open(modifiedUrl, '_blank');
  32. }
  33. }
  34. }, true);
  35.  
  36. // Check for text "This video is unavailable" and reload page if found
  37. function checkForText() {
  38. const textToFind = "This video is unavailable";
  39. const pageText = document.body.textContent;
  40.  
  41. if (pageText.includes(textToFind)) {
  42. location.reload();
  43. }
  44. }
  45.  
  46. window.addEventListener('load', checkForText);
  47. })();