Skip to content

Commit

Permalink
Add BrowserStyle.css
Browse files Browse the repository at this point in the history
  • Loading branch information
the1812 committed Jul 3, 2023
1 parent eefbccf commit 48b3883
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ There are 4 files:
- `Style.css`: Your custom CSS code to insert

Write your Steam installation path in `SteamPath.txt` and custom CSS code in `Style.css`.
Optionally, you can create an extra `BrowserStyle.css` file. This style will be inserted to Steam Browser styles in replace of `Style.css`.

Start `SteamCSS.exe` to run the program.

Expand Down
1 change: 1 addition & 0 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- `Style.css`: 自定义要插入的 CSS 代码

先在 `SteamPath.txt` 里写下 Steam 的安装文件夹, `Style.css` 里写下要插入的 CSS 代码.
另外也可以再新建一个 `BrowserStyle.css` 文件, 这个样式可以替代 `Style.css` 插入到 Steam 内置浏览器的样式中.

然后启动 `SteamCSS.exe` 就可以了.

Expand Down
14 changes: 13 additions & 1 deletion SteamCSS/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,18 @@ static void Main()
try
{
var steamPath = File.ReadAllText("SteamPath.txt").Trim();
var style = File.ReadAllText("Style.css");
var mainStyle = File.ReadAllText("Style.css");

var browserStyle = "";
if (File.Exists("BrowserStyle.css"))
{
browserStyle = File.ReadAllText("BrowserStyle.css");
}
else
{
browserStyle = mainStyle;
}

var cssFiles = File.ReadAllText("StylePath.txt").Trim().Split(new string [] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries).ToList();
var processedFiles = new List<string>();
cssFiles.ForEach(file =>
Expand All @@ -48,6 +59,7 @@ static void Main()
return;
}
var content = File.ReadAllText(filePath);
var style = file.Contains("webkit") ? browserStyle : mainStyle;
if (!content.StartsWith(style))
{
File.WriteAllText(filePath, style + Environment.NewLine + content);
Expand Down
4 changes: 2 additions & 2 deletions SteamCSS/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.1.0")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyVersion("1.1.0.0")]
[assembly: AssemblyFileVersion("1.1.0.0")]

0 comments on commit 48b3883

Please sign in to comment.