53 lines
4.4 KiB
Markdown
53 lines
4.4 KiB
Markdown
# YouTube Music Auto-Confirm & Anti-Pause
|
|
|
|
A lightweight, highly effective Tampermonkey userscript that ensures uninterrupted listening on YouTube Music. It automatically dismisses "Are you still there?" prompts, auto-accepts viewer discretion warnings, and spoofs user activity to prevent playback from pausing in the background.
|
|
|
|
## ✨ Features
|
|
|
|
* **Anti-Pause Activity Spoofing**: Silently spoofs user activity (simulating keypresses and updating internal trackers) every minute to prevent YouTube's inactivity timer from triggering.
|
|
* **Auto-Dismiss "Are you still there?"**: If the inactivity popup does manage to appear, the script instantly detects it, clicks "Yes", and resumes playback.
|
|
* **Auto-Accept Discretion Warnings**: Automatically clicks "I understand and wish to proceed" on content warnings (e.g., suicide/self-harm topics) and resumes the video/song.
|
|
* **Native UI Integration**: Injects a sleek, non-intrusive status badge into the top-right YouTube Music navigation bar. It features a pulsing green dot and tracks how many times activity has been spoofed.
|
|
* **Smart Loop Prevention**: Includes a 3-second action cooldown and promise-based error handling to prevent infinite play/pause loops caused by strict browser autoplay policies.
|
|
|
|
## 🚀 Installation
|
|
|
|
1. **Install a Userscript Manager**:
|
|
* [Tampermonkey](https://www.tampermonkey.net/) (Recommended)
|
|
* [Violentmonkey](https://violentmonkey.github.io/)
|
|
* [Greasemonkey](https://www.greasespot.net/)
|
|
2. **Install the Script**:
|
|
* **Option A (Direct Install)**: Click on the `YouTube_Music_Auto_Confirm_-Are_You_Still_There-_&_Discretion_Warning-1.9.user.js` file in this repository, click the **Raw** button, and your userscript manager should prompt you to install it.
|
|
* **Option B (Manual)**: Open your userscript manager dashboard, click "Create a new script", copy the entire contents of the `.user.js` file from this repository, paste it into the editor, and save (Ctrl+S / Cmd+S).
|
|
3. **Refresh YouTube Music**: Reload any open `music.youtube.com` tabs for the script to take effect.
|
|
|
|
## 💡 Recommended Setup
|
|
|
|
For the best, truly uninterrupted listening experience, it is highly recommended to run this script in **Mozilla Firefox** with the **uBlock Origin** extension installed.
|
|
|
|
While this script perfectly handles YouTube's native inactivity and discretion prompts, uBlock Origin will effectively block audio and video ads. Together, they provide a seamless, ad-free, and pause-free music experience.
|
|
|
|
## 💻 Usage
|
|
|
|
Once installed, the script runs completely in the background. You don't need to configure anything.
|
|
|
|
To verify it is working:
|
|
1. Open [YouTube Music](https://music.youtube.com).
|
|
2. Look at the top right corner of the navigation bar (next to your profile picture/cast icon).
|
|
3. You should see a subtle **Anti-Pause: 0** badge with a pulsing dot. The number will increase every minute as the script spoofs activity to keep your session alive.
|
|
|
|
## 🛠️ How It Works (Technical Details)
|
|
|
|
* **Activity Spoofing**: YouTube tracks inactivity via the `window._lact` variable. The script updates this timestamp to `Date.now()` and dispatches a harmless `Shift` keyup event every 60 seconds.
|
|
* **DOM Monitoring**: The script polls the DOM every 2 seconds (and listens for HTML5 `<video>` `pause` events) to check for the presence of `ytmusic-you-there-renderer` or `#player-error-message-container`.
|
|
* **Visibility Checks**: It uses `.offsetParent !== null` to ensure it only interacts with popups that are actually visible on the screen, avoiding false positives from hidden DOM elements.
|
|
* **Autoplay Handling**: Browsers often block scripts from calling `video.play()` if the user hasn't interacted with the page recently. The script catches `DOMException` autoplay rejections gracefully to prevent console spam and infinite loops.
|
|
|
|
## ⚠️ Troubleshooting
|
|
|
|
* **The video stays paused after a warning**: If you open a link in a new background tab and a discretion warning appears, the script will click "Proceed", but your browser's Autoplay Policy might block the video from resuming until you physically click anywhere on the page. This is a browser security feature, not a bug in the script.
|
|
* **Badge isn't showing**: The script waits for the YouTube Music navigation bar to load. If you have a slow connection, it might take a few extra seconds for the "Anti-Pause" badge to appear.
|
|
|
|
## 📄 License
|
|
|
|
This project is open-source and available under the MIT License. Feel free to fork, modify, and improve it! |