媒體音量增強器

增強媒體音量最高至 20 倍,可記住增強設置後自動應用,部分網站可能無效或無聲,可選擇禁用。

目前為 2025-04-06 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         媒體音量增強器
// @name:zh-TW   媒體音量增強器
// @name:zh-CN   媒体音量增强器
// @name:en      Media Volume Booster
// @version      0.0.38
// @author       Canaan HS
// @description         增強媒體音量最高至 20 倍,可記住增強設置後自動應用,部分網站可能無效或無聲,可選擇禁用。
// @description:zh-TW   增強媒體音量最高至 20 倍,可記住增強設置後自動應用,部分網站可能無效或無聲,可選擇禁用。
// @description:zh-CN   增强媒体音量最高至 20 倍,可记住增强设置后自动应用,部分网站可能无效或无声,可选择禁用。
// @description:en      Boost media volume up to 20 times, automatically apply saved settings, may not work or have no sound on some sites, can disable if needed.

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

// @license      MPL-2.0
// @namespace    https://greasyfork.org/users/989635

// @run-at       document-start
// @grant        GM_setValue
// @grant        GM_getValue
// @grant        GM_getResourceURL
// @grant        GM_registerMenuCommand
// @grant        GM_addValueChangeListener
// @resource     Img https://cdn-icons-png.flaticon.com/512/8298/8298181.png
// @require      https://update.greasyfork.org/scripts/487608/1558817/ClassSyntax_min.js
// ==/UserScript==
(async()=>{(new class extends Syntax{constructor(){super();this.Increase=this.Booster=null;this.EnhanceNodes=[];this.MediaContent=null;this.EnhancedElement=new Map;this.AudioContext=window.AudioContext||window.webkitAudioContext;this.ExcludeStatus=this.Init=this.ObserverOption=this.MediaObserver=null;this.Host=this.Device.Host;this.Lang=this.Language(this.Device.Lang);this.BannedHost=this.Store("g","BannedDomains_v2",{});this.GetBannedHost=d=>{this.ExcludeStatus=this.BannedHost[this.Host]??!1;d(!this.ExcludeStatus)};this.Banned=async()=>{this.ExcludeStatus?delete this.BannedHost[this.Host]:this.BannedHost[this.Host]=!0;this.Store("s","BannedDomains_v2",this.BannedHost);location.reload()};this.MenuHotkey=async()=>{this.AddListener(document,"keydown",d=>{d.altKey&&"B"==d.key.toUpperCase()&&this.BoosterMenu()},{passive:!0,capture:!0})}}BoosterFactory(d,b){try{if(!this.AudioContext)throw this.Lang.Transl("\u4e0d\u652f\u63f4\u97f3\u983b\u589e\u5f37\u7bc0\u9ede");this.MediaContent||(this.MediaContent=new this.AudioContext);"suspended"===this.MediaContent.state&&this.MediaContent.resume();const c=this.EnhanceNodes.length;for(const a of d){const f=this.MediaContent.createMediaElementSource(a),g=this.MediaContent.createGain(),h=this.MediaContent.createBiquadFilter(),e=this.MediaContent.createBiquadFilter(),l=this.MediaContent.createBiquadFilter(),k=this.MediaContent.createDynamicsCompressor(),m=setInterval(()=>{a.volume=1},1E3);setTimeout(()=>{clearInterval(m)},3E3);g.gain.value=this.Increase**2;h.type="lowshelf";h.gain.value=2.2;h.frequency.value=200;e.type="peaking";e.Q.value=1;e.gain.value=3;e.frequency.value=1200;l.type="highshelf";l.gain.value=1.8;l.frequency.value=12E3;k.ratio.value=5.4;k.knee.value=.4;k.threshold.value=-12;k.attack.value=.02;k.release.value=.4;f.connect(g).connect(h).connect(e).connect(l).connect(k).connect(this.MediaContent.destination);this.EnhanceNodes.push(g);this.EnhancedElement.set(a,!0)}this.EnhanceNodes.length>c&&(this.Log(this.Lang.Transl("\u6dfb\u52a0\u589e\u5f37\u7bc0\u9ede\u6210\u529f"),{"Booster Media : ":d,"Elapsed Time : ":this.Runtime(b,{log:!1})},{collapsed:!1}),this.Init||(this.Init=!0,this.Menu({[this.Lang.Transl("\ud83d\udcdc \u83dc\u55ae\u71b1\u9375")]:{func:()=>alert(this.Lang.Transl("\u71b1\u9375\u547c\u53eb\u8abf\u6574\u83dc\u55ae!!\n\n\u5feb\u6377\u7d44\u5408 : (Alt + B)"))},[this.Lang.Transl("\ud83d\udee0\ufe0f \u8abf\u6574\u83dc\u55ae")]:{func:()=>this.BoosterMenu()}},"Menu",2),this.MenuHotkey(),this.StoreListen([this.Host],a=>{a.far&&a.key==this.Host&&this.Booster.setVolume(a.nv)})));setTimeout(()=>{this.MediaObserver.observe(document,this.ObserverOption)},3E3);return{setVolume:a=>{this.Increase=a;this.EnhanceNodes.forEach(f=>{f.gain.value=this.Increase**2})}}}catch(c){this.Log(this.Lang.Transl("\u589e\u5f37\u932f\u8aa4"),c,{type:"error",collapsed:!1})}}async Trigger(d,b){try{this.Increase=this.Store("g",this.Host)??1,this.Booster=this.BoosterFactory(d,b)}catch(c){this.Log("Trigger Error : ",c,{type:"error",collapsed:!1})}}async Injec(){this.GetBannedHost(d=>{const b=async c=>{this.Menu({[c]:{func:()=>this.Banned()}})};if(d){const c=this.Debounce(a=>{const f=[...this.$$("video, audio",{all:!0})].filter(g=>!this.EnhancedElement.has(g));0<f.length&&a(f)},400);this.Observer(document,()=>{const a=this.Runtime();c(f=>{this.MediaObserver.disconnect();this.Trigger(f,a)})},{mark:"Media-Booster",attributes:!1,throttle:500},a=>{this.MediaObserver=a.ob;this.ObserverOption=a.op;b(this.Lang.Transl("\u274c \u7981\u7528\u589e\u5e45"))})}else b(this.Lang.Transl("\u2705 \u555f\u7528\u589e\u5e45"))})}async BoosterMenu(){function d(){a.classList.add("Booster-Modal-Background-Closur");setTimeout(()=>{b.remove()},800)}if(!this.$$("#Booster_Modal_Background")){var b=document.createElement("div"),c=b.attachShadow({mode:"open"});b.id="Booster_Modal_Background";c.innerHTML=`<style id="Booster-Menu">Booster_Modal_Background {top: 0;left: 0;opacity: 1;width: 100%;height: 100%;display: flex;z-index: 9999;overflow: auto;position: fixed;align-items: center;justify-content: center;transition: opacity 0.4s ease;}.Booster-Modal-Button {margin: 0 2% 2% 0;color: #d877ff;cursor: pointer;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;text-decoration: none;}.Booster-Modal-Content {width: 400px;padding: 5px;overflow: auto;text-align: center;border-radius: 10px;background-color: #cff4ff;border: 2px ridge #82c4e2;border-collapse: collapse;margin: 2% auto 8px auto;}.Booster-Slider {width: 350px;cursor: pointer;margin-bottom: 1rem;}.Booster-Multiplier {margin: 2rem;font-size: 25px;font-weight: bold;color:rgb(253, 1, 85);}.Booster-Multiplier img {width: 8%;}.Booster-Multiplier span {display: flex;align-items: center;justify-content: center;}.Booster-Modal-Background-Closur {opacity: 0;pointer-events: none;}</style><Booster_Modal_Background id="Booster-Modal-Menu"><div class="Booster-Modal-Content"><div><h2 style="color: #3754f8;">${this.Lang.Transl("\u97f3\u91cf\u589e\u5f37")}</h2><div class="Booster-Multiplier"><span><img src="${GM_getResourceURL("Img")}">${this.Lang.Transl("\u589e\u5f37\u500d\u6578 ")}<span id="Booster-CurrentValue">${this.Increase}</span>${this.Lang.Transl(" \u500d")}</span></div><input type="range" id="Adjustment-Sound-Enhancement" 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="Booster-Menu-Close">${this.Lang.Transl("\u95dc\u9589")}</button><button class="Booster-Modal-Button" id="Booster-Sound-Save">${this.Lang.Transl("\u4fdd\u5b58")}</button></div></div></Booster_Modal_Background>`;document.body.appendChild(b);c=b.shadowRoot;var a=c.querySelector("Booster_Modal_Background"),f=c.querySelector("#Booster-CurrentValue"),g=c.querySelector("#Adjustment-Sound-Enhancement"),h;this.Listen(g,"input",e=>{h=e.target.value;f.textContent=h;this.Booster.setVolume(h)});this.Listen(a,"click",e=>{e.stopPropagation();e=e.target;"Booster-Sound-Save"===e.id?(this.Increase=e=parseFloat(g.value),this.Store("s",this.Host,e),d()):"Booster-Menu-Close"!==e.id&&"Booster-Modal-Menu"!==e.id||d()})}}Language(d){var b={},c={"\u2705 \u555f\u7528\u589e\u5e45":"\u2705 \u542f\u7528\u589e\u5e45","\ud83d\udcdc \u83dc\u55ae\u71b1\u9375":"\ud83d\udcdc \u83dc\u5355\u70ed\u952e","\ud83d\udee0\ufe0f \u8abf\u6574\u83dc\u55ae":"\ud83d\udee0\ufe0f \u8c03\u6574\u83dc\u5355","\u95dc\u9589":"\u5173\u95ed","\u97f3\u91cf\u589e\u5f37":"\u97f3\u91cf\u589e\u5f3a","\u589e\u5f37\u500d\u6578 ":"\u589e\u5f3a\u500d\u6570 ","\u589e\u5f37\u932f\u8aa4":"\u589e\u5f3a\u9519\u8bef","\u6dfb\u52a0\u589e\u5f37\u7bc0\u9ede\u6210\u529f":"\u6dfb\u52a0\u589e\u5f3a\u8282\u70b9\u6210\u529f","\u4e0d\u652f\u63f4\u97f3\u983b\u589e\u5f37\u7bc0\u9ede":"\u4e0d\u652f\u6301\u97f3\u9891\u589e\u5f3a\u8282\u70b9","\u71b1\u9375\u547c\u53eb\u8abf\u6574\u83dc\u55ae!!\n\n\u5feb\u6377\u7d44\u5408 : (Alt + B)":"\u70ed\u952e\u547c\u53eb\u8c03\u6574\u83dc\u5355!!\n\n\u5feb\u6377\u7ec4\u5408 : (Alt + B)"};b={"en-US":{"\u274c \u7981\u7528\u589e\u5e45":"\u274c Disable Boost","\u2705 \u555f\u7528\u589e\u5e45":"\u2705 Enable Boost","\ud83d\udcdc \u83dc\u55ae\u71b1\u9375":"\ud83d\udcdc Menu Hotkey","\ud83d\udee0\ufe0f \u8abf\u6574\u83dc\u55ae":"\ud83d\udee0\ufe0f Adjust Menu"," \u500d":"x","\u95dc\u9589":"Close","\u4fdd\u5b58":"Save","\u97f3\u91cf\u589e\u5f37":"Volume Boost","\u589e\u5f37\u500d\u6578 ":"Boost Multiplier ","\u589e\u5f37\u932f\u8aa4":"Boost Error","\u6dfb\u52a0\u589e\u5f37\u7bc0\u9ede\u6210\u529f":"Successfully Added Boost Node","\u4e0d\u652f\u63f4\u97f3\u983b\u589e\u5f37\u7bc0\u9ede":"Audio Boost Node Not Supported","\u71b1\u9375\u547c\u53eb\u8abf\u6574\u83dc\u55ae!!\n\n\u5feb\u6377\u7d44\u5408 : (Alt + B)":"Hotkey to Call Adjust Menu!!\n\nShortcut: (Alt + B)"},"zh-CN":c,"zh-SG":c,"zh-TW":b,"zh-HK":b,"zh-MO":b};const a=b[d]??b["en-US"];return{Transl:f=>a[f]??f}}}).Injec()})();