影片音量增強器

增强影片音量上限,最高增幅至 20 倍。有些不支援的网站,影片会没声音,禁用增幅即可。命令选单有时有 BUG 会多创建一个,但不影响原功能使用。

当前为 2024-02-19 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         影片音量增強器
// @version      0.0.32
// @author       HentaiSaru
// @description  增強影片音量上限,最高增幅至 20 倍,有些不支援的網站,影片會沒聲音 或是 沒有效果,命令選單有時有 BUG 會多創建一個,但不影響原功能使用。
// @description:zh-TW 增強影片音量上限,最高增幅至 20 倍,有些不支援的網站,影片會沒聲音禁用增幅即可,命令選單有時有 BUG 會多創建一個,但不影響原功能使用。
// @description:zh-CN 增强影片音量上限,最高增幅至 20 倍。有些不支援的网站,影片会没声音,禁用增幅即可。命令选单有时有 BUG 会多创建一个,但不影响原功能使用。
// @description:en Enhance the upper limit of video volume, boosting up to 20 times. For unsupported websites where videos have no sound, disabling the boost is sufficient. Occasionally, there may be a bug in the command menu causing duplication, but it does not affect the original functionality.

// @match        *://*/*
// @icon         https://cdn-icons-png.flaticon.com/512/8298/8298181.png

// @license      MIT
// @namespace    https://greasyfork.org/users/989635

