Group Group Group Group Group Group Group Group Group

Android Tutorial for GeckoView: Getting Started | raywenderlich.com

In thus tutorial you’ll learn about GeckoView, an open source library that allows you to render web content on Android using the Gecko web engine.


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/1381698-android-tutorial-for-geckoview-getting-started

Hi Arturo, Thanks for the in-depth article. Does geckoview support injecting custom JS , like Android Webview? (e.g. https://medium.com/@filipe.batista/inject-javascript-into-webview-2b702a2a029f)](

thanks in advance

Hi @weprofit,
Yes, it does. You can do it using WebExtensions, you can find more information about how to use it on GeckoView here.

If you have any additional questions please let me know :slight_smile:

Thanks for pointing me in the right directions. Content Script is a static JS file included in the build. How do I pass a parameter/variable to it?

My use-case is as follows- I want user to specify a word, and when i show the webpage in Geckoview, I want to highlight the word occurrence in the page . How to I pass this word_to_higlight variable to my content script?

thanks again in advance.

Hi @weprofit sorry for the delay,
As the documentation describe the web extension allows bidirectional communication, you can send a message from Kotlin/Java to JavaScript and viscera. Take a look at the section “Communicating with Web Content” under the web extension documentation. There you can find some examples of how to pass some parameter/variables from one side to another. Here you can find a more in-depth example of the Reader view functionality.

If you want to mimic the find in page functionality, GeckoView provides a build-in API for that take a look at GeckoSession.getFinder(), you can find some examples of usages here.

Hope this answer helps you, if you need any additional help please let me know, I’m glad to help.

I just saw this tutorial https://sammacbeth.eu/blog/2019/09/04/geckoview-extensions.html this could be also helpful!

Hi, im getting the Secure Connection Failed, it is because bad cert or something, you know how to handle this? in firefox there is a option to continue, thanks

Hi @amejia481,
I am trying to implement Javascript using Web Extension in GeckoView.
Can you please help me out with my code.

https://github.com/ankitrawat46/GeckoJavascript

Here i need to just change the colour of some elements on the webpage using javascript.
Thanks

Hi @ismalel,
This is a work in progress.
Bypass certificate error pages -> https://bugzilla.mozilla.org/show_bug.cgi?id=1553265
Import custom certificates -> https://bugzilla.mozilla.org/show_bug.cgi?id=868370

Hi @ankitrawat46 I have to catch a flight today, but I can take a look over the weekend!

Thanks @amejia481 Will wait for your update.

Hi @ankitrawat46 I opened a PR responding to your request https://github.com/ankitrawat46/GeckoJavascript/pull/1

The code is functional and I added some details about why it wasn’t working, if you have any additional questions please let me know happy to help :slight_smile: !

Hi @amejia481 Thanks for the help.
I have one question, If i want to change the class name 'infobox' in JS during runtime depending on the next page it opens.

document.getElementsByClassName('$myString')

In this case, you have to send a message from the app to the JS and which contains the name of the class that you want to replace, you could follow this section where it explains how to send a message from the app to the JS https://mozilla.github.io/geckoview/consumer/docs/web-extensions#connection-based-messaging