Prevent YouTube Ads

Redirect YouTube URLs to .com. to prevent ads

  1. // ==UserScript==
  2. // @name Prevent YouTube Ads
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description Redirect YouTube URLs to .com. to prevent ads
  6. // @author Sirfredrick
  7. // @match https://www.youtube.com/
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13. const url = window.location.href;
  14.  
  15. if (!url.includes(".com.")) {
  16. const first = url.split(".com")[0];
  17. const second = url.split(".com")[1];
  18. const newUrl = first + ".com." + second;
  19. console.log(url);
  20. console.log(newUrl);
  21. window.location.replace(newUrl);
  22. }
  23. })();