akhargha / pki-chrome

1 stars 1 forks source link

Websites being unblocked async #1

Closed akhargha closed 3 months ago

akhargha commented 3 months ago

Sensitive sites are being unblocked async (i.e. before the extension is opened). It seems like the JS code runs as soon as the browser and site is loaded, it executes the check for sensitive site and executes the code to unblock the site. The intended functionality is to unblock sensitive sites ONLY when the user clicks on the browser extension and opens the popup, NOT before that.

if (result === 0) {
                //Website is sensitive
                removeView();
                document.getElementById("all-set").style.display = "block";
                chrome.scripting.executeScript({
                    target: {tabId: tabs[0].id},
                    files: ['contentScript.js']
                })
                chrome.tabs.sendMessage(tabs[0].id, {action: "removeBlocker"}); // <= this line needs to be executed AFTER the popup is loaded
            }
akhargha commented 3 months ago

Prithvi and I tested it again and it somehow magically works as intended now. Great!