mytube

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

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

作者
player27
今日安裝
0
安裝總數
29
評價
0 1 0
版本
2024-04-13
建立日期
2024-04-13
更新日期
2024-04-13
尺寸
1.6 KB
授權條款
未知
腳本執行於

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.