0

Which ResourceType do I have to use for the RequestFilter so that my chrome.webRequest.onHeadersReceived listener takes up the least amout of resources?

I think it's either "object" or "other" but I didn't find any information about this.

Because at the moment I use {urls: ["<all_urls>"]} to catch all requests and then the code below to check for video requests:

chrome.webRequest.onHeadersReceived.addListener(function (details) {
    details.responseHeaders.forEach(function (header) {
        if (header.name.toLowerCase() === "content-type") {
            var type = header.value.toLowerCase().split('/');
            if (type[0] === "video") {
                type = type[1].split(';')[0];
                alert("Request for " + type + " video registered.");
            }
        }
    });
}, {urls: ["<all_urls>"]}, ["responseHeaders"]);

1 Answer 1

0

(HTML5) video resources are assigned the ResourceType "other".

"object" is used for requests from plugins (loaded via <embed> and <object>), so if you you want to account for e.g. Flash videos, then you also have to include "object" in your filter.

}, {
    urls: ["<all_urls>"],
    types: ["other", "object"],
}, ["responseHeaders"]);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.