// @run-at       document-start
// @grant        unsafeWindow
// @grant        GM_setValue
// @grant        GM_getValue
// @grant        GM_addStyle
// @grant        GM_registerMenuCommand
// @require      https://update.greasyfork.org/scripts/487608/1330066/GrammarSimplified.js
// ==/UserScript==
(function(){if(/^(http|https):\/\/(?!chrome\/|about\/).*$/i.test(document.URL)){class l extends API{constructor(){super();this.Increase=this.Booster=null;this.StyleTag=!1;this.Domain=location.hostname;this.Display=this.Language(navigator.language);this.BannedDomains=this.store("get","BannedDomains",[]);this.ExcludeStatus=this.BannedDomains.includes(this.Domain);this.BannedDomain=async a=>{this.ExcludeStatus?this.BannedDomains=this.BannedDomains.filter(b=>b!=a):this.BannedDomains.push(a);this.store("set","BannedDomains",this.BannedDomains);location.reload()};this.StatusMenu=async a=>{this.Menu({[a]:()=>this.BannedDomain(this.Domain)})};this.MenuHotkey=async a=>{this.Listen(document,"keydown",b=>{b.altKey&&"B"==b.key.toUpperCase()&&this.IncrementalSetting()},{passive:!0,capture:!0},b=>{const d=`${(performance.now()-a).toFixed(2)}ms`;b?this.log("Hotkey Success",d):this.log("Hotkey Failed",d)})};this.Verify=()=>{const a=this.$$("video");return a&&a.hasAttribute("Media-Audio-Booster")?!0:!1}}static async Injection(){let a,b=new l;b.ExcludeStatus?b.StatusMenu(b.Display.MS):((new MutationObserver(()=>{(a=b.$$("video"))&&!a.hasAttribute("Media-Audio-Booster")&&b.Trigger(a,performance.now())})).observe(document.head,{childList:!0,subtree:!0}),b.StatusMenu(b.Display.MD))}async Trigger(a,b){try{this.Increase=this.store("get",this.Domain)||1,this.Booster=this.BoosterLogic(a,this.Increase,b),this.StyleTag||(this.StyleTag=!0,this.AddStyle(".Booster-Modal-Background {top: 0;left: 0;width: 100%;height: 100%;display: flex;z-index: 9999;overflow: auto;position: fixed;align-items: center;justify-content: center;}.Booster-Modal-Button {top: 0;margin: 3% 2%;color: #d877ff;font-size: 16px;font-weight: bold;padding: 0 0.3rem;border-radius: 3px;background-color: #ffebfa;border: 1px solid rgb(124, 183, 252);}.Booster-Modal-Button:hover,.Booster-Modal-Button:focus {color: #fc0e85;cursor: pointer;text-decoration: none;}.Booster-Modal-Content {width: 400px;padding: 5px;overflow: auto;background-color: #cff4ff;border-radius: 10px;text-align: center;border: 2px ridge #82c4e2;border-collapse: collapse;margin: 2% auto 8px auto;}.Booster-Multiplier {font-size:25px;color:rgb(253, 1, 85);margin: 10px;font-weight:bold;}.Booster-Slider {width: 350px;}div input {cursor: pointer;}"))}catch(d){this.log("Trigger Error : ",d,"error")}}BoosterLogic(a,b,d){const c=window.AudioContext||window.oAudioContext;try{if(!c)throw this.Display.BT1;const e=new c,n=e.createMediaElementSource(a),g=e.createGain(),h=e.createBiquadFilter(),k=e.createBiquadFilter(),f=e.createDynamicsCompressor();a.volume=1;g.gain.value=b**2;f.ratio.value=6;f.knee.value=.5;f.threshold.value=-14;f.attack.value=.02;f.release.value=.4;h.frequency.value=250;h.type="lowshelf";h.gain.value=2.2;k.frequency.value=1E4;k.type="highshelf";k.gain.value=1.8;n.connect(g).connect(h).connect(k);g.connect(f).connect(e.destination);a.setAttribute("Media-Audio-Booster",!0);if(!this.Verify())throw this.Display.BT2;this.Menu({[this.Display.MK]:()=>alert(this.Display.MKT),[this.Display.MM]:()=>this.IncrementalSetting()});this.MenuHotkey(d);this.log(this.Display.BT3,{"Booster Media : ":a,"Elapsed Time : ":`${(performance.now()-d).toFixed(2)}ms`});return{setVolume:m=>{g.gain.value=m**2;this.Increase=m}}}catch(e){this.log(this.Display.BT4,e)}}async IncrementalSetting(){if(!this.$$(".Booster-Modal-Background")){const a=document.createElement("div");a.innerHTML=`<div class="Booster-Modal-Background"><div class="Booster-Modal-Content"><h2 style="color: #3754f8;">${this.Display.ST}</h2><div style="margin:1rem auto 1rem auto;"><div class="Booster-Multiplier"><span><img src="https://cdn-icons-png.flaticon.com/512/8298/8298181.png" width="5%">${this.Display.S1}</span><span id="CurrentValue">${this.Increase}</span><span>${this.Display.S2}</span></div><input type="range" id="sound-amplification" class="Booster-Slider" min="0" max="20.0" value="${this.Increase}" step="0.1"><br></div><div style="text-align: right;"><button class="Booster-Modal-Button" id="sound-save">${this.Display.SS}</button><button class="Booster-Modal-Button" id="sound-close">${this.Display.SC}</button></div></div></div>`;document.body.appendChild(a);const b=this.$$("#CurrentValue"),d=this.$$("#sound-amplification");this.AddListener(d,"input",c=>{c=c.target.value;b.textContent=c;this.Booster.setVolume(c)},{passive:!0,capture:!0});this.AddListener(this.$$(".Booster-Modal-Background"),"click",c=>{c.stopPropagation();c=c.target;"sound-save"===c.id?(this.Increase=c=parseFloat(d.value),this.store("set",this.Domain,c),this.$$(".Booster-Modal-Background").remove()):"Booster-Modal-Background"!==c.className&&"sound-close"!==c.id||this.$$(".Booster-Modal-Background").remove()},{capture:!0})}}Language(a){const b={"zh-TW":[{MS:"\u2705 \u555f\u7528\u589e\u5e45",MD:"\u274c \u7981\u7528\u589e\u5e45",MK:"\ud83d\udcdc \u83dc\u55ae\u71b1\u9375",MM:"\ud83d\udee0\ufe0f \u8abf\u6574\u83dc\u55ae",MKT:"\u71b1\u9375\u547c\u53eb\u8abf\u6574\u83dc\u55ae!!\n\n\u5feb\u6377\u7d44\u5408 : (Alt + B)",BT1:"\u4e0d\u652f\u63f4\u97f3\u983b\u589e\u5f37\u7bc0\u9ede",BT2:"\u6dfb\u52a0\u589e\u5f37\u7bc0\u9ede\u5931\u6557",BT3:"\u6dfb\u52a0\u589e\u5f37\u7bc0\u9ede\u6210\u529f",BT4:"\u589e\u5f37\u5931\u6557",ST:"\u97f3\u91cf\u589e\u5f37",S1:"\u589e\u5f37\u500d\u6578 ",S2:" \u500d",SS:"\u4fdd\u5b58\u8a2d\u7f6e",SC:"\u9000\u51fa\u9078\u55ae"}],"zh-CN":[{MS:"\u2705 \u542f\u7528\u589e\u5e45",MD:"\u274c \u7981\u7528\u589e\u5e45",MK:"\ud83d\udcdc \u83dc\u5355\u70ed\u952e",MM:"\ud83d\udee0\ufe0f \u8c03\u6574\u83dc\u5355",MKT:"\u70ed\u952e\u547c\u53eb\u8c03\u6574\u83dc\u5355!!\n\n\u5feb\u6377\u7ec4\u5408 : (Alt + B)",BT1:"\u4e0d\u652f\u63f4\u97f3\u9891\u589e\u5f3a\u8282\u70b9",BT2:"\u6dfb\u52a0\u589e\u5f3a\u8282\u70b9\u5931\u8d25",BT3:"\u6dfb\u52a0\u589e\u5f3a\u8282\u70b9\u6210\u529f",BT4:"\u589e\u5f3a\u5931\u8d25",ST:"\u97f3\u91cf\u589e\u5f3a",S1:"\u589e\u5f3a\u500d\u6570 ",S2:" \u500d",SS:"\u4fdd\u5b58\u8bbe\u7f6e",SC:"\u9000\u51fa\u83dc\u5355"}],"en-US":[{MS:"\u2705 Enable Boost",MD:"\u274c Disable Boost",MK:"\ud83d\udcdc Menu Hotkey",MM:"\ud83d\udee0\ufe0f Adjust Menu",MKT:"Hotkey to Call Menu Adjustments!!\n\nShortcut: (Alt + B)",BT1:"Audio enhancement node not supported",BT2:"Failed to add enhancement node",BT3:"Enhancement node added successfully",BT4:"Enhancement failed",ST:"Volume Boost",S1:"Boost Level ",S2:" X",SS:"Save Settings",SC:"Exit Menu"}]};return b.hasOwnProperty(a)?b[a][0]:b["en-US"][0]}}l.Injection()}})();