Skip to content
This repository was archived by the owner on Oct 23, 2022. It is now read-only.

Commit 37687d5

Browse files
committed
R10-ready (webpages n stuff)
1 parent 16ab03d commit 37687d5

File tree

4 files changed

+72
-37
lines changed

4 files changed

+72
-37
lines changed

ActiveDesktop/ADPWebWallpaper.xaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
<Window
1+
<Window x:Class="ActiveDesktop.ADPWebWallpaper"
22
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
44
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
55
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
66
xmlns:local="clr-namespace:ActiveDesktop"
7-
xmlns:Controls="clr-namespace:Microsoft.Toolkit.Wpf.UI.Controls;assembly=Microsoft.Toolkit.Wpf.UI.Controls.WebView" x:Class="ActiveDesktop.ADPWebWallpaper"
7+
xmlns:wv2="clr-namespace:Microsoft.Web.WebView2.Wpf;assembly=Microsoft.Web.WebView2.Wpf"
88
mc:Ignorable="d"
99
ResizeMode="NoResize"
1010
WindowStartupLocation="CenterScreen"
1111
WindowState="Maximized" WindowStyle="None"
1212
Title="ADPWebWallpaper" Height="800" Width="800">
1313
<Grid>
14-
<Controls:WebView x:Name="WebView" NavigationCompleted="WebView_NavigationCompleted"/>
14+
<wv2:WebView2 x:Name="WebView2" NavigationCompleted="WebView2_NavigationCompleted" CoreWebView2Ready="WebView2_CoreWebView2Ready"/>
1515
</Grid>
16-
</Window>
16+
</Window>
Lines changed: 63 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
using Microsoft.Toolkit.Win32.UI.Controls.Interop.WinRT;
2-
using System;
3-
using System.Windows;
4-
using System.Windows.Threading;
5-
using System.Threading.Tasks;
1+
using System.Windows;
62

73
namespace ActiveDesktop
84
{
@@ -16,52 +12,91 @@ public ADPWebWallpaper(string url)
1612
{
1713
navto = url;
1814
InitializeComponent();
19-
WebView.Loaded += WebView_Loaded;
20-
System.Diagnostics.Debug.WriteLine("Window created");
15+
WebView2.EnsureCoreWebView2Async();
2116
Show();
22-
}
23-
24-
private void WebView_Loaded(object sender, RoutedEventArgs e)
25-
{
26-
Potato();
17+
System.Diagnostics.Debug.WriteLine("Window created");
2718
}
2819

2920
private void Potato()
3021
{
22+
if (navto.Contains("https://www.youtube.com/watch?v="))
23+
{
24+
navto = "https://www.youtube.com/embed/" + navto.Substring(32);
25+
}
26+
if (navto.Contains("https://youtube.com/watch?v="))
27+
{
28+
navto = "https://www.youtube.com/embed/" + navto.Substring(28);
29+
}
30+
if (navto.Contains("http://www.youtube.com/watch?v="))
31+
{
32+
navto = "https://www.youtube.com/embed/" + navto.Substring(31);
33+
}
34+
if (navto.Contains("http://youtube.com/watch?v="))
35+
{
36+
navto = "https://www.youtube.com/embed/" + navto.Substring(27);
37+
}
38+
if (navto.Contains("https://www.youtu.be/"))
39+
{
40+
navto = "https://www.youtube.com/embed/" + navto.Substring(21);
41+
}
42+
if (navto.Contains("https://youtu.be/"))
43+
{
44+
navto = "https://www.youtube.com/embed/" + navto.Substring(17);
45+
}
46+
if (navto.Contains("http://www.youtu.be/"))
47+
{
48+
navto = "https://www.youtube.com/embed/" + navto.Substring(20);
49+
}
50+
if (navto.Contains("http://youtu.be/"))
51+
{
52+
navto = "https://www.youtube.com/embed/" + navto.Substring(16);
53+
}
54+
3155
System.Diagnostics.Debug.WriteLine("Potatoing to " + navto);
32-
WebView.Navigate(navto);
56+
WebView2.CoreWebView2.Navigate(navto);
3357
System.Diagnostics.Debug.WriteLine("Potatoed");
34-
3558
}
3659

37-
private void WebView_NavigationCompleted(object sender, WebViewControlNavigationCompletedEventArgs e)
60+
private void WebView2_NavigationCompleted(object sender, Microsoft.Web.WebView2.Core.CoreWebView2NavigationCompletedEventArgs e)
3861
{
39-
if (navto.Contains("youtube.com/watch?v=") || navto.Contains("youtu.be/"))
40-
{
41-
System.Diagnostics.Debug.WriteLine("Detected need to trigger fullscreen on YouTube");
42-
YouTubeFullscreen();
43-
}
44-
if (navto.Contains("shadertoy.com/view/"))
4562
{
46-
System.Diagnostics.Debug.WriteLine("Detected need to trigger fullscreen on ShaderToy");
47-
ShaderToyFullscreen();
63+
64+
if (navto.Contains("shadertoy.com/view/"))
65+
{
66+
System.Diagnostics.Debug.WriteLine("Detected need to trigger fullscreen on ShaderToy");
67+
ShaderToyFullscreen();
68+
}
69+
if (navto.Contains("youtube.com/embed/"))
70+
{
71+
YouTubeFullscreen();
72+
}
4873
}
4974
}
5075

5176
private async void YouTubeFullscreen()
5277
{
53-
await WebView.InvokeScriptAsync("eval", new string[] { @"document.getElementsByClassName('ytp-fullscreen-button')[0].click();" });
54-
55-
await WebView.InvokeScriptAsync("eval", new string[] { @"document.getElementsByClassName('html5-main-video')[0].loop = true;" });
78+
await WebView2.ExecuteScriptAsync("document.getElementsByClassName('ytp-large-play-button')[0].click();");
79+
80+
await WebView2.ExecuteScriptAsync("document.getElementsByClassName('ytp-fullscreen-button')[0].click();");
5681

82+
await WebView2.ExecuteScriptAsync("document.getElementsByClassName('ytp-mute-button')[0].click();");
83+
84+
await WebView2.ExecuteScriptAsync("document.getElementsByClassName('html5-main-video')[0].loop = true;");
85+
86+
5787
System.Diagnostics.Debug.WriteLine("Tried and probably failed to make YouTube fullscreen and looping");
5888
}
5989

6090
private async void ShaderToyFullscreen()
6191
{
62-
await WebView.InvokeScriptAsync("eval", new string[] { "myFullScreen.click();" });
63-
//await WebView.InvokeScriptAsync("eval", new string[] { "document.getElementsByClassName('uiButton')[5].click();" });
92+
await WebView2.ExecuteScriptAsync("myFullScreen.click();");
6493
System.Diagnostics.Debug.WriteLine("Tried and probably failed to make ShaderToy fullscreen");
6594
}
95+
96+
private void WebView2_CoreWebView2Ready(object sender, System.EventArgs e)
97+
{
98+
System.Diagnostics.Debug.WriteLine("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
99+
Potato();
100+
}
66101
}
67102
}

