Ajax on Chrome Extension Uninstall - ajax

I need to run an AJAX query to clean up my database when my Chrome extension is uninstalled. The chrome.management.onUninstalled function is for all installed extensions and I don't want to create a solution that uses it because it requires a special permission.
How do I detect when only my extension is uninstalled.

Related

Chrome Extension Issue in UiPath Robot Only

I am facing the chrome extension issue. The following is the issue:
“UiPath.Core.BrowserOperationException: Cannot communicate with the browser, please check the UiPath extension”
I have UiPath Robot only so I cannot install extension from Studio. I am running the package from the tray.
Things I did to solve the issue by myself:
Removed extension and installed again (multiple times).
Cleared browsing data before execution.
Update the package few times.
Restarted my machine.
It's not clear whether you have installed the extension from the Chrome web store, but it is preferable to install the extension using the following command:
C:\Program Files\UiPath\Studio\UiPath\SetupExtensions.exe /chrome
This will work without having Studio installed. Also bear in mind that if you are launching Chrome in Incognito, you will need to explicitly allow the extension in Incognito by going to the following URL in Chrome:
chrome://extensions/
Choose "Details" on the UiPath extension, and "Allow in Incognito".
Further information can be found here: Extension for Chrome
Try this.
1 Use the StartProcess to start Internet explorer exe file from program files.
2 Send Url as argument eg “www.abc.com”
3 Use on element appear to check if the home page is loaded.
4 Attach browser and use the browser variable to pass to other workflows.

Install a personal firefox web extension permanently

