From 2b6404cb111b07dc298f381d5f4ce437cf79f9d6 Mon Sep 17 00:00:00 2001 From: eight Date: Tue, 19 Sep 2017 08:41:40 +0800 Subject: [PATCH] Fix: stop live-reload and refresh the page when style is removed --- content/install-user-css.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/content/install-user-css.js b/content/install-user-css.js index 3936accd..ee20f79a 100644 --- a/content/install-user-css.js +++ b/content/install-user-css.js @@ -189,6 +189,16 @@ function initLiveReload(sourceLoader) { watcher.start(); } }); + chrome.runtime.onMessage.addListener(request => { + if (request.method === 'styleDeleted') { + if (installed && installed.id === request.id) { + installed = null; + watcher.stop(); + $('.live-reload-checkbox').checked = false; + location.reload(); + } + } + }); $('.actions').appendChild($element({tag: 'label', className: 'live-reload', appendChild: [ $element({tag: 'input', type: 'checkbox', className: 'live-reload-checkbox'}), $element({tag: 'span', textContent: t('liveReloadLabel')})