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: .ico
and .js
// ==UserScript==
// @name YouTube Urls
// @namespace /
// @version 0.1
// @description URLs on YouTube.
// @author me
// @match /*
// @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
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742389671a4434760.html
评论列表(0条)