Last active
January 25, 2023 15:44
-
-
Save rishubil/05736f0acc0591657db2680e7c4acdd8 to your computer and use it in GitHub Desktop.
PleaseSpeakLouder.plugin.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @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