Greasy Fork is available in English.

影片音量增強器

增強影片音量上限,最高增幅至 20 倍,有些不支援的網站,影片會沒聲音 或是 沒有效果,命令選單有時有 BUG 會多創建一個,但不影響原功能使用。

// ==UserScript==
// @name         影片音量增強器
// @version      0.0.35-Beta
// @author       Canaan HS
// @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
// @grant        GM_addValueChangeListener
// @require      https://update.greasyfork.org/scripts/487608/1361054/SyntaxSimplified.js
// ==/UserScript==
(function(){if(!/^(http|https):\/\/(?!chrome\/|about\/).*$/i.test(document.URL))return!1;(new class extends Syntax{constructor(){super();this.Increase=this.Booster=this.Display=this.Domain=null;this.StyleTag=!1;this.ObserverOptions=this.MediaObserver=this.ExcludeStatus=this.BannedDomains=null;this.DetectionInitialization=b=>{this.Domain=location.hostname;this.BannedDomains=this.store("g","BannedDomains_v2",{});this.ExcludeStatus=this.BannedDomains[this.Domain];b(this.ExcludeStatus)};this.BannedDomain=async()=>{this.ExcludeStatus?delete this.BannedDomains[this.Domain]:this.BannedDomains[this.Domain]=!0;this.store("s","BannedDomains_v2",this.BannedDomains);location.reload()};this.StartMenu=async b=>{this.Menu({[b]:{func:()=>this.BannedDomain(this.Domain)}})};this.MenuHotkey=async b=>{this.Listen(document,"keydown",a=>{a.altKey&&"B"==a.key.toUpperCase()&&this.IncrementalSetting()},{passive:!0,capture:!0},a=>{a?this.Runtime(b,"Hotkey Success",{style:"\u001b[1m\u001b[32m%s\u001b[0m"}):this.Runtime(b,"Hotkey Failed",{style:"\u001b[1m\u001b[31m%s\u001b[0m"})})};this.FindMain=async(b,a)=>{a(b.sort((c,f)=>f.offsetWidth-c.offsetWidth)[0])}}async Injection(){this.DetectionInitialization(b=>{this.Display=this.Language(navigator.language);if(b)return this.StartMenu(this.Display.MS),!1;this.Observer(document.head,()=>{const a=Date.now();this.FindMain(this.$$("video",{all:!0}),c=>{c&&!c.hasAttribute("Media-Audio-Booster")&&(this.MediaObserver.disconnect(),this.Trigger(c,a))})},{mark:"Audio-Booster",throttle:300},a=>{this.MediaObserver=a.ob;this.ObserverOptions=a.op;this.StartMenu(this.Display.MD)})})}async Trigger(b,a){try{this.Increase=this.store("g",this.Domain)||1,this.Booster=this.BoosterLogic(b,this.Increase,a),this.StyleTag||(this.StyleTag=!0,this.AddStyle(".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;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: 15px;font-weight:bold;}.Booster-Modal-Background-Closur {opacity: 0;pointer-events: none;}.Booster-Slider {width: 350px;}div input {cursor: pointer;}#sound-save {cursor: pointer;}\n"))}catch(c){this.log("Trigger Error : ",c,{type:"error",collapsed:!1})}}BoosterLogic(b,a,c){const f=window.AudioContext||window.webkitAudioContext;try{if(!f)throw this.Display.BT1;const e=new f,k=e.createMediaElementSource(b),d=e.createGain(),l=e.createBiquadFilter(),m=e.createBiquadFilter(),g=e.createDynamicsCompressor();b.volume=1;d.gain.value=a**2;g.ratio.value=6;g.knee.value=.5;g.threshold.value=-14;g.attack.value=.02;g.release.value=.4;l.frequency.value=250;l.type="lowshelf";l.gain.value=2.2;m.frequency.value=1E4;m.type="highshelf";m.gain.value=1.8;k.connect(d).connect(l).connect(m);d.connect(g).connect(e.destination);b.setAttribute("Media-Audio-Booster",!0);this.log(this.Display.BT3,{"Booster Media : ":b,"Elapsed Time : ":`${(Date.now()-c)/1E3}s`},{collapsed:!1});b.hasAttribute("Media-Audio-Booster")&&(this.MenuHotkey(c),this.Menu({[this.Display.MK]:{func:()=>alert(this.Display.MKT)},[this.Display.MM]:{func:()=>this.IncrementalSetting()}},"Menu",2),setTimeout(()=>{this.MediaObserver.observe(document.head,this.ObserverOptions)},8E3));this.storeListen([this.Domain],h=>{h.far&&h.key==this.Domain&&this.Booster.setVolume(h.nv)});return{setVolume:h=>{d.gain.value=h**2;this.Increase=h}}}catch(e){this.log(this.Display.BT4,e,{type:"error",collapsed:!1})}}async IncrementalSetting(){if(!this.$$(".Booster-Modal-Background")){const b=document.createElement("div");b.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="Booster-CurrentValue">${this.Increase}</span><span>${this.Display.S2}</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="sound-save">${this.Display.SS}</button></div></div></div>`;document.body.appendChild(b);const a=this.$$("#Booster-CurrentValue"),c=this.$$("#Adjustment-Sound-Enhancement");let f;this.Listen(c,"input",d=>{requestAnimationFrame(()=>{f=d.target.value;a.textContent=f;this.Booster.setVolume(f)})},{passive:!0,capture:!0});const e=this.$$(".Booster-Modal-Background");this.Listen(e,"click",d=>{d.stopPropagation();d=d.target;"sound-save"===d.id?(this.Increase=d=parseFloat(c.value),this.store("s",this.Domain,d),k()):"Booster-Modal-Background"===d.className&&k()},{capture:!0});function k(){e.classList.add("Booster-Modal-Background-Closur");setTimeout(()=>{e.remove()},1200)}}}Language(b){var a={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"},c={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"};a={"zh-TW":a,"zh-HK":a,"zh-MO":a,"zh-CN":c,"zh-SG":c,"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"}};return a[b]||a["en-US"]}}).Injection()})();