mytube

Skip youtube video ads duration < 180 seconds and banners. Tested on FIrefox

Author
player27
Daily installs
0
Total installs
20
Ratings
0 1 0
Version
2024-04-13
Created
2024-04-13
Updated
2024-04-13
License
N/A
Applies to

This JavaScript function is designed to enhance the user experience when watching YouTube videos by automatically skipping short videos and hiding various types of advertisements. Here's a breakdown of its functionality:

1. **Skipping Short Videos:**
- It targets the video player element on the webpage by selecting the element with the class ".video-stream".
- If the video player exists (`videoPlayer` is truthy) and the duration of the video is less than 180 seconds (3 minutes), the script performs the following actions:
- Pauses the video (`videoPlayer.pause()`).
- Sets the current playback time to slightly before the end of the video (`videoPlayer.currentTime = videoPlayer.duration - 0.001`), ensuring that the video is considered completed.
- Plays the video (`videoPlayer.play()`).
- Emulates a click on the video player (`videoPlayer.click()`), possibly to activate certain functionalities.
- It also attempts to skip any ads by clicking on elements with classes containing "ad-skip".

2. **Hiding Advertisements:**
- It defines an array `adWords` containing keywords commonly associated with advertisements.
- It selects all elements with classes containing "ytd" (likely YouTube elements) and iterates over them.
- For each element, it checks if its class contains any of the ad-related keywords (`adWords`). If it does and the element is currently displayed (`element.style.display !== 'none'`), it hides the element by setting its display style to "none".

3. **Interval Execution:**
- The function `mytube` is set to run repeatedly at intervals of 250 milliseconds (`setInterval(mytube, 250)`). This ensures that the function continuously monitors the page for changes and applies its modifications as needed.

Overall, this script aims to automate the process of skipping short videos and hiding advertisements on YouTube, providing a smoother and more enjoyable viewing experience for users.