Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove Chrome extension via code

I have created a Chrome application. When the user adds it to the Chrome browser, a form is opened as a part of the installation. I want to delete the added extension when the installation is not done correctly.

How do I trigger deletion of a Chrome extension?

like image 953
Milind Anantwar Avatar asked Jun 06 '13 07:06

Milind Anantwar


People also ask

How do I remove extensions from Chrome registry?

Click “Edit,” then “Find Next” to locate any other registry entries containing the extension's ID and then delete them as well. You can now close Registry Editor and restart Chrome. Head back to chrome://extensions and click the “Remove” button inside the extension you want to remove.


3 Answers

An extension can remove itself by calling chrome.management.uninstallSelf();.

If your extension wants to remove another extension, declare the management permission in the manifest file and call chrome.management.uninstall('<id of other extension>');.

You cannot uninstall an extension from the command line any more as of Chrome 36.0.1960.0 (using --uninstall-extension, crbug 351294).

like image 193
Rob W Avatar answered Oct 10 '22 13:10

Rob W


If anyone is looking for an alternative to --uninstall-extension, here is a try: sadly this doesn't work from command line, but you can be used to programmatically do stuff with extensions.

manifest.json

{
  "manifest_version": 2,
  "name": "Uninstaller",
  "version": "1.0",
  "description": "Uninstalls hardcoded extensions.",
  "permissions": [ "management" ],
  "browser_action": { },
  "background": { "scripts": ["background.js"] }
}

background.js

chrome.browserAction.onClicked.addListener(function(tab) {
  chrome.management.uninstall('ckibcdccnfeookdmbahgiakhnjcddpki');
  chrome.management.uninstallSelf();
});

Usage

  1. Save the above two files to a new folder
  2. Change the ID of the extension you want to uninstall in background.js
  3. Open chrome://extensions (or Menu > Settings > Extensions)
  4. Tick Developer mode
  5. Click Load unpacked extension
  6. Browse the folder you saved the files to
  7. Click the new icon that appears next to the hamburger menu
    in the top right corner (puzzle piece)
  8. Untick Developer mode
  9. Delete the folder with the two files
like image 20
TWiStErRob Avatar answered Oct 10 '22 13:10

TWiStErRob


Let's say you really, really need to do this from the command line, and only the command line, or from another system far far away entirely. Somehow that situation keeps coming up for people... can't imagine why.

In my case, I came across an extension that actually prevented me from opening chrome://extensions. O.O

This meant that I could not use most of the other answers on this page without some serious forethought.

Anyway, if you're one of those unlucky folks somehow limited to good old bash, zsh, ncurses, whatever, something like the following might help as a starting point:

I just used the following method to ditch an evil extension in Chromium Version 51.0.2704.79 on an Ubuntu 14.04 (64-bit) system: 
% sudo add-apt-repository ppa:pgolm/the-silver-searcher
% sudo apt-get update
% sudo apt-get install the-silver-searcher  ## Add a searcher tool
% cd ~/.config/chromium/Default/Extensions  ## Go to the default folder for Chromium Extensions.
% ls -rolath  ## List the contents in order of most recently modified.
total 16K
drwx------  3 fu 4.0K Sep  4 20:45 gcbombkclmclpchdgiimedpiimgmedia
drwx------  3 fu 4.0K Sep  4 20:45 bilkyoucmkafdfolokijcfjliaokphfk
drwx------  3 fu 4.0K Sep  5 13:56 leniggcoacklhapakkkcpdbppfkghcmi
drwx------  3 fu 4.0K Sep  5 14:37 fvuckkukegcagdloljackdonpwnmedph
%  ## Looks like we have two suspicious candidates, here, to possibly delete. 
% aptitude search silversearcher ; aptitude install silversearcher-ag ## - very fast grep-like program, altenative to ack-grep
% ag --literal "adclick" ; ag --literal "_trackPageview" ; ag --literal "hijack" ## Etc. I did a bunch of 
     ## separate little searches 
     ## until I found the item that 
     ## looked like it was installed 
     ## most recently and had the 
     ## most suspicious keywords. 
% ag --literal '"version": "' | grep leniggcoacklhapakkkcpdbppfkghcmi  
    ## The above line finds the versions 
    ## of the extension to which I took offense.
% rm -rf leniggcoacklhapakkkcpdbppfkghcmi  
    ## Remove the files for the extension 
    ## to which I took offense.

I then started Chromium, happily went along to my chrome://extensions link, looked at the version information for the few most recently installed extensions, compared them to the output I found from ag --literal '"version": "' | grep leniggcoacklhapakkkcpdbppfkghcmi, and clicked the little trash can button next to that extension.

joy at last

Hope that gives you some ideas. It worked for me. I found that out mostly by guesswork and searching on http://duckduckgo.com. Your results may vary, which is good!

like image 44
Nathan Basanese Avatar answered Oct 10 '22 14:10

Nathan Basanese