diff options
Diffstat (limited to 'src/plugins/volumeBooster.ts')
-rw-r--r-- | src/plugins/volumeBooster.ts | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/src/plugins/volumeBooster.ts b/src/plugins/volumeBooster.ts index 6553a5c..7d81449 100644 --- a/src/plugins/volumeBooster.ts +++ b/src/plugins/volumeBooster.ts @@ -16,14 +16,26 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -import { makeRange } from "@components/PluginSettings/components/SettingSliderComponent"; +import { definePluginSettings } from "@api/settings"; +import { makeRange } from "@components/PluginSettings/components"; import { Devs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; +const settings = definePluginSettings({ + multiplier: { + description: "Volume Multiplier", + type: OptionType.SLIDER, + markers: makeRange(1, 5, 1), + default: 2, + stickToMarkers: true, + } +}); + export default definePlugin({ name: "VolumeBooster", authors: [Devs.Nuckyz], description: "Allows you to set the user and stream volume above the default maximum.", + settings, patches: [ // Change the max volume for sliders to allow for values above 200 @@ -33,11 +45,10 @@ export default definePlugin({ ].map(find => ({ find, replacement: { - match: /maxValue:(?<defaultMaxVolumePredicate>\i\.\i)\?(?<higherMaxVolume>\d+?):(?<minorMaxVolume>\d+?),/, - replace: "" - + "maxValue:$<defaultMaxVolumePredicate>" - + "?$<higherMaxVolume>*Vencord.Settings.plugins.VolumeBooster.multiplier" - + ":$<minorMaxVolume>*Vencord.Settings.plugins.VolumeBooster.multiplier," + match: /(?<=maxValue:\i\.\i)\?(\d+?):(\d+?)(?=,)/, + replace: (_, higherMaxVolume, minorMaxVolume) => "" + + `?${higherMaxVolume}*$self.settings.store.multiplier` + + `:${minorMaxVolume}*$self.settings.store.multiplier` } })), // Prevent Audio Context Settings sync from trying to sync with values above 200, changing them to 200 before we send to Discord @@ -45,16 +56,16 @@ export default definePlugin({ find: "AudioContextSettingsMigrated", replacement: [ { - match: /(?<restOfFunction>updateAsync\("audioContextSettings".{1,50})(?<volumeChangeExpression>return (?<volumeOptions>\i)\.volume=(?<newVolume>\i))/, - replace: "$<restOfFunction>if($<newVolume>>200)return $<volumeOptions>.volume=200;$<volumeChangeExpression>" + match: /(?<=updateAsync\("audioContextSettings".{0,50})(?=return (\i)\.volume=(\i))/, + replace: (_, volumeOptions, newVolume) => `if(${newVolume}>200)return ${volumeOptions}.volume=200;` }, { - match: /(?<restOfFunction>Object\.entries\(\i\.localMutes\).+?)volume:(?<volumeExpression>.+?),/, - replace: "$<restOfFunction>volume:$<volumeExpression>>200?200:$<volumeExpression>," + match: /(?<=Object\.entries\(\i\.localMutes\).+?volume:).+?(?=,)/, + replace: "$&>200?200:$&" }, { - match: /(?<restOfFunction>Object\.entries\(\i\.localVolumes\).+?)volume:(?<volumeExpression>.+?)}\)/, - replace: "$<restOfFunction>volume:$<volumeExpression>>200?200:$<volumeExpression>})" + match: /(?<=Object\.entries\(\i\.localVolumes\).+?volume:).+?(?=})/, + replace: "$&>200?200:$&" } ] }, @@ -63,24 +74,13 @@ export default definePlugin({ find: '.displayName="MediaEngineStore"', replacement: [ { - match: /(?<restOfFunction>\.settings\.audioContextSettings.+?)(?<localVolume>\i\[\i\])=(?<syncVolume>\i\.volume)(?<secondRestOfFunction>.+?)setLocalVolume\((?<id>.+?),.+?\)/, - replace: "" - + "$<restOfFunction>" - + "($<localVolume>>200?undefined:$<localVolume>=$<syncVolume>)" - + "$<secondRestOfFunction>" - + "setLocalVolume($<id>,$<localVolume>??$<syncVolume>)" + match: /(?<=\.settings\.audioContextSettings.+?)(\i\[\i\])=(\i\.volume)(.+?setLocalVolume\(\i,).+?\)/, + replace: (_, localVolume, syncVolume, rest) => "" + + `(${localVolume}>200?void 0:${localVolume}=${syncVolume})` + + rest + + `${localVolume}??${syncVolume})` } ] } ], - - options: { - multiplier: { - description: "Volume Multiplier", - type: OptionType.SLIDER, - markers: makeRange(1, 5, 1), - default: 2, - stickToMarkers: true, - } - } }); |