Custom CSS support

This commit is contained in:
Natsumi
2022-01-15 15:39:46 +13:00
parent 8a66bed6a2
commit 03fbec6a08
2 changed files with 28 additions and 0 deletions

View File

@@ -394,6 +394,15 @@ namespace VRCX
return System.Text.Json.JsonSerializer.Serialize<VRCEventDeserialization.EventEntry>(eventData);
}
public string CustomCssPath()
{
var output = String.Empty;
var filePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "VRCX\\custom.css");
if (File.Exists(filePath))
output = filePath;
return output;
}
public void SetStartup(bool enabled)
{
try

View File

@@ -73,6 +73,8 @@ speechSynthesis.getVoices();
} else if (e.key === 'r') {
location.reload();
}
} else if (e.key === 'R') {
$app.refreshCustomCss();
}
});
@@ -4055,6 +4057,7 @@ speechSynthesis.getVoices();
API.$on('SHOW_LAUNCH_DIALOG', (tag) => this.showLaunchDialog(tag));
this.updateLoop();
this.getGameLogTable();
this.refreshCustomCss();
this.$nextTick(function () {
this.$el.style.display = '';
if (!this.enablePrimaryPassword) {
@@ -4077,6 +4080,22 @@ speechSynthesis.getVoices();
}
};
$app.methods.refreshCustomCss = function () {
if (document.contains(document.getElementById('app-custom-style'))) {
document.getElementById('app-custom-style').remove();
}
AppApi.CustomCssPath().then((customCss) => {
var head = document.head;
if (customCss) {
var $appCustomStyle = document.createElement('link');
$appCustomStyle.setAttribute('id', 'app-custom-style');
$appCustomStyle.rel = 'stylesheet';
$appCustomStyle.href = `file://${customCss}?_=${Date.now()}`;
head.appendChild($appCustomStyle);
}
});
};
$app.methods.openExternalLink = function (link) {
this.$confirm(`${link}`, 'Open External Link', {
confirmButtonText: 'Confirm',