🎉 欢迎访问GreasyFork.Org 镜像站!本镜像站由公众号【爱吃馍】搭建,用于分享脚本。联系邮箱📮

Greasy fork 爱吃馍镜像

自研 - 豆瓣 - 调整预告片音量

当预告片播放时自动调整音量。

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

// ==UserScript==
// @name               自研 - 豆瓣 - 调整预告片音量
// @name:en_US         Self-made - douban - Modify trailer volume
// @description        当预告片播放时自动调整音量。
// @description:en_US  When trailers play, automatically adjust the volume.
// @version            2.0.1
// @author             CPlayerCHN
// @license            MulanPSL-2.0
// @namespace          https://www.gitlink.org.cn/CPlayerCHN
// @match              https://movie.douban.com/trailer/*
// @icon               https://douban.com/favicon.ico
// @grant              GM_setValue
// @grant              GM_getValue
// @grant              GM_registerMenuCommand
// @run-at             document-end
// @noframes
// ==/UserScript==

(function() {
    'use strict';

    // 定义「视频元素」变量和「保存音量值」函数。
    const video = document.querySelector('.video-js video');

    function saveVolume() {

        // 定义「音量值」变量。
        let volume = ""

        // 判断数值是否合规,如果合规就继续往下执行。
        do {

            volume = window.prompt("请输入您期望的音量。", GM_getValue("volume", 10));

        } while (typeof volume !== 'number' && !(volume > 0 && volume <= 100));

        // 写入「音量值」变量至数据。
        GM_setValue("volume", volume);

    }


    // 判断「音量值」数据是否被定义,如果没有就定义。
    if(!GM_getValue("volume")) {

        saveVolume();

    }


    // 修改视频音量
    video.volume = GM_getValue("volume") * 0.01;


    // 增加「修改音量」菜单命令。
    GM_registerMenuCommand("修改音量", () => {

        // 读取新「音量值」后修改视频音量。
        saveVolume();
        video.volume = GM_getValue("volume") * 0.01;

    })

})();