title: Implement GeckoView Web Extension
body: <p>I'm trying to implement a noddy web extension for GeckoView in Android to simply execute some javascript on a web page, the equivalent of webView.evaluateJavascript() on a normal Android WebView, however I'm having trouble finding any useful examples or tutorials online.</p>
  
  <p>I have previously tried a WebView before, however the site I am attempting to access bugs during login meaning I cannot access it. However the login works with a GeckoView</p>
  
  <p>I've followed these so far: </p>
  
  <ol>
  <li><p><a href="https://sammacbeth.eu/blog/2019/09/04/geckoview-extensions.html" rel="nofollow noreferrer">https://sammacbeth.eu/blog/2019/09/04/geckoview-extensions.html</a></p></li>
  <li><p><a href="https://mozilla.github.io/geckoview/consumer/docs/web-extensions" rel="nofollow noreferrer">https://mozilla.github.io/geckoview/consumer/docs/web-extensions</a></p></li>
  <li><p><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Your_first_WebExtension" rel="nofollow noreferrer">https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Your_first_WebExtension</a></p></li>
  </ol>
  
  <p>However, they seem to be a bit dated, even mozilla's own documentation, as the API I am using no longer follows the examples.</p>
  
  <p>I'm using the stable release of GeckoView: 73.0.20200217142647</p>
  
  <p>As per [3] above, my file structure is:</p>
  
  <pre><code>java
   |
   +-- assets
   |   |
   |   +--checkExtension
   |      |
   |      manifest.json
   |      checkExtension.js
   |
   +-- res
   |
   +-- src
  </code></pre>
  
  <p>The contents of manifest.json is</p>
  
  <pre><code> {
  
    "manifest_version": 2,
    "name": "checkExtension",
    "version": "1.0",
  
    "description": "Automatically clicks the authorise button to continue the photo upload.",
  
    "content_scripts": [
      {
        "matches": ["*"],
        "js": ["checkExtension.js"]
      }
    ],
    "permissions": [
      "nativeMessaging",
      "geckoViewAddons"
    ]
  
  }
  </code></pre>
  
  <p>'matches' is set to '*' so that it should match any and all pages navigated to</p>
  
  <p>checkExtension.js just contains:</p>
  
  <pre><code>alert('hello')
  </code></pre>
  
  <p>My GeckoView activity is:</p>
  
  <pre><code>GeckoView view = findViewById(R.id.geckoview);
  GeckoSession session = new GeckoSession();
  GeckoRuntime runtime = GeckoRuntime.create(this);
  
  session.open(runtime);
  
  WebExtension test = new WebExtension(
      "resource://assets/extension/checkExtension/",
      runtime.getWebExtensionController());
  
  runtime.registerWebExtension(test);
  
  view.setSession(session);
  session.loadUri("https://www.google.com");
  </code></pre>
  
  <p>However, no alert is showing when the page loads. I have tried a few site-specific targeted scripts besides just attempting to show an alert box, however none of them have worked either.</p>
  
  <p>Is there anything obvious is am missing or any resources that might help me?</p>
  
  <p>Many Thanks.</p>