Skip to content
This repository has been archived by the owner on Nov 6, 2023. It is now read-only.

Commit

Permalink
Fix extension popup shows rulesets from previous pages
Browse files Browse the repository at this point in the history
  • Loading branch information
Chan Chak Shing committed Nov 4, 2018
1 parent d9d75f2 commit 02a9220
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions chromium/background-scripts/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,14 @@ function onBeforeRequest(details) {
return;
}

// Clear the content shown in the extension popup.
// This needed to be done before this listener returns,
// otherwise, the extension page might include rulesets
// from previous page.
if (details.type == "main_frame") {
appliedRulesets.removeTab(details.tabId);
}

let uri = new URL(details.url);

/**
Expand Down Expand Up @@ -387,12 +395,6 @@ function onBeforeRequest(details) {
return redirectOnCancel(shouldCancel, details.url);
}

if (details.type == "main_frame") {
appliedRulesets.removeTab(details.tabId);
}

let potentiallyApplicable = all_rules.potentiallyApplicableRulesets(uri.hostname);

if (redirectCounter.get(details.requestId) >= 8) {
util.log(util.NOTE, "Redirect counter hit for " + uri.href);
urlBlacklist.add(uri.href);
Expand All @@ -405,6 +407,8 @@ function onBeforeRequest(details) {
let upgradeToSecure = false;
let newuristr = null;

let potentiallyApplicable = all_rules.potentiallyApplicableRulesets(uri.hostname);

for (let ruleset of potentiallyApplicable) {
if (details.url.match(ruleset.scope)) {
appliedRulesets.addRulesetToTab(details.tabId, details.type, ruleset);
Expand Down

0 comments on commit 02a9220

Please sign in to comment.