Previously, I could write an addon for personal usage packed as something.xpi and I clicked on it to install it.
After a while, mozilla introduced xpinstall.signatures.required which you could still get around it.
However, it did not stop stabbing developers who are interested to have a personal addon isolated from the world. Today, only web extensions are working and my XUL based addon is thrown away. The tutorials only talk about temporary installation of a web extension while I want my one runs on firefox forever.
Beside whether I can use web extension to write into files or create a GUI in an independent page, I have a bigger challenge:
How can I install a local web extension permanently without creating a Mozilla account for personal usage?
Navigate to the folder where your extension is located. You can build it in the usual way using web-ext:
web-ext build
You can install this ZIP file permanently in Firefox by going to about:addons and dragging this file into the tab.
In order for this to work, you need to set xpinstall.signatures.required to false in about:config (works only for Nightly and maybe Developer Edition).
Apart from setting xpinstall.signatures.required to false, you need to add this to your manifest.json:
"browser_specific_settings": {
"gecko": {
"id": "some-name#example.org"
}
}
Found on https://www.reddit.com/r/firefox/comments/blqffs/how_to_permanently_add_temporary_addon/exh2u3o/, thanks to "alexherbo2".
You need a "blueish" Firefox -- Developer Edition (effectively beta) or Nightly (unstable, updated every night).
You can get them from https://mozilla.org/firefox/channel/desktop/.
Then xpinstall.signatures.required will work again.
(As for permissions--you can create a GUI in a tab or a popup, but I don't think you can do it in a separate window (unless you do a webpage-style popup window). You won't be able to write to arbitrary files anywhere on the system--which is a good thing! You can write to the Downloads folder, and read/write some sort of internal storage, but that may not expose the actual files involved. For more information see https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Working_with_files.)
What you should be looking for is having your extension signed by Mozilla as Unlisted.
See Mixing Listed and Unlisted Add-ons on addons.mozilla.org blog post for an overview.
That way, AMO does not host nor (normally) review your extension; it simply runs some basic automated checks and immediately signs your extension so that it can be privately distributed as an XPI.
For those interested in developing/running an extension from a local directory without having to package or load it manually via "Load Temporary Addon..." from about:debuggin#/runtime/this-firefox please go to this github repository.
From the README.md:
The procedure involves a few steps, but it needs to be done only once.
First you need to enable AutoConfig aka userchrome.js by copying the file config-prefs.js to [Your Firefox install directory]/defaults/pref
Note: For best security, on Windows it is best to leave your Firefox install in "c:\Program Files" so that your config-prefs.js and userChrome.js can only be modified when you are in root/admin mode.
Then you need to edit the file userChrome.js and modify the function installUnpackedExtensions() to reflect the locations of your own addons.
The modified userChrome.js then must be copied to your Firefox installation directory. For example on Windows this is usually "c:\Program Files (x86)\Mozilla Firefox" for the 32-bit version of Firefox. You can rename the file, but remember to modify the corresponding line pref("general.config.filename", "userChrome.js") in defaults/pref/config-prefs.js
Now your addons from your local directories will be loaded automaticaly whenever Firefox starts. After editing your code remember to reload it from about:debuggin. You can also get there via the menu by selecting "More Tools", then "Remote Debugging", and click on "This Firefox" on the left side (but the quickiest way is to bookmark it and then add a bookmark keyword such as "dbg" for quick access.)
Please note that this is an automated install of the extension every time Firefox starts, so it is not quite the same as a "permenent install". That is, this procedure has exactly the same effect as clicking on "Load Temporary Addon..." from the about:debuggin page, just that the process is now automated via userChrome.js. This means that if you have code that does something after the installation of the extension such as browser.runtime.onInstalled.addListener(details => { if (details.reason == "install") { ...do something after install... }); then this code will be called every time Firefox is launched.
You can try setting the preference extensions.legacy.enabled (this will only work in Nightly or Dev Edition).

Better way to prevent Firefox add-on variables values to wipe out on browser close? Getting error to use "io/text-streams" module

I want to save user settings for my firefox add-on in a variable which can be accessible any time I want. It should not get vanished on browser clos. Now how can I do it?
I have tried "simple-storage" module of firefox, it works fine until I quit my browser. When I quit my browser, "simple-storage"s wipes out. So I can't use it.
I have also tried "io/text-streams" module but when I try to use this module in "firefox add-on builder"
var io = require("io/text-streams");
io.write("write it");
I am getting this error:
XPI not built
ModuleNotFoundError: unable to satisfy: require(io/text-streams) from /tmp/tmpePRdMr/addon-sdk-1.12/packages/sadaf2605-4/lib/main.js:2: Looked for it in: /tmp/tmpePRdMr/addon-sdk-1.12/packages/sadaf2605-4/lib/io/text-streams.js /tmp/tmpePRdMr/addon-sdk-1.12/lib/io/text-streams.js
Most probably, I would need to install some packages, do the user who will be using my add-on, do they also need to install those packages on their browser?
Apparently you are testing your add-on with cfx run. The documentation explains why simple-storage appears broken and how to solve it.
Try saving your settings in localStorage object (HTML5) .Your values wont vanish after the session is closed ......

Details of the Firefox add-on installation procedure

I am curious about the inner workings of the Firefox add-on installation procedure. I have noticed that the following steps take place when user installs an add-on from addons.mozilla.org:
The add-on is downloaded (probably in a temporary folder).
An installation confirmation dialogue box pops up ("install add-ons from authors you trust").
Upon clicking install, the add-on is stored in the /extensions/staged folder. Along with the add-on, there is also a JSON file like this: addon_id.json.
Firefox prompts the user to restart the browser.
After restart, the contents from the /extensions/staged/ folder are moved to the /extensions/ folder.
What I would like to know is:
Which code portion in the Firefox source code is responsible for step 5? I am assuming some c++ or js code or some xpcom module is responsible for figuring out that an add-on is waiting to be installed in the staged/ folder, and performs the necessary steps (moving the files, registering the add-on etc.). Can anyone please point me to that module/code?
Where is the add-on stored temporarily, when it is downloaded (step 1)?
Basically, I would like to alter some files after an add-on is downloaded at step 1, but before it becomes part of the browser (step 5). I want to add this functionality in the Firefox source code.
You analysis is mostly correct, it merely leaves out bootstrapped extensions. Bootstrapped extensions don't require a browser restart, they will be moved out of the staged directory and activated immediately.
The Add-on Manager is all JavaScript starting with Firefox 4. The important files are amWebInstallListener.js (the component handling add-on installations from the web), AddonManager.jsm (the generic add-on management API) and XPIProvider.jsm (the provider for XPI-packaged extensions).
extWebInstallListener.onWebInstallRequested() gets called with a bunch of AddonInstall instances (defined in XPIInstall.jsm) and creates an Installer instance that calls AddonInstall.install() for each of the installs. The downloads go into a temp file determined by getTemporaryFile() in XPIProvider.jsm (tmp-foo.xpi in the OS-specific temp directory).
Installer.checkAllDownloaded() determines that all downloads finished and displays a modal confirmation dialog (URI_XPINSTALL_DIALOG).
AddonInstall.startInstall() moves the add-on into the staging directory. Bootstrapped add-ons will be immediately installed after that. For other add-ons it continues to step 4.
onInstallEnded listeners are triggered - one of them shows the message that the browser needs to be restarted.
After a browser restart XPIProvider.startup() calls XPIProvider.checkForChanges() calls XPIProvider.processPendingFileChanges().

Calling Firefox XPCOM from external app?

Context: we need to read Firefox cookies in our app; until Firefox 3.5, this was possible by reading cookies.txt / cookies.sqlite. In Firefox 3.5, it exclusively locks the cookie file so outside apps can't read it (see https://bugzilla.mozilla.org/show_bug.cgi?id=476167), and even if we make a local copy, FF doesn't always flush the cookies to disk until exit so they may not be there.
The suggested solution is to use nsICookieManager, which looks like what we need -- but how can I get at one of those from a process that isn't Firefox?
Everything I see about XPCOM suggests I can only use it from firefox extensions -- do we have to write an extension, and then somehow invoke Firefox to install our extension and then somehow invoke the extension itself to pass cookies back out?
Yes - you'll have to build an extension which communicates from your application to Firefox. You can install the add-on with the windows registry (assuming you are on windows).

Resources