Skip to content

Instantly share code, notes, and snippets.

@huaminghuangtw
Last active November 30, 2024 07:05
Show Gist options
  • Save huaminghuangtw/be2eaee73f155187ca1ed0570b7268a0 to your computer and use it in GitHub Desktop.
Save huaminghuangtw/be2eaee73f155187ca1ed0570b7268a0 to your computer and use it in GitHub Desktop.
How to watch YouTube videos without any ads?

Ever feel annoyed by YouTube’s ads? This simple method allows you to enjoy YouTube videos without additional clutter. The secret? Watching videos in “Embed Mode,” giving you a cleaner experience without distractions! Most videos work seamlessly with this trick—even if you don’t have an ad blocker installed!


Manual Approach

  1. Click the Share button below the YouTube video.
  2. From the sharing options, click Embed.
    • This will open the video in embed mode.

Automated Approach

  1. Create a Bookmark

    • Open your browser's bookmarks bar.
    • Right-click on the bookmarks bar and select Add This Page to Favorites.
  2. Add the JavaScript Code

    • In the Name field, enter a descriptive name like YouTube Embed Mode.

    • In the URL field, paste the following JavaScript code:

      javascript:(function(){if(location.href.includes("youtube.com/watch?v=")){let id=location.href.split("v=")[1].split("&")[0];window.open(`https://www.youtube.com/embed/${id}`,"_blank");}})();
      • This will replace watch?v= with embed/ 1 in the address bar, and let YouTube load the video in full-screen embed mode in a new tab.
  3. Save the Bookmark

    • Save the bookmark. It should now appear on your bookmarks bar.
  4. Use the Bookmarklet

    • Navigate to a YouTube video page (e.g., https://www.youtube.com/watch?v=exampleID).
    • Click on the YouTube Embed bookmark you've just created.
    • The script will extract the video ID and open the corresponding embeddable URL (e.g., https://www.youtube.com/embed/exampleID) in a new tab.

Footnotes

  1. For example: https://www.youtube.com/watch?v=NcQQVbioeZkhttps://www.youtube.com/embed/NcQQVbioeZk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment