Skip to content

Instantly share code, notes, and snippets.

@rishubil
Last active January 25, 2023 15:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rishubil/05736f0acc0591657db2680e7c4acdd8 to your computer and use it in GitHub Desktop.
Save rishubil/05736f0acc0591657db2680e7c4acdd8 to your computer and use it in GitHub Desktop.
PleaseSpeakLouder.plugin.js
/**
* @name PleaseSpeakLouder
* @author Nesswit
* @description You can adjust the volume of someone else's voice louder.
* @version 0.0.4
* @source https://gist.github.com/rishubil/05736f0acc0591657db2680e7c4acdd8
* @updateUrl https://gist.githubusercontent.com/rishubil/05736f0acc0591657db2680e7c4acdd8/raw/a7211050f1131f72b57f184ce6eb48f600f21c3e/PleaseSpeakLouder.plugin.js
*/
// original code: https://github.com/QWERTxD/BetterDiscordPlugins/blob/main/UserVolumeBooster/UserVolumeBooster.plugin.js
function waitForElm(selector) {
return new Promise(resolve => {
if (document.querySelector(selector)) {
return resolve(document.querySelector(selector));
}
const observer = new MutationObserver(mutations => {
if (document.querySelector(selector)) {
resolve(document.querySelector(selector));
observer.disconnect();
}
});
observer.observe(document.body, {
childList: true,
subtree: true
});
});
}
module.exports = class PleaseSpeakLouder {
start() {
this.patch();
}
stop() {
BdApi.Patcher.unpatchAll("slider");
}
patch() {
waitForElm('.slider-BEB8u7').then((elm) => {
let slider_prototype = BdApi.ReactUtils.getOwnerInstance(elm).__proto__
BdApi.Patcher.before("slider", slider_prototype, "render", ((_this, [props]) => {
if ("slider-BEB8u7" !== _this?.props?.className) return;
_this.props.maxValue = 500;
_this.state.range = 500;
_this.state.max = 500;
_this.state.value = _this.state.initialValueProp;
}));
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment