aboutsummaryrefslogtreecommitdiffstats
path: root/extension/background.js
diff options
context:
space:
mode:
authorTeddy Wing2021-02-27 18:54:54 +0100
committerTeddy Wing2021-02-27 18:54:54 +0100
commitcbd9d28467f03569f464cbd0628fed73e4a6cd32 (patch)
treebf99595bc79a078ccb45ed64e8088724a5a95f01 /extension/background.js
parent9f349ac9a02d3e0276bd45f25a9c61035a0bd3a5 (diff)
downloadextreload-cbd9d28467f03569f464cbd0628fed73e4a6cd32.tar.bz2
Remove web extension and native messaging host
This code is superseded by the Common Lisp project that communicates via the DevTools Protocol. The `chrome.management` API's `setEnabled()` function just allowed me to turn extensions off and on. It didn't reload the extensions. The DevTools Protocol allows us to execute JavaScript in the context of an extension's background page. This allows us to run `chrome.runtime.reload()` in an extension's context, properly reloading the extension.
Diffstat (limited to 'extension/background.js')
-rw-r--r--extension/background.js31
1 files changed, 0 insertions, 31 deletions
diff --git a/extension/background.js b/extension/background.js
deleted file mode 100644
index fa7defb..0000000
--- a/extension/background.js
+++ /dev/null
@@ -1,31 +0,0 @@
-var NATIVE_HOST_ID = 'com.teddywing.extreload';
-var port = null;
-
-port = chrome.runtime.connectNative(NATIVE_HOST_ID);
-port.onMessage.addListener(on_native_message);
-port.onDisconnect.addListener(on_disconnected);
-
-function on_native_message(message) {
- console.log(message);
-
- if (message.ids) {
- message.ids.forEach(function(id) {
- // Disable extension
- chrome.management.setEnabled(id, false, function() {
- console.log('Disabled', id);
-
- // Enable extension
- chrome.management.setEnabled(id, true, function() {
- console.log('Enabled', id);
-
- // Reload the current tab
- chrome.tabs.reload();
- });
- });
- });
- }
-}
-
-function on_disconnected() {
- console.warn('Native host disconnected');
-}