3

I ported an extension from Chrome to Microsoft Edge.The extension works properly in Chrome, but in Edge it has some issues.

One of these issues is that Edge does not support browser.alarms.

For Edge extensions, what are the alternatives to using browser.alarms?

Makyen
  • 31,849
  • 12
  • 86
  • 121
Tarun Talreja
  • 163
  • 1
  • 12
  • 1
    "not working" isn't a useful description of the problem, right? You need to debug it, check console for errors in the background page, popup, content script. Also, just changing `chrome` to `browser` won't work with callbacks since `browser` is Promise-based. – wOxxOm Jun 05 '17 at 12:28
  • But i am not able to check console for background.js and popup.js . I just can't see those files in the debugger . Can you tell me what all things should i change in my code?I have used browser.tabs.query,browser.extension.getBackgroundPage(),browser.alarms.create and browser.alarms.onAlarm.addListener – Tarun Talreja Jun 05 '17 at 13:20
  • See the [documentation](https://learn.microsoft.com/en-us/microsoft-edge/extensions/guides/debugging-extensions) you've linked. – wOxxOm Jun 05 '17 at 13:22
  • Please [edit] the question to be on-topic: include a [mcve] that duplicates the problem. For Chrome extensions or Firefox WebExtensions this almost always means including your *manifest.json* and some of the background, content, and/or popup scripts/HTML. Questions seeking debugging help ("why isn't this code working the way I want?") must include: (1) the desired behavior, (2) a specific problem or error and (3) the shortest code necessary to reproduce it *in the question itself*. Please also see: [What topics can I ask about here?](http://stackoverflow.com/help/on-topic), and [ask]. – Makyen Jun 05 '17 at 19:06
  • @Makyen I have edited the question to be on-topic . I have included the things not supported by edge which I was using in chrome extension . So I need to find alternatives for that,which I was not able to do. – Tarun Talreja Jun 06 '17 at 03:25
  • You really need to separate out, at least the different APIs into their own questions. Grouping them all in one question is too broad. It's not unreasonable to have the `alarm` ones grouped together, but those can be easily substituted by `setTimeout()`. – Makyen Jun 06 '17 at 05:10
  • @Makyen I know I should have made their own questions but I have reached my question limit so can not do that. – Tarun Talreja Jun 06 '17 at 10:43
  • Then edit this question to be a good question about one of them, not a bad question about them *and* anything else which is of issue with your "Edge Extension not working after porting from Chrome Extension". As it is, this question will most likely be closed. – Makyen Jun 06 '17 at 21:23
  • @Makyen I changed it a little bit . Is it correct now? – Tarun Talreja Jun 07 '17 at 03:10
  • @wOxxOm I have edited the question and I am not getting why my question is not getting any upvotes. I mean it is a good question after all for anyone who wants to create an Edge Extension . It would help them . I know my question asking style was not upto the mark and that is because I have not been able to cope up with the Stack Overflow environment and I am doing my best to do that . – Tarun Talreja Jun 08 '17 at 06:04
  • @TarunTalreja, I have significantly edited your question to make it reflect the self-answer which you have accepted, and make it closer to being narrow enough to be on-topic. If this is not acceptable to you, feel free to rollback the edit from the [question edit history page](https://stackoverflow.com/posts/44368904/revisions). – Makyen Jun 08 '17 at 18:07
  • @TarunTalreja, Regardless of the quality of the question, getting votes in relatively low traffic tags (e.g. [tag:google-chrome-extension] and [tag:microsoft-edge-extension]) is something that happens rarely. – Makyen Jun 08 '17 at 18:12
  • @Makyen thanks for the edit, it is good. – Tarun Talreja Jun 09 '17 at 03:28

1 Answers1

1

I did all the research and came to the conclusion that alarms can be replaced simply using the setTimeout function of JavaScript . The function written in browser.alarms.onAlarm.addListener should be written in the 1st parameter of setTimeout() function and currently for clearing the cache programmatically access to browser internal functionality is required which is currently not implemented in Microsoft Edge .

Tarun Talreja
  • 163
  • 1
  • 12