Hide player config when it’s locked by server (#329)
* add missing api * Might as well get the client list, too * Remove client setting when unavailable --------- Co-authored-by: Kilian von Pflugk <github@jumoog.io>
This commit is contained in:
parent
f07134cc55
commit
a81b367ffe
@ -9,7 +9,10 @@ namespace ConfusedPolarBear.Plugin.IntroSkipper.Configuration;
|
|||||||
/// <param name="visible">Skip button visibility.</param>
|
/// <param name="visible">Skip button visibility.</param>
|
||||||
/// <param name="introText">Skip button intro text.</param>
|
/// <param name="introText">Skip button intro text.</param>
|
||||||
/// <param name="creditsText">Skip button end credits text.</param>
|
/// <param name="creditsText">Skip button end credits text.</param>
|
||||||
public class UserInterfaceConfiguration(bool visible, string introText, string creditsText)
|
/// <param name="autoSkip">Auto Skip Intro.</param>
|
||||||
|
/// <param name="autoSkipCredits">Auto Skip Credits.</param>
|
||||||
|
/// <param name="clientList">Auto Skip Clients.</param>
|
||||||
|
public class UserInterfaceConfiguration(bool visible, string introText, string creditsText, bool autoSkip, bool autoSkipCredits, string clientList)
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets a value indicating whether to show the skip intro button.
|
/// Gets or sets a value indicating whether to show the skip intro button.
|
||||||
@ -25,4 +28,19 @@ public class UserInterfaceConfiguration(bool visible, string introText, string c
|
|||||||
/// Gets or sets the text to display in the skip intro button in end credits mode.
|
/// Gets or sets the text to display in the skip intro button in end credits mode.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string SkipButtonEndCreditsText { get; set; } = creditsText;
|
public string SkipButtonEndCreditsText { get; set; } = creditsText;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether auto skip intro.
|
||||||
|
/// </summary>
|
||||||
|
public bool AutoSkip { get; set; } = autoSkip;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether auto skip credits.
|
||||||
|
/// </summary>
|
||||||
|
public bool AutoSkipCredits { get; set; } = autoSkipCredits;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating clients to auto skip for.
|
||||||
|
/// </summary>
|
||||||
|
public string ClientList { get; set; } = clientList;
|
||||||
}
|
}
|
||||||
|
@ -303,8 +303,18 @@ const introSkipper = {
|
|||||||
localStorage.setItem('introskipperOption', option);
|
localStorage.setItem('introskipperOption', option);
|
||||||
this.d(`Introskipper option selected and saved: ${option}`);
|
this.d(`Introskipper option selected and saved: ${option}`);
|
||||||
},
|
},
|
||||||
injectIntroSkipperOptions(actionSheet) {
|
isAutoSkipLocked(config) {
|
||||||
|
const isAutoSkip = config.AutoSkip && config.AutoSkipCredits;
|
||||||
|
const isAutoSkipClient = new Set(config.ClientList.split(',')).has(ApiClient.appName());
|
||||||
|
return isAutoSkip || (config.SkipButtonVisible && isAutoSkipClient);
|
||||||
|
},
|
||||||
|
async injectIntroSkipperOptions(actionSheet) {
|
||||||
if (!this.skipButton) return;
|
if (!this.skipButton) return;
|
||||||
|
const config = await this.secureFetch("Intros/UserInterfaceConfiguration");
|
||||||
|
if (this.isAutoSkipLocked(config)) {
|
||||||
|
this.d("Auto skip enforced by server");
|
||||||
|
return;
|
||||||
|
}
|
||||||
const statsButton = actionSheet.querySelector('[data-id="stats"]');
|
const statsButton = actionSheet.querySelector('[data-id="stats"]');
|
||||||
if (!statsButton) return;
|
if (!statsButton) return;
|
||||||
const menuItem = this.createButton(statsButton, 'introskipperMenu',
|
const menuItem = this.createButton(statsButton, 'introskipperMenu',
|
||||||
|
@ -221,6 +221,9 @@ public class SkipIntroController : ControllerBase
|
|||||||
return new UserInterfaceConfiguration(
|
return new UserInterfaceConfiguration(
|
||||||
config.SkipButtonVisible,
|
config.SkipButtonVisible,
|
||||||
config.SkipButtonIntroText,
|
config.SkipButtonIntroText,
|
||||||
config.SkipButtonEndCreditsText);
|
config.SkipButtonEndCreditsText,
|
||||||
|
config.AutoSkip,
|
||||||
|
config.AutoSkipCredits,
|
||||||
|
config.ClientList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user