diff --git a/src/scriptlets/prevent-fetch.js b/src/scriptlets/prevent-fetch.js index 973171c3..f376654d 100644 --- a/src/scriptlets/prevent-fetch.js +++ b/src/scriptlets/prevent-fetch.js @@ -41,7 +41,8 @@ import { * - responseBody - optional, string for defining response body value, defaults to `emptyObj`. Possible values: * - `emptyObj` - empty object * - `emptyArr` - empty array - * - responseType - optional, string for defining response type, defaults to `default`. + * - responseType - optional, string for defining response type, defaults to `default`. Possible values: + * - opaque * * > Usage with no arguments will log fetch calls to browser console; * which is useful for debugging but not permitted for production filter lists. @@ -103,6 +104,11 @@ export function preventFetch(source, propsToMatch, responseBody = 'emptyObj', re return; } + let allowedResponseType; + if (responseType === 'default' || responseType === 'opaque') { + allowedResponseType = responseType; + } + const handlerWrapper = (target, thisArg, args) => { let shouldPrevent = false; const fetchData = getFetchData(args); @@ -133,7 +139,7 @@ export function preventFetch(source, propsToMatch, responseBody = 'emptyObj', re if (shouldPrevent) { hit(source); - return noopPromiseResolve(strResponseBody, fetchData.url, responseType); + return noopPromiseResolve(strResponseBody, fetchData.url, allowedResponseType); } return Reflect.apply(target, thisArg, args);