Skip to content

Commit

Permalink
Compatibility with 1904X.3086+
Browse files Browse the repository at this point in the history
Fix #46
  • Loading branch information
krlvm committed Jun 20, 2023
1 parent daf54d0 commit f115cc0
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions BeautySearch/Installer/ScriptInstaller.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Microsoft.Win32;
using System;
using System.Diagnostics;
using System;
using System.IO;
using System.Windows.Forms;

Expand Down Expand Up @@ -260,6 +258,7 @@ private static string LoadScript(string name)
}

// Controller Injector
// TODO: Refactor

private static bool InjectController()
{
Expand All @@ -273,7 +272,12 @@ private static bool InjectController()

// Controller is accessible via 'bsController' global variable
controller = "var bsController = null;" + controller;
if (IS_20H1 && SystemInfo.BUILD_NUMBER_MINOR < MIN_20H1_PATCH_FIX)
if (controller.Contains("static bindShown"))
{
// 1904X.3086+
controller = controller.Insert(controller.IndexOf("t._queryParamsCache={};"), ";bsController=t;");
}
else if (IS_20H1 && SystemInfo.BUILD_NUMBER_MINOR < MIN_20H1_PATCH_FIX)
{
controller = controller.Insert(controller.IndexOf("}return l.prototype"), ";bsController=l;");
}
Expand All @@ -295,7 +299,12 @@ public static string FindControllerFile()
foreach (var file in Directory.EnumerateFiles(TARGET_DIR, "*.js"))
{
string text = File.ReadAllText(file);
if (text.Contains("return l.prototype") || text.Contains("return l.isBingWallpaperAppInstalled")) return file;
if (text.Contains("static bindShown")
|| text.Contains("return l.prototype")
|| text.Contains("return l.isBingWallpaperAppInstalled"))
{
return file;
}
}
return null;
}
Expand Down

0 comments on commit f115cc0

Please sign in to comment.