Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to run Chrome Extension
#1
hi wila.
Nice to visit you again after a long time.
I am always grateful for good components.

But after a long time, I ask again.
When I open a site
Chrome Extension [Google Translate]
I want to drive

By default, extensions are installed in Antview.
Please tell me how to drive it.

Since I am Korean, I have a lot of access to overseas websites.
Also, it is very inconvenient to do any work with the page source.

For example Chinese, English, Japanese Source of these pages
To reprocess the materials to suit me
It will take a lot of time.

That's why I started
With [Google Translate] running
I want to open a specific site and import its translated source.
Is it possible? I'd really appreciate it if you could tell me how.
HeartThankyou.
Reply
#2
Hi,

Thank you for your question.

At this moment, WebView2 itself does not have extension support.
See also:
https://github.com/MicrosoftEdge/WebView.../issues/98
and
https://github.com/MicrosoftEdge/WebView...issues/191

From what I understand, Microsoft is working on adding support for extension support, but there does not appear to be a time line.
As WebView2 itself does not yet have extension support, there's not much for AntView to expose in that regard.

But you are looking for a feature that might be possible to get working without using an actual extension as google has a web only version by visiting their translate website.
So I figured to go to the https://translate.google.com website. Entered the url https://antview.dev and suggested to the translate site to translate from English to Dutch.

This then returns the following URL to use:
https://antview-dev.translate.goog/?_x_t...r_pto=wapp

I then opened the URL from above in AntView and looked what the output is of the RequestCurrentText method in the Document interface. The output of that was translated to Dutch for about half the page. The rest showed up in English.
So it looks like that google is translating on the spot, if it isn't rendered.. it isn't getting translated.
Paging down through the page and calling the RequestCurrentText again did deliver better results.

But as you can see.. it still isn't perfect as some html seeped through as well.
This would have to be addressed either at javascript level or when post processing the content.

FWIW, you could create your own version of RequestCurrentText by running the following javascript:

Code:
document.body.textContent;


followed by passing the result of that tidbit of javascript through DecodeJsonObjectString

Hope this helps,
--
Wil
Reply
#3
aha. It wasn't easy.
But as always, thanks for the detailed help.
For reference, I'll try.
HeartThankyou.
Reply
#4
I want to try some tricks.
by any chance
In the <body> area when html is loaded between others
as defined by me
Script source to innerhtml, etc
Can I insert it?

My own JavaScript source
Is there a way to insert it
Please let me know if there is a way.

Reference source:
https://www.w3schools.com/howto/howto_go...nslate.asp
HeartThankyou.
Reply
#5
Hi,

Yes, of course you can.

Taking the example from w3schools that you attached I went to the VB6 browser demo form and added a new button to the form called "AutoTranslateButton" and put the following code in the OnClick event.

Code:
Private Sub AutoTranslateButton_Click()
  Dim sEle As String
  Dim jScript As String
  sEle = "const tempDiv = document.createElement('div');" & vbCrLf
  sEle = sEle & "tempDiv.id = 'google_translate_element'" & vbCrLf
  sEle = sEle & "document.body.insertAdjacentElement('afterbegin',tempDiv);" & vbCrLf
  EdgeWebBrowser.ExecuteScript (sEle)
  jScript = "" & vbCrLf
  jScript = jScript & "function googleTranslateElementInit() {" & vbCrLf
  jScript = jScript & "new google.translate.TranslateElement({pageLanguage: 'en'}, 'google_translate_element');" & vbCrLf
  jScript = jScript & "}" & vbCrLf
  EdgeWebBrowser.ExecuteScript (jScript)
 
  sEle = "const tempScript = document.createElement('script');" & vbCrLf
  sEle = sEle & "tempScript.type = 'text/javascript'" & vbCrLf
  sEle = sEle & "tempScript.src = '//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit'" & vbCrLf
  sEle = sEle & "document.body.insertAdjacentElement('beforeend',tempScript);" & vbCrLf
  EdgeWebBrowser.ExecuteScript (sEle)
End Sub

and that worked for me.

Navigating to the antwise.com website, then clicking the "Translate" button nicely inserted the google translate feature into the page.

   

Hope this helps,
--
Wil
Reply
#6
Thanks again for the really kind reply.
But in https://world.taobao.com
It's sad because it doesn't work.
It seems that the page source is complicated.
But good sincere thanks.
HeartThankyou.
Reply
#7
Hi,

Strange as it works for me on that page? (see the screenshot below, note that you have to be logged in to see the screenshot)
Probably something has gone wrong when copying the code.

   

If you still have problems then I can attach the code if needed.

Also note that you can test this type of thing in developer tools (Function key F12 when in the browser control), the screenshot here is from MS Edge, but you can do the exact same thing in AntView after pressing F12.
 
   

You can diagnose things that way when writing custom scripts.
See also: https://doc.antview.dev/hs191.htm

--
Wil
Reply
#8
Administrator, if you change Taobao to Korean instead of English,
Can you send me the converted picture?

I only partially translate. (pictured above)
Normal full translation (picture below)
   
Reply
#9
Hi,

I see the same as you.
This looks like it is an issue with the google translate button, or the translation service in general.

There's also issues if I go to a normal browser and stick the https://world.taobao.com URL directly in https://translate.google.com and set the translation button to Korean. The page is missing a lot of details.
eg.
https://world-taobao-com.translate.goog/...r_pto=wapp

--
Wil
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)