-
-
Save silver-mixer/6e0e73165e1774ec81ea60193ec81bb5 to your computer and use it in GitHub Desktop.
(function() { | |
// The following utility function are taken from EnhancedDiscord, developed by | |
// joe27g <https://github.com/joe27g>, and licensed under an MIT License. | |
// All credit goes to joe27g for the breadth of the work regarding accessing | |
// webpack modules at runtime. | |
// | |
// --- | |
// MIT License | |
// | |
// Copyright (c) 2019 joe27g | |
// | |
// Permission is hereby granted, free of charge, to any person obtaining a copy | |
// of this software and associated documentation files (the "Software"), to deal | |
// in the Software without restriction, including without limitation the rights | |
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
// copies of the Software, and to permit persons to whom the Software is | |
// furnished to do so, subject to the following conditions: | |
// | |
// The above copyright notice and this permission notice shall be included in all | |
// copies or substantial portions of the Software. | |
// | |
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
// SOFTWARE. | |
// | |
// --- | |
// | |
// Taken from dom_shit.js, lines 79-149, commit 8795de5f80608f4647668fcd5c3a5a7d508f350b | |
// https://github.com/joe27g/EnhancedDiscord/blob/8795de5f80608f4647668fcd5c3a5a7d508f350b/dom_shit.js#L79 | |
// | |
// --- | |
// | |
// このスクリプトはdavejbax氏のdiscord.jsを元に作成されています。 | |
// https://gist.github.com/davejbax/42abae54865f2ba1e3c649c7949fbbe1 | |
// | |
// DiscordのアップデートによりUserVolumeGroupが取得できなくなったため、該当部分を削除。 | |
// 最低限の動作をするように改変しています。 | |
// | |
// 注意点としてDiscordの言語設定が「日本語」か「English」の場合にのみ動作します。(未検証) | |
// また、このスクリプトを使用して起こったいかなる事態に関しても責任をおいません。予めご了承下さい。 | |
// | |
// (2020/11/05追記) | |
// Discordの大幅な変更に対応するため、MeguminSama氏のソースを参考にさせていただきました。 | |
// https://gist.github.com/MeguminSama/2cae24c9e4c335c661fa94e72235d4c4 | |
// | |
// --- | |
// | |
// ここを改変することで最大音量の変更ができます。 | |
let maxVolume = 500; | |
// < BEGIN EnhancedDiscord CODE > | |
webpackChunkdiscord_app.push([['wp_dvlc'], {}, (e) => window.req = e]); | |
window.findModule = (module, silent) => { | |
for (let i in req.c) { | |
if (req.c.hasOwnProperty(i)) { | |
let m = req.c[i].exports; | |
if (m && m.__esModule && m.default && m.default[module] !== undefined) | |
return m.default; | |
if (m && m[module] !== undefined) | |
return m; | |
} | |
} | |
if (!silent) c.warn(`Could not find module ${module}.`, {name: 'Modules', color: 'black'}); | |
return null; | |
}; | |
window.findModules = (module) => { | |
let mods = []; | |
for (let i in req.c) { | |
if (req.c.hasOwnProperty(i)) { | |
let m = req.c[i].exports; | |
if (m && m.__esModule && m.default && m.default[module] !== undefined) | |
mods.push(m.default); | |
if (m && m[module] !== undefined) | |
mods.push(m); | |
} | |
} | |
return mods; | |
}; | |
window.findRawModule = (module, silent) => { | |
for (let i in req.c) { | |
if (req.c.hasOwnProperty(i)) { | |
let m = req.c[i].exports; | |
if (m && m.__esModule && m.default && m.default[module] !== undefined) | |
return req.c[i]; | |
if (m && m[module] !== undefined) | |
return req.c[i]; | |
} | |
} | |
if (!silent) c.warn(`Could not find module ${module}.`, {name: 'Modules', color: 'black'}); | |
return null; | |
}; | |
window.findReactComponent = (name) => { | |
const named = findModules('displayName'); | |
return named.find(m => m.displayName === name); | |
}; | |
window.monkeyPatch = function(what, methodName, newFunc) { | |
if (!what || typeof what !== 'object') | |
return c.error(`Could not patch ${methodName} - Invalid module passed!`, {name: 'Modules', color: 'black'}); | |
const displayName = what.displayName || what.name || what.constructor.displayName || what.constructor.name; | |
const origMethod = what[methodName]; | |
const cancel = () => { | |
what[methodName] = origMethod; | |
console.log(`%c[EnhancedDiscord] %c[Modules]`, 'color: red;', `color: black;`, `Unpatched ${methodName} in module:`, what); | |
return true; | |
}; | |
what[methodName] = function() { | |
const data = { | |
thisObject: this, | |
methodArguments: arguments, | |
//cancelPatch: cancel, | |
originalMethod: origMethod, | |
callOriginalMethod: () => data.returnValue = data.originalMethod.apply(data.thisObject, data.methodArguments) | |
}; | |
return newFunc(data); | |
}; | |
what[methodName].__monkeyPatched = true; | |
what[methodName].displayName = 'patched ' + (what[methodName].displayName || methodName); | |
what[methodName].unpatch = cancel; | |
console.log(`%c[EnhancedDiscord] %c[Modules]`, 'color: red;', `color: black;`, `Patched ${methodName} in module:`, what); | |
return true; | |
}; | |
// < END EnhancedDiscord CODE > | |
// Find the relevant components | |
const Slider = findReactComponent('Slider'); | |
// Unpatch render methods if already patched (this allows re-pasting) | |
if (Slider.prototype.render.__monkeyPatched) { | |
Slider.prototype.render.unpatch(); | |
} | |
// We patch the Slider component, because we need to change it's max value; | |
// we can change this prop and re-render, but the state of the component does NOT | |
// change until it is re-created entirely. We therefore change the state ourselves | |
// on render (without re-invoking render) so that state.max and state.range are | |
// set correctly to the props (as if the component had been re-created). | |
monkeyPatch(Slider.prototype, 'render', (data) => { | |
// Check whether there's a discrepancy between prop max and state max | |
// 表示名が「ユーザーの音量」もしくは「User volume」のスライダーにのみ変更を適用 | |
if(data.thisObject && (data.thisObject.props['aria-label'] === 'ユーザーの音量' || | |
data.thisObject.props['aria-label'] === 'User Volume')){ | |
let props = Object.assign({}, data.thisObject.props); | |
props.maxValue = maxVolume; | |
data.thisObject.props = props; | |
let state = Object.assign({}, data.thisObject.state); | |
if(!data.thisObject.state.active)state.value = state.initialValueProp; | |
state.max = maxVolume; | |
state.range = state.max; | |
data.thisObject.state = state; | |
} | |
return data.callOriginalMethod(); | |
}); | |
})(); |
Hello,
thanks for updating this script! Is it possible for you to turn it into a BetterDiscord plugin?
Hello,
thanks for updating this script! Is it possible for you to turn it into a BetterDiscord plugin?
Thank you for your comment.
I'm sorry I can't make a plugin because I'm not using Better Discord.
コメントありがとうございます。
申し訳ありませんが私はBetterDiscordを使っていないためプラグインを作ることができません。
Do you have updated version?
Do you have updated version?
@MOKLx
Thank you for your comment.
I confirmed that it is not working.
I found the cause, so I fixed the part and updated the file.
コメントありがとうございます。
動作しなくなっていることを確認しました。
原因がわかったので該当部分を直してファイルを更新しました。
@silver-mixer Thank you so much! <3
for the English speakers who don't know why it doesn't work, change 'User volume' to 'User Volume'
for the English speakers who don't know why it doesn't work, change 'User volume' to 'User Volume'
@gregmueller
Thank you for information.
I fixed a bug and updated the file.
情報ありがとうございます。
バグを修正してファイルを更新しました。
Still working in March 2022. Thanks for keeping this script updated!
FYI: If you're trying to use this script to increase stream volume above 200% instead of user volume, all you need to do is replace data.thisObject.props['aria-label'] === 'User Volume')){
on line 148 with data.thisObject.props['aria-label'] === 'Stream Volume')){
and it just works.
const Slider = findReactComponent('Slider');
の部分でSliderが見つからなくなってるみたいです。
I keep getting this:
Uncaught TypeError: Cannot read property 'prototype' of undefined
at :136:13
at :163:3
Any ideas?
I'm pretty sure its complaining about this:
if (Slider.prototype.render.__monkeyPatched) {
Slider.prototype.render.unpatch();
}
But I don't know enough about Discord to fix this.
getting
//
Uncaught TypeError: Cannot read property 'prototype' of undefined
at :135:13
at :162:3
//
I do not know enough to try and figure out why it isn't working, especially as I don't have the old discord code to work with.
but I've tried renaming "Slider" to "slider", "sliderContainer" with no luck.
Yeah, I'm getting the same issue. Something changed about the Discord client in the way it presents the sliders internally, which is causing the script to fail when it tries to get the slider object to patch. I'm in the same boat of not knowing enough about Discord internally to figure out why it's no longer pointing correctly.
Discord音量上限変更スクリプト
このスクリプトはDiscordの音量調節の上限を200%以上にするものです。デフォルトでは500%まで上げることが出来ます。
Discordのバージョンアップによって動かなくなったdavejbax氏のソースを参考に、手直しを行っています。
davejbax氏のdiscord.js(ソース改変元)
使い方
上限の変更
デフォルトでは500%が上限となっていますが48行目
let maxVolume = 500;
を変更することにより500%以上に調節することが出来ます。
上限700%にする例)
let maxVolume = 700;
注意
開発者ツールのコンソールを開いた時に警告が表示されますが、これは非常に重要な警告です。
このスクリプトにはユーザの情報を抜き取るようなプログラムは含まれていませんが、一度ソースをよく確認することをおすすめします。
確認した上で自己責任でご使用下さい。このスクリプトを使用して起きたいかなる事象についても責任をおいません。
使用できる環境はDiscordの言語設定が「日本語」もしくは「English」の場合のみです。
また、応急処置的な対処なのでDiscordのアップデートにより使用できなくなる可能性があります。
謝辞
このスクリプトはdavejbax氏のdiscord.jsを元にさせていただきました。
Enhanced Discordに関しましては元のスクリプトとヘッダーをご参照ください。
また2021/11/05に確認したDiscordのアップデートに対応するため、MeguminSama氏の"Discord Experiments.js"を参考にさせていただきました。
感謝申し上げます。
既知のバグ
履歴
2021/12/24 言語設定が「English」の場合動作しないバグを修正
2021/11/05 Discordのアップデートにより動作しなくなったため修正
2021/08/14 Discordのアップデートにより動作しなくなったため修正