• 07-11-2022, 23:43:15
    #1
    Merhaba arkdaşlar
    sarı ile belirttiğim yere
    bu linkte bulduğum https://learn.microsoft.com/en-us/do...et-1.0.1418.22

    kodu eklemek istiyorum nasıl yazmam gerekiyor çalıştıramadım yardımcı olabilecek varsa sevinirim..





    using Microsoft.Web.WebView2.Core;
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;

    namespace ProdemandAuth
    {
    public partial class Browser : Form
    {
    public Browser(Main MainForm)
    {
    InitializeComponent();
    this.MainForm = MainForm;
    }

    private const bool V = true;
    private const bool V1 = true;
    Main MainForm;

    public object targetCompatibleBrowserVersion { get; private set; }

    private async void Browser_Load(object sender, EventArgs e)
    {
    webView21.Enabled = false;
    CoreWebView2EnvironmentOptions Options = new CoreWebView2EnvironmentOptions();
    Options.AdditionalBrowserArguments = "--proxy-server=http://" + MainForm.myconfig.ip + ":" + MainForm.myconfig.port;
    CoreWebView2Environment env = await CoreWebView2Environment.CreateAsync(null, null, Options);
    await webView21.EnsureCoreWebView2Async(env);
    webView21.CoreWebView2.BasicAuthenticationRequeste d += CoreWebView2_BasicAuthenticationRequested;
    webView21.CoreWebView2.Settings.AreBrowserAccelera torKeysEnabled = true;
    webView21.CoreWebView2.Settings.AreDefaultContextM enusEnabled = true;
    webView21.CoreWebView2.Settings.AreDefaultScriptDi alogsEnabled = true;
    webView21.CoreWebView2.Settings.AreDevToolsEnabled = true;
    webView21.CoreWebView2.Settings.AreHostObjectsAllo wed = true;
    webView21.CoreWebView2.Settings.IsBuiltInErrorPage Enabled = true;
    webView21.CoreWebView2.Settings.IsScriptEnabled = true;
    webView21.CoreWebView2.Settings.IsStatusBarEnabled = true;
    webView21.CoreWebView2.Settings.IsSwipeNavigationE nabled = true;
    webView21.CoreWebView2.Settings.IsZoomControlEnabl ed = true;
    webView21.CoreWebView2.Settings.IsWebMessageEnable d = true;
    webView21.CoreWebView2.Settings.IsBuiltInErrorPage Enabled = true;
    webView21.CoreWebView2.Settings.IsGeneralAutofillE nabled = true;
    webView21.CoreWebView2.Settings.IsPasswordAutosave Enabled = true;

    webView21.CoreWebView2.DOMContentLoaded += CoreWebView2_DOMContentLoaded;
    webView21.CoreWebView2.CookieManager.DeleteAllCook ies();
    MainForm.data["cookies"].ToList().ForEach(x => {
    webView21.CoreWebView2.CookieManager.AddOrUpdateCo okie(webView21.CoreWebView2.CookieManager.CreateCo okie(x["Name"].ToString(), x["Value"].ToString(), x["Domain"].ToString(), x["Path"].ToString()));
    });
    webView21.CoreWebView2.Navigate("https://workshop.autodata-group.com/login?destination=node");
    }

    private void CoreWebView2EnvironmentOptions(string v1, object p1, string v2, object v3, string v4, object v5, bool v6, object p2)
    {
    throw new NotImplementedException();
    }

    private void CoreWebView2EnvironmentOptions(string v1, object p1, string v2, object p2, string v3, object p3, bool v4, object p4)
    {
    throw new NotImplementedException();
    }

    private void CoreWebView2_BasicAuthenticationRequested(object sender, CoreWebView2BasicAuthenticationRequestedEventArgs e)
    {
    e.Response.UserName = MainForm.myconfig.user;
    e.Response.Password = MainForm.myconfig.pass;
    }

    private async void CoreWebView2_DOMContentLoaded(object sender, CoreWebView2DOMContentLoadedEventArgs e)
    {
    webView21.Enabled = true;
    foreach (string rule in MainForm.myconfig.rules)
    {
    await webView21.CoreWebView2.ExecuteScriptAsync(@"(funct ion(){
    var elements = document.querySelectorAll(""" + rule + @""");
    if(elements.length != 0){
    elements[0].remove();
    }
    })();");
    }
    }

    private void Browser_FormClosed(object sender, FormClosedEventArgs e)
    {
    MainForm.Show();
    }
    }
    }
  • 07-11-2022, 23:44:35
    #2
    Ne yapmaya calisiyorsunuz tam olarak
  • 07-11-2022, 23:44:57
    #3
    belkide çalışması için başka bir satıra eklemem gerekiyordur bilmiyorum benim için bu kod nasıl düzgün çalışır o yeterli eğer yardımcı olabilirseniz..

    Letosprit adlı üyeden alıntı: mesajı görüntüle
    Ne yapmaya calisiyorsunuz tam olarak
    bu kod ile açtığım programımda sağ clik yaptığınızda sayfayı türkçe diline çevir seçeneği gelmiyor

    bu kod ile o seçeneğin geleceğini öğrendim ama ekleyemedim kodu