ActiveDesktop/ActiveDesktop.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,8 @@
274274
<PackageReference Include="Hardcodet.NotifyIcon.Wpf">
275275
<Version>1.0.8</Version>
276276
</PackageReference>
277-
<PackageReference Include="Microsoft.Toolkit.Wpf.UI.Controls.WebView">
278-
<Version>6.1.2</Version>
277+
<PackageReference Include="Microsoft.Web.WebView2">
278+
<Version>0.9.579-prerelease</Version>
279279
</PackageReference>
280280
<PackageReference Include="Microsoft.Windows.SDK.Contracts">
281281
<Version>10.0.18362.2005</Version>

ActiveDesktop/MainWindow.xaml.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
using DesktopBridge;
2020
using Windows.ApplicationModel;
2121
using System.Threading.Tasks;
22-
using Microsoft.Toolkit.Win32.UI.Controls.Interop.WinRT;
2322

2423
namespace ActiveDesktop
2524
{
@@ -1267,7 +1266,7 @@ private void PinApp(string hwnd)
12671266
}
12681267

12691268
// Actually deals with window properties or smth idk
1270-
async void WindowFromListToDesktop(App i, int t)
1269+
private void WindowFromListToDesktop(App i, int t)
12711270
{
12721271
try
12731272
{
@@ -1314,7 +1313,8 @@ async void WindowFromListToDesktop(App i, int t)
13141313
{
13151314
try
13161315
{
1317-
IntPtr hweb = await StartWebWallpaper(i.Flags);
1316+
ADPWebWallpaper GeneratedWebWallpaper = new ADPWebWallpaper(i.Flags);
1317+
IntPtr hweb = new WindowInteropHelper(GeneratedWebWallpaper).Handle;
13181318
System.Diagnostics.Debug.WriteLine(hweb.ToString());
13191319
Thread.Sleep(Convert.ToInt32(t));
13201320
LogEntry("[ADP] Started web window");

0 commit comments

Comments
 (0)