9

I'm developing a Chrome extension and previously, to reload the new code, I would just go to chrome://extensions/ and hit CMD+R. Now this is not reloading the extension and I have to manually click (with a mouse!!!) on the CMD+R link.

This is quite annoying and not sure what were the reasons behind this change. Anyone knows of a workaround?

EDIT: Seems this was fixed in the recent Chrome versions.

Alex Plugaru
  • 2,209
  • 19
  • 26

3 Answers3

2

Ctrl+R being broken is a bug: https://code.google.com/p/chromium/issues/detail?id=526945

Until that bug is fixed, you could use any of the suggestions from How do I auto-reload a Chrome extension I'm developing? to reload extensions.

Community
  • 1
  • 1
Rob W
  • 341,306
  • 83
  • 791
  • 678
0

Huh, true. It used to work before. Note that this reloaded all extensions.

Anyway, there are plenty of extensions that will do that for you, e.g. this one or many others.

If you're interested in making your own solution, chrome.management API can do this.

Xan
  • 74,770
  • 16
  • 179
  • 206
  • The above extension doesn't work for me. It does the same Global CMD+R which doesn't actually work. Will have a look at chrome.management API – Alex Plugaru Oct 09 '15 at 19:20
0

Here is pretty simple extension that defined two shortcuts to reload all extensions: Ctrl+Shift+R and Alt+R. Unfortunately, we cannot redefine Ctrl+R.

manifest.json:

{
  "manifest_version": 2,
  "name": "Extensions Reloader",
  "short_name": "Extensions Reloader",
  "description": "",
  "version": "0.0.1",

  "permissions": [
    "<all_urls>",
    "tabs",
    "storage",
    "management",
    "http://*/*",
    "https://*/*"
  ],

  "commands": {
    "reload1" : {
      "suggested_key": {
        "default": "Ctrl+Shift+R"
      },
      "description": "Reload all extensions"
    },
    "reload2" : {
      "suggested_key": {
        "default": "Alt+R"
      },
      "description": "Reload all extensions"
    }
  },

  "browser_action": {
    "default_icon": {
      "19": "icon.png",
      "38": "icon.png"
    },
    "default_title": "Reload all extensions"
  },

  "background": {
    "persistent": false,
    "scripts": [
      "background.js"
    ]
  }
}

background.json:

chrome.commands.onCommand.addListener(function (command) {
  console.log(command);
  if (command == "reload1" || command == "reload2") {
    reloadAll();
  }
});

chrome.browserAction.onClicked.addListener(reloadAll);

function reloadAll() {
  chrome.management.getAll(function(extensions) {
    for (var i = 0; i < extensions.length; i++) {
      var extension = extensions[i];

      if (extension.id == chrome.runtime.id) {
        continue;
      }

      if (!extension.enabled) {
        continue;
      }

      var id = extension.id;

      chrome.management.setEnabled(id, false, function() {
        chrome.management.setEnabled(id, true);
      });
    }
  });
}
Valentin Shergin
  • 7,166
  • 2
  • 50
  • 53