Domanda

I've been using Crossrider's great API for some time now, however I have reached a great block in my progress.

I have been able to message the popup scope with the current domain through the tab change interrupts and the change of url interrupts. However, when I click the popup browser button, data about the current tab URL is supposed to be shown. Instead, such data is black, and when debugging - it was found that the reason for it being blank is either:

  • The current URL is being set to the popup extension internal URL
  • Some sort of bug with the popup logic

I am really stumped, and require such functionality to progress further. My Crossrider ID is 52909.

Thanks!

È stato utile?

Soluzione

First and foremost, when posting questions to this forum please include code snippets for the benefit of others so that they can try an assist you. As-is they have no access to the extension code you provided.

Looking at your popup.html code, I can see that you are using the following Crossrider API methods that are not supported in the popup scope: appAPI.resources.includeJS, appAPI.webRequest.onRequest. For more information about API supported in the popup scope, see appAPI.browserAction.setPopup.

As alternatives/workarounds:

  • For appAPI.resources.includeJS, you can use the jquery to load resources scripts, as follows: $.globalEval(appAPI.resources.get('script.js'));

  • For appAPI.webRequest.onRequest, implement it in the background scope and use messaging to pass the data to the popup scope, something like:

background.js:

appAPI.ready(fucntion($) {
  appAPI.webRequest.onRequest.addListener(function(details, opaqueData) {
    appAPI.message.toPopup(details);
  }, []);
});

crossriderMain in popup.html:

function crossriderMain($) {
  appAPI.message.addListener(function(details) {
    // Do something with the details from webRequest
  });
}

[Disclosure: I am a Crossrider employee]

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top