fix: custom Video/Audio switcher in Plugins menu (#3174)

Related to #3167

Update `setVideoState` function and `switchButtonDiv` event listener to handle transition back to audio mode.

* **Update `setVideoState` function**
  - Correctly handle the transition back to audio mode.
  - Update the `hideVideo` property in the plugin configuration.
  - Use `this.config` instead of `config` to set options and update checkbox state.

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/th-ch/youtube-music/issues/3167?shareId=XXXX-XXXX-XXXX-XXXX).
This commit is contained in:
LuckyMod
2025-04-08 04:16:51 +05:30
committed by GitHub
parent 0d3311ff5d
commit fef3b63581

View File

@ -179,12 +179,12 @@ export default createPlugin({
if (this.config) {
this.config.hideVideo = !showVideo;
}
window.mainConfig.plugins.setOptions('video-toggle', config);
window.mainConfig.plugins.setOptions('video-toggle', this.config);
const checkbox = document.querySelector<HTMLInputElement>(
'.video-switch-button-checkbox',
); // custom mode
if (checkbox) checkbox.checked = !config.hideVideo;
if (checkbox) checkbox.checked = !this.config.hideVideo;
if (player) {
player.style.margin = showVideo ? '' : 'auto 0px';