Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refining onBeforeRequest handler to minimize the number of requests without corresponding page url. #138

Merged
merged 10 commits into from Aug 2, 2018
@@ -336,15 +336,20 @@ class EventHandlers {
log(`tabInfo not found for tab ${tab_id}, initializing...`);

// create new tabInfo entry
tabInfo.create(tab_id);
if (details.type === 'main_frame') {
tabInfo.create(tab_id, details.url);
} else {
tabInfo.create(tab_id);
}

// get tab data from browser and update the new tabInfo entry
utils.getTab(tab_id, (tab) => {
const ti = tabInfo.getTabInfo(tab_id);
if (ti && ti.partialScan) {
if (!ti) { return; }
if (ti.partialScan) {
tabInfo.setTabInfo(tab_id, 'url', tab.url);
tabInfo.setTabInfo(tab_id, 'incognito', tab.incognito);
}
tabInfo.setTabInfo(tab_id, 'incognito', tab.incognito);
});
}

@@ -69,17 +69,11 @@ class TabInfo {
insecureRedirects: [],
};

this._tabInfo[tab_id] = info;

if (tab_url) {
const parsed = processUrl(tab_url);
info.url = tab_url;
info.protocol = parsed.protocol;
info.host = parsed.host;
info.path = parsed.path;
info.hash = parsed.anchor;
info.partialScan = false;
this._updateUrl(tab_id, tab_url);
}

this._tabInfo[tab_id] = info;
}

/**
@@ -183,6 +177,7 @@ class TabInfo {
this._tabInfo[tab_id].host = parsed.host;
this._tabInfo[tab_id].path = parsed.path;
this._tabInfo[tab_id].hash = parsed.anchor;
this._tabInfo[tab_id].partialScan = false;
}
}

ProTip! Use n and p to navigate between commits in a pull request.