gorhill / httpswitchboard

Point & click to forbid/allow any class of requests made by your browser. Use it to block scripts, iframes, ads, facebook, etc.
GNU General Public License v3.0
1.33k stars 83 forks source link

Inline script tags not reported in matrix under certain conditions #413

Open gorhill opened 9 years ago

gorhill commented 9 years ago

Test case: https://news.ycombinator.com/.

Conditions:

The problem is this piece of code in contentScriptSummaryHandler() in https://github.com/gorhill/httpswitchboard/blob/master/js/messaging-handlers.js:

if ( pageStats && inlineScriptBlocked ) {
    urls = details.scriptSources;
    for ( url in urls ) {
        if ( !urls.hasOwnProperty(url) ) {
            continue;
        }
        if ( url === '{inline_script}' ) {
            url = frameURL + '{inline_script}';
        }
        r = httpsb.filterRequest(pageURL, 'script', url);
        pageStats.recordRequest('script', url, r !== false, r);
    }
}

Inline script tags should always be counted, even if inlineScriptBlocked is false. inlineScriptBlocked needs to be used to filter out 3rd-party scripts to avoid counting them twice.