我怎样才能完全欺骗网站,让它认为我没有最小化浏览器窗口或者打开并切换到新标签?
有一个网站,如果我最小化浏览器或打开并切换到新选项卡,它会在几次警告后检测并终止会话。我该如何欺骗这个网站?该网站不允许使用 Firefox 访问,只允许使用 Google Chrome。我正在使用带有 kde(xorg)的 Manjaro Linux。
答案1
应该可以工作(对于一些混乱的代码我表示歉意,这是content2.js的一些示例代码):
console.log("v3");
function fakeAddEventListener(type, listener, options) {
console.log("addEventListener called for:", type);
if (!this.lastListenerInfo) {
this.lastListenerInfo = [];
}
if (type !== 'visibilitychange') {
const listenerInfo = { type, listener, options };
this.lastListenerInfo.push(listenerInfo);
this.realAddEventListener(type, listener, options);
} else {
console.log(type, "detected");
removeVisibilityChangeListeners();
}
}
function removeVisibilityChangeListeners() {
const arr = window.lastListenerInfo;
for (const event of arr) {
if (event.type === 'visibilitychange') {
window.realRemoveEventListener(event.type, event.listener, event.options || false);
document.realRemoveEventListener(event.type, event.listener, event.options || false);
window.lastListenerInfo.splice(window.lastListenerInfo.indexOf(event), 1);
console.log(`removed event listener for ${event.type}`);
}
}
}
function setup() {
setInterval(removeVisibilityChangeListeners, 1000);
}
Document.prototype.realAddEventListener = Document.prototype.addEventListener;
Document.prototype.addEventListener = fakeAddEventListener;
Document.prototype.realRemoveEventListener = Document.prototype.removeEventListener;
Window.prototype.realAddEventListener = Window.prototype.addEventListener;
Window.prototype.addEventListener = fakeAddEventListener;
Window.prototype.realRemoveEventListener = Window.prototype.removeEventListener;
setup();
你可以在 Chrome 扩展程序中使用它
这是一个示例 manifest.json 文件:
{
"manifest_version": 3,
"name": "Remove Visibility Change Listeners",
"version": "0",
"description": "Removes all visibility change event listeners on a specific site",
"permissions": ["activeTab", "scripting"],
"content_scripts": [
{
"matches": ["https://*.example.com/*"],
"world": "MAIN",
"js": ["content2.js"],
"all_frames": false,
"run_at":"document_start"
}
],
"host_permissions": ["<all_urls>"]
}