From c615bf231303e003744f0378e97b639e799587ce Mon Sep 17 00:00:00 2001
From: Pierre Ranwez <pierre.ranwez.etu@univ-lille.fr>
Date: Fri, 25 Feb 2022 14:20:00 +0100
Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20bug:=20sync=20instead=20of=20loc?=
 =?UTF-8?q?al?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 content.js | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/content.js b/content.js
index 829158a..c50936d 100644
--- a/content.js
+++ b/content.js
@@ -481,10 +481,10 @@ function audioEvent() {
 }
 
 function pureCss() {
-    chrome.storage.local.get(['all', 'activate'], function (result) {
-        if (result.all.length > 0 && activate) {
+    chrome.storage.local.get(['all'], function (result) {
+        if (result.all.length > 0) {
             const elements = document.getElementsByClassName('CSSLSD');
-            while(elements.length > 0){
+            while (elements.length > 0) {
                 elements[0].parentNode.removeChild(elements[0]);
             }
             result.all.forEach(element => {
@@ -518,7 +518,11 @@ function onMessage({ type, data }) {
         console.info('Message received from CSSLSD back :', type, data);
     switch (type) {
         case 'update': {
-            pureCss();
+            chrome.storage.sync.get(['activate'], function (result) {
+                if (result.activate) {
+                    pureCss();
+                }
+            });
             break;
         }
         case 'start': {
-- 
GitLab