影片音量增強器

增強影片音量上限,最高增幅至 10 倍,尚未測試是否所有網域都可使用,當影片無聲時,禁止該腳本在該網域上運行。

目前為 2024-01-28 提交的版本,檢視 最新版本

// ==UserScript==
// @name 影片音量增強器
// @version 0.0.29
// @author HentaiSaru
// @description 增強影片音量上限,最高增幅至 10 倍,尚未測試是否所有網域都可使用,當影片無聲時,禁止該腳本在該網域上運行。
// @match *://*/*
// @exclude *://video.eyny.com/*
// @icon https://cdn-icons-png.flaticon.com/512/8298/8298181.png
// @license MIT
// @namespace https://gf.qytechs.cn/users/989635
// @run-at document-end
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_addStyle
// @grant GM_registerMenuCommand
// ==/UserScript==
(function(){async function u(){y("video",8,a=>{try{k=q?m("get",n)||1:1,v=z(a,k)}catch{}})}function z(a,d){const c=new window.AudioContext,b=c.createMediaElementSource(a),e=c.createGain(),f=c.createBiquadFilter(),p=c.createBiquadFilter(),g=c.createDynamicsCompressor();a.volume=1;e.gain.value=d*d;g.ratio.value=6;g.knee.value=.5;g.threshold.value=-14;g.attack.value=.02;g.release.value=.4;f.frequency.value=250;f.type="lowshelf";f.gain.value=2.2;p.frequency.value=1E4;p.type="highshelf";p.gain.value=1.8;
b.connect(e);e.connect(f);f.connect(p);e.connect(g);g.connect(c.destination);a.setAttribute("data-audio-context",!0);return{setVolume:function(r){e.gain.value=r*r;k=r}}}async function w(){const a=document.createElement("div");
a.innerHTML=`<div class="modal-content"><h2 style="color: #3754f8;">\u97f3\u91cf\u589e\u91cf</h2><div style="margin:1rem auto 1rem auto;"><div class="multiplier"><span><img src="https://cdn-icons-png.flaticon.com/512/8298/8298181.png" width="5%">\u589e\u91cf\u500d\u6578 </span><span id="CurrentValue">${k}</span><span> \u500d</span></div><input type="range" id="sound-amplification" class="slider" min="0" max="10.0" value="${k}" step="0.1"><br></div><div style="text-align: right;"><button class="modal-button" id="sound-save">\u4fdd\u5b58\u8a2d\u7f6e</button><button class="modal-button" id="sound-close">\u9000\u51fa\u9078\u55ae</button></div></div>`;
a.classList.add("modal-background");document.body.appendChild(A.appendChild(a));const d=h("#CurrentValue"),c=h("#sound-amplification");t(c,"input",b=>{b=b.target.value;d.textContent=b;v.setVolume(b)},{passive:!0,capture:!0});t(h(".modal-background"),"click",b=>{b.stopPropagation();b=b.target;"sound-save"===b.id?q?(m("set",n,parseFloat(c.value)),h(".modal-background").remove()):alert("\u9700\u555f\u7528\u81ea\u52d5\u589e\u5e45\u624d\u53ef\u4fdd\u5b58"):"modal-background"!==b.className&&"sound-close"!==
b.id||h(".modal-background").remove()},{capture:!0})}async function t(a,d,c,b={}){l.has(a)&&l.get(a).has(d)||(a.addEventListener(d,c,b),l.has(a)||l.set(a,new Map),l.get(a).set(d,c))}function h(a,d=!1,c=document){if(d)return c.querySelectorAll(a);d=a.slice(1);switch(d.includes(" ")||d.includes(".")||d.includes("#")?" ":a[0]){case "#":return c.getElementById(d);case " ":return c.querySelector(a);case ".":return c.getElementsByClassName(d)[0];default:return c.getElementsByTagName(a)[0]}}async function y(a,
d,c){let b,e;const f=new MutationObserver(()=>{if(e=h(a))f.disconnect(),clearTimeout(b),c(e)});f.observe(document.body,{childList:!0,subtree:!0});b=setTimeout(()=>{f.disconnect()},1E3*d)}async function B(){let a;(new MutationObserver(()=>{(a=h("video"))&&!a.hasAttribute("data-audio-context")&&u()})).observe(document.head,{childList:!0,subtree:!0})}async function C(a,d){q?(a=a.filter(c=>c!==d),alert("\u274c \u7981\u7528\u81ea\u52d5\u589e\u5e45")):(a.push(d),alert("\u2705 \u555f\u7528\u81ea\u52d5\u589e\u5e45"));
m("set","\u555f\u7528\u7db2\u57df",a);location.reload()}function m(a,d,c=null){return{__verify:b=>void 0!==b?b:null,set:function(b,e){return GM_setValue(b,e)},get:function(b,e){return this.__verify(GM_getValue(b,e))},setjs:function(b,e){return GM_setValue(b,JSON.stringify(e,null,4))},getjs:function(b,e){return JSON.parse(this.__verify(GM_getValue(b,e)))}}[a](d,c)}var v,k,l=new Map,n=location.hostname,A=document.createDocumentFragment(),x=m("get","\u555f\u7528\u7db2\u57df",[]),q=x.includes(n);u();
(async function(){t(document,"keydown",a=>{a.altKey&&"b"===a.key&&w()},{passive:!0,capture:!0})})();setTimeout(()=>{B()},1E3);(async function(a){for(const [d,c]of Object.entries(a))GM_registerMenuCommand(d,()=>{c()})})({"\ud83d\udd0a [\u958b\u95dc] \u81ea\u52d5\u589e\u5e45":()=>C(x,n),"\ud83d\udee0\ufe0f \u8a2d\u7f6e\u589e\u5e45":()=>w(),"\ud83d\udcdc \u83dc\u55ae\u71b1\u9375":()=>alert("\u71b1\u9375\u547c\u53eb\u8abf\u6574\u83dc\u55ae!!\n\n\u5feb\u6377\u7d44\u5408 : (Alt + B)")});GM_addStyle("\n        .modal-background {\n            top: 0;\n            left: 0;\n            width: 100%;\n            height: 100%;\n            display: flex;\n            z-index: 9999;\n            overflow: auto;\n            position: fixed;\n            align-items: center;\n            justify-content: center;\n        }\n        .modal-button {\n            top: 0;\n            margin: 3% 2%;\n            color: #d877ff;\n            font-size: 16px;\n            font-weight: bold;\n            border-radius: 3px;\n            background-color: #ffebfa;\n            border: 1px solid rgb(124, 183, 252);\n        }\n        .modal-button:hover,\n        .modal-button:focus {\n            color: #fc0e85;\n            cursor: pointer;\n            text-decoration: none;\n        }\n        .modal-content {\n            width: 400px;\n            padding: 5px;\n            overflow: auto;\n            background-color: #cff4ff;\n            border-radius: 10px;\n            text-align: center;\n            border: 2px ridge #82c4e2;\n            border-collapse: collapse;\n            margin: 2% auto 8px auto;\n        }\n        .multiplier {\n            font-size:25px;\n            color:rgb(253, 1, 85);\n            margin: 10px;\n            font-weight:bold;\n        }\n        .slider {width: 350px;}\n        input {cursor: pointer;}\n    ")})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址