Similar to this question. The following userscript intercepts fetch and XMLHttpRequest requests and log their url's to the console. But, why it doesn't intercept all requests? for example it doesn't log: https://www.youtube.com/s/desktop/508deff1/img/logos/favicon.ico and https://tpc.googlesyndication.com/sodar/56-y-0RG.js
// ==UserScript==
// @name YouTube Urls
// @namespace http://tampermonkey.net/
// @version 0.1
// @description URLs on YouTube.
// @author me
// @match https://www.youtube.com/*
// @grant none
// @run-at document-start
// ==/UserScript==
(function() {
'use strict';
// intercept fetch requests
const originalFetch = window.fetch;
window.fetch = function(url, options) {
console.log(url)
return originalFetch(url, options);
};
// intercept XMLHttpRequest
const originalXhrOpen = XMLHttpRequest.prototype.open;
XMLHttpRequest.prototype.open = function(method, url, async, user, password) {
console.log(url)
return originalXhrOpen.apply(this, arguments);
};
})();
Both resources aren't preloaded:
EDIT:
Here are the initiator of a request, three cases in the same order marked in the image:
For the first one:
(anonymous) @desktop_polymer.js:7320
zla @base.js:1425
nwa @base.js:2869
mya @base.js:3155
g.k.xz @base.js:9573
g.k.startRendering @base.js:9520
.
.
.
g.k.loadVideoByPlayerVars @base.js:10439
g.k.saa @base.js:10612
UR.a.state.j.<computed> @base.js:4605
(anonymous) @desktop_polymer.js:9647
(anonymous) @desktop_polymer.js:18592
acquireApi_ @desktop_polymer.js:18592
(anonymous) @desktop_polymer.js:3853
(anonymous) @desktop_polymer.js:11370
Ov.resolveCommand @desktop_polymer.js:5622
fmb @desktop_polymer.js:7712
onEndpointClick_ @desktop_polymer.js:7719
(anonymous) @desktop_polymer.js:3853
For the second one:
For the third one:
eval @ VM118:1
gy @ VM110:1
t7 @ VM114:1
eval @ 5k7CCto5.html:1
Oa @ 5k7CCto5.html:1
M5 @ 5k7CCto5.html:1
X @ 5k7CCto5.html:1
eval @ 5k7CCto5.html:1
requestIdleCallback.timeout @ 5k7CCto5.html:1
requestIdleCallback
R3 @ 5k7CCto5.html:1
M5 @ 5k7CCto5.html:1
X @ 5k7CCto5.html:1
eval @ 5k7CCto5.html:1
requestIdleCallback.timeout @ 5k7CCto5.html:1
requestIdleCallback
R3 @ 5k7CCto5.html:1
M5 @ 5k7CCto5.html:1
X @ 5k7CCto5.html:1
eval @ 5k7CCto5.html:1
requestIdleCallback.timeout @ 5k7CCto5.html:1
requestIdleCallback
R3 @ 5k7CCto5.html:1
M5 @ 5k7CCto5.html:1
X @ 5k7CCto5.html:1
eval @ 5k7CCto5.html:1
requestIdleCallback.timeout @ 5k7CCto5.html:1
requestIdleCallback
R3 @ 5k7CCto5.html:1
M5 @ 5k7CCto5.html:1
X @ 5k7CCto5.html:1
eval @ 5k7CCto5.html:1
requestIdleCallback.timeout @ 5k7CCto5.html:1
requestIdleCallback
R3 @ 5k7CCto5.html:1
M5 @ 5k7CCto5.html:1
X @ 5k7CCto5.html:1
.
.
.
Promise.then
C @ 5k7CCto5.html:13
D @ 5k7CCto5.html:13
db @ 5k7CCto5.html:19
E @ 5k7CCto5.html:18
(anonymous) @ 5k7CCto5.html:13
(anonymous) @ 5k7CCto5.html:41
(anonymous) @ 5k7CCto5.html:37
ServiceWorker router, does that mean the request was made by a service worker and cannot be intercepted?