Created
June 18, 2023 19:16
-
-
Save jscher2000/8a9112b1c03af77f6b3b63b1296bd864 to your computer and use it in GitHub Desktop.
Add handler for Firefox via Browser Console - Yahoo! Mail example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Add Handler via Firefox Browser Console -- mailto: Yahoo! Mail | |
NOTE: BEFORE YOU CAN RUN THIS SCRIPT, IF YOU HAVEN'T ALREADY: | |
* Type or paste about:config into the address bar and press Enter | |
* Click the button promising to be careful | |
* In the search box type devt and pause while Firefox filters the list | |
* If devtools.chrome.enabled is false, double-click it to toggle to true | |
Paste this entire script into the command line at the bottom of the Browser Console (Windows: Ctrl+Shift+j) | |
Then press Enter to run the script. A dialog should pop indicating whether the save was successful. | |
*/ | |
// User-supplied values for the new handler: | |
var handlerprotocol = 'mailto'; | |
var handlername = 'Yahoo! Mail 2023'; | |
var handlerurl = 'https://compose.mail.yahoo.com/?to=%s'; | |
/* Code to add the new handler, derived from | |
https://searchfox.org/mozilla-release/source/browser/components/protocolhandler/WebProtocolHandlerRegistrar.sys.mjs#133 | |
as of 2023-06-18 | |
*/ | |
var handler = Cc["@mozilla.org/uriloader/web-handler-app;1"].createInstance(Ci.nsIWebHandlerApp); | |
handler.name = handlername; | |
handler.uriTemplate = handlerurl; | |
var eps = Cc["@mozilla.org/uriloader/external-protocol-service;1"].getService(Ci.nsIExternalProtocolService); | |
var handlerInfo = eps.getProtocolHandlerInfo(handlerprotocol); | |
handlerInfo.possibleApplicationHandlers.appendElement(handler); | |
handlerInfo.alwaysAskBeforeHandling = true; | |
var hs = Cc["@mozilla.org/uriloader/handler-service;1"].getService(Ci.nsIHandlerService); | |
try { | |
hs.store(handlerInfo); | |
alert('Assuming not a duplicate, it should be saved now. Reload Settings page to see updated list.'); | |
} catch(err) { | |
alert('Error during saving: '+err); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment