Play with MPV (Enhanced)

Combines a floating button, thumbnail clicks, and a Shift+Click fallback context menu to play videos in MPV.

当前为 2025-07-09 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

作者
gabreek
评分
0 0 0
版本
2025.07.09.5
创建于
2025-07-09
更新于
2025-07-09
大小
16.0 KB
许可证
MIT
适用于
所有网站

Play with MPV (Enhanced)

This is a powerful UserScript that integrates website videos with the MPV media player. It combines the best features of two original scripts and adds new functionalities for a seamless experience, allowing you to play web videos in your native player with customized settings.

Prerequisites & Installation

For this UserScript to work, you need three key components installed on your system.

Note: This userscript is not compatible with Greasemonkey v4.0+. Please use a manager like Violentmonkey or Tampermonkey.

1. Dependencies

mpv-handler mpv yt-dlp

For Windows Users: It is highly recommended to use shinchiro's mpv builds. These builds conveniently include both mpv and yt-dlp. After installing, remember to run updater.bat to get the latest versions.

2. UserScript

Install the "Play with MPV (Enhanced)" UserScript in Violentmonkey or Tampermonkey.


Core Features

  • Floating "Play" Button: A convenient button appears on supported video pages to instantly open the current video in MPV.
  • Direct Thumbnail Clicking: Click directly on video thumbnails on supported sites (like YouTube) to open them in MPV, bypassing the site's player.
  • Universal Context Menu: On any website not explicitly supported, you can Shift + Right-Click any link to open it with MPV.
  • Centralized Settings Panel: A single, easy-to-use panel to configure your MPV preferences (quality, profile, codec, etc.) for all playback methods.

Origin & Evolution

This script is a synergistic merger of two excellent original scripts, enhancing their features and creating a unified, more powerful tool.

Original Scripts

  1. "Play with MPV" by Akatsuki Rui

    • Functionality: Provided a floating "Play" button on video pages and a robust settings panel (GM_config) to customize MPV launch options. This formed the foundation for our script's configuration and on-page button.
  2. "Click on video thumbnail to play in MPV" by nSinister

    • Functionality: Introduced the intuitive feature of clicking directly on video thumbnails to launch them in MPV. It had hardcoded settings.

What's New in This "Enhanced" Version?

This version isn't just a simple combination; it's a complete refactor that improves upon the originals:

  • Unified Functionality: The thumbnail-clicking feature now respects the settings you choose in the configuration panel.
  • Persistent Settings Button: The settings icon is now accessible on all pages of the supported sites.
  • Universal Fallback Context Menu: Use Shift + Right-Click on a link on any site to get a "Play with MPV" option.
  • Smarter Page Detection: Uses MutationObserver to reliably detect new content.

How to Use

Basic Usage

1. The Floating Button

  • On a page with a video (e.g., a YouTube watch page), the MPV play icon will appear in the bottom-left corner.
  • Clicking it will immediately open the current page's video in MPV.

2. Clicking Thumbnails

  • On supported sites like YouTube, Vimeo, etc., simply click on any video thumbnail.
  • Instead of navigating to the video page, the script will intercept the click and open the video directly in MPV.

3. The Fallback Context Menu

  • This works on any site not listed in the main configuration (e.g., news sites, educational platforms, etc.).
  • Find a link to a video.
  • Hold down the Shift key and right-click the link.
  • A custom context menu will appear with the option "Play with MPV". Click it.
  • A normal right-click (without Shift) will show the browser's default context menu.

Advanced Configuration

You can access the settings panel to customize the script's behavior.

  • Access: On any of the supported sites (YouTube, Twitch, etc.), hover your mouse over the bottom-left corner of the screen. A settings gear icon will appear. Click it.

Here are the available options:

  • Try to Pass Cookies:

    • For advanced users to view member-only videos. Since userscripts cannot access HttpOnly cookies, you must export them manually using an extension like Get cookies.txt LOCALLY (Chromium) or cookies.txt (Firefox).
    • The exported cookies file must be named after the domain (e.g., www.youtube.com.txt) and placed in the correct directory:
      • Linux: $HOME/.config/mpv-handler/cookies/
      • Windows: (mpv-hander.exe parent folder)\cookies\
  • MPV Profile:

  • Video Quality:

  • Video Codec:

  • Run With Console:

    • yes: Runs mpv-handler with a console window to view output and errors.
    • no: Runs mpv-handler silently in the background.

GitHub & Credits

This project stands on the shoulders of giants.