Get Mystery Box with random crypto!

B 站开始在页面加载后利用 replaceState 向地址栏添加追踪标识,可 | 神奇的笔记

B 站开始在页面加载后利用 replaceState 向地址栏添加追踪标识,可以看到 History API 被 Sentry 库篡改。由于发生在 replaceState 时,地址清理插件 Neat URL 等工具无法对此进行自动移除。
在 uBlockOrigin 中自定义静态规则添加
//s1.hdslb.com/bfs/static/jinkela/long/js/sentry/
然后需要通过 User Script 添加
(function() {
'use strict';
unsafeWindow.Sentry = {
init: () => {},
Integrations: { Vue: class {constructor() {}}}
}
var ops = unsafeWindow.history.pushState;
var ors = unsafeWindow.history.replaceState;
var callOriginal = (stateObj, title, url, calling) => {
if (new URL(`https://example.com${url}`).searchParams.get('vd_source') === null) {
calling(stateObj, title, url);
}
}
unsafeWindow.history.pushState = (stateObj, title, url) => callOriginal(stateObj, title, url, ops)
unsafeWindow.history.replaceState = (stateObj, title, url) => callOriginal(stateObj, title, url, ors)
})();
记得 @grant unsafeWindow
进行占位
可以避免篡改
(没叔叔 Premium 放不下了,只能压缩一下了)