Skip to content

Commit d122b4a

Browse files
committed
remove obsolete code
1 parent b08caef commit d122b4a

File tree

1 file changed

+13
-84
lines changed

1 file changed

+13
-84
lines changed

platform/chromium/vapi-webrequest.js

Lines changed: 13 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -171,54 +171,11 @@ vAPI.net.registerListeners = function() {
171171
}
172172
};
173173

174-
// https://bugs.chromium.org/p/chromium/issues/detail?id=129353
175-
// https://github.com/gorhill/uBlock/issues/1497
176-
// Expose websocket-based network requests to uBO's filtering engine,
177-
// logger, etc.
178-
// Counterpart of following block of code is found in "vapi-client.js" --
179-
// search for "https://github.com/gorhill/uBlock/issues/1497".
180-
//
181-
// Once uBO 1.11.1 and uBO-Extra 2.12 are widespread, the image-based
182-
// handling code can be removed.
183-
var onBeforeWebsocketRequest = function(details) {
184-
if ( (details.type !== 'image') &&
185-
(details.method !== 'HEAD' || details.type !== 'xmlhttprequest')
186-
) {
187-
return;
188-
}
189-
var requestURL = details.url,
190-
matches = /[?&]u(?:rl)?=([^&]+)/.exec(requestURL);
191-
if ( matches === null ) { return; }
192-
details.type = 'websocket';
193-
details.url = decodeURIComponent(matches[1]);
194-
var r = onBeforeRequestClient(details);
195-
if ( r && r.cancel ) { return r; }
196-
// Redirect to the provided URL, or a 1x1 data: URI if none provided.
197-
matches = /[?&]r=([^&]+)/.exec(requestURL);
198-
return {
199-
redirectUrl: matches !== null ?
200-
decodeURIComponent(matches[1]) :
201-
'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=='
202-
};
203-
};
204-
205174
var onBeforeRequestClient = this.onBeforeRequest.callback;
206-
var onBeforeRequest = validTypes.websocket
207-
// modern Chromium/WebExtensions: type 'websocket' is supported
208-
? function(details) {
209-
normalizeRequestDetails(details);
210-
return onBeforeRequestClient(details);
211-
}
212-
// legacy Chromium
213-
: function(details) {
214-
// https://github.com/gorhill/uBlock/issues/1497
215-
if ( details.url.endsWith('ubofix=f41665f3028c7fd10eecf573336216d3') ) {
216-
var r = onBeforeWebsocketRequest(details);
217-
if ( r !== undefined ) { return r; }
218-
}
219-
normalizeRequestDetails(details);
220-
return onBeforeRequestClient(details);
221-
};
175+
var onBeforeRequest = function(details) {
176+
normalizeRequestDetails(details);
177+
return onBeforeRequestClient(details);
178+
};
222179

223180
// This is needed for Chromium 49-55.
224181
var onBeforeSendHeaders = validTypes.csp_report
@@ -238,44 +195,16 @@ vAPI.net.registerListeners = function() {
238195
var onHeadersReceivedClient = this.onHeadersReceived.callback,
239196
onHeadersReceivedClientTypes = this.onHeadersReceived.types.slice(0),
240197
onHeadersReceivedTypes = denormalizeTypes(onHeadersReceivedClientTypes);
241-
var onHeadersReceived = validTypes.font
242-
// modern Chromium/WebExtensions: type 'font' is supported
243-
? function(details) {
244-
normalizeRequestDetails(details);
245-
if (
246-
onHeadersReceivedClientTypes.length !== 0 &&
247-
onHeadersReceivedClientTypes.indexOf(details.type) === -1
248-
) {
249-
return;
250-
}
251-
return onHeadersReceivedClient(details);
198+
var onHeadersReceived = function(details) {
199+
normalizeRequestDetails(details);
200+
if (
201+
onHeadersReceivedClientTypes.length !== 0 &&
202+
onHeadersReceivedClientTypes.indexOf(details.type) === -1
203+
) {
204+
return;
252205
}
253-
// legacy Chromium
254-
: function(details) {
255-
normalizeRequestDetails(details);
256-
// Hack to work around Chromium API limitations, where requests of
257-
// type `font` are returned as `other`. For example, our normalization
258-
// fail at transposing `other` into `font` for URLs which are outside
259-
// what is expected. At least when headers are received we can check
260-
// for content type `font/*`. Blocking at onHeadersReceived time is
261-
// less worse than not blocking at all. Also, due to Chromium bug,
262-
// `other` always becomes `object` when it can't be normalized into
263-
// something else. Test case for "unfriendly" font URLs:
264-
// https://www.google.com/fonts
265-
if ( details.type === 'font' ) {
266-
var r = onBeforeRequestClient(details);
267-
if ( typeof r === 'object' && r.cancel === true ) {
268-
return { cancel: true };
269-
}
270-
}
271-
if (
272-
onHeadersReceivedClientTypes.length !== 0 &&
273-
onHeadersReceivedClientTypes.indexOf(details.type) === -1
274-
) {
275-
return;
276-
}
277-
return onHeadersReceivedClient(details);
278-
};
206+
return onHeadersReceivedClient(details);
207+
};
279208

280209
var urls, types;
281210

0 commit comments

Comments
 (0)