Skip to content

Instantly share code, notes, and snippets.

@huaminghuangtw
Last active July 17, 2025 07:17
Show Gist options
  • Select an option

  • Save huaminghuangtw/be2eaee73f155187ca1ed0570b7268a0 to your computer and use it in GitHub Desktop.

Select an option

Save huaminghuangtw/be2eaee73f155187ca1ed0570b7268a0 to your computer and use it in GitHub Desktop.
How to watch YouTube videos without any ads?

One of the annoying distractions while watching YouTube videos is the constant interruption by advertisements—it breaks the flow and ruins the viewing experience. A simple trick I found is to watch videos in "Embed Mode". Most videos play seamlessly this way—even if you don’t have an ad blocker installed. It works on mobile too!


  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