[GH-ISSUE #10] Original 'mailto' handler not called, if owaIntercept == "off" #6

Open
opened 2026-02-27 07:17:04 +03:00 by kerem · 1 comment
Owner

Originally created by @kriegaex on GitHub (Jun 19, 2022).
Original GitHub issue: https://github.com/jonroig/MailtOWA/issues/10

This code is always executed for mailto: links:
github.com/jonroig/MailtOWA@60caaab443/mailtowa.js (L18-L21)

Fetching the config value from chrome.storage.sync is inherently asynchronous, so I know it is difficult to fetch the config value and use it in a condition skipping those lines of code, if the user setting is "off", but this could be fixed by caching the configuration locally, also making sure that the cache is getting refreshed, using an event handler reacting to changes in chrome.storage.sync. I do not speak JS at all, but I think this is the way you handle such things in a language like this, trying to escape the infamous callback hell.

Originally created by @kriegaex on GitHub (Jun 19, 2022). Original GitHub issue: https://github.com/jonroig/MailtOWA/issues/10 This code is always executed for `mailto:` links: https://github.com/jonroig/MailtOWA/blob/60caaab4431b120c0cacaa41133b6e920635f6f4/mailtowa.js#L18-L21 Fetching the config value from `chrome.storage.sync` is inherently asynchronous, so I know it is difficult to fetch the config value and use it in a condition skipping those lines of code, if the user setting is `"off"`, but this could be fixed by caching the configuration locally, also making sure that the cache is getting refreshed, using an event handler reacting to changes in `chrome.storage.sync`. I do not speak JS at all, but I think this is the way you handle such things in a language like this, trying to escape the infamous _**callback hell**_.
Author
Owner

@kriegaex commented on GitHub (Jun 19, 2022):

Disclaimer: In my fork, I modified the extension to fit my needs for another type of web mailer. This is my very first try to write or modify any JS code, so probably the code is horrible. Of course, I also never wrote a Chrome extension.

You may want to refer to my content script in order to see how I am using localStorage as a cache for chrome.storage.sync. Maybe you want to do something similar. In my case, it solves the problem.

<!-- gh-comment-id:1159705775 --> @kriegaex commented on GitHub (Jun 19, 2022): _Disclaimer: In my fork, I modified the extension to fit my needs for another type of web mailer. This is my very first try to write or modify any JS code, so probably the code is horrible. Of course, I also never wrote a Chrome extension._ You may want to refer to [my content script](https://github.com/kriegaex/MailtoAllInklChromeExtension/blob/506b2dbc9d46517c7369c108c213487067e220d3/mailto.js) in order to see how I am using `localStorage` as a cache for `chrome.storage.sync`. Maybe you want to do something similar. In my case, it solves the problem.
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/MailtOWA-jonroig#6
No description provided.