谷歌浏览器,摁F12,在console输入以下代码即可.
// 劫持所有JS自动滚动API,网页脚本无法主动跳转
window.scrollTo = function(){};
window.scrollBy = function(){};
window.scroll = function(){};
Element.prototype.scrollIntoView = function(){};
Element.prototype.scrollTo = function(){};
Element.prototype.scrollBy = function(){};
// 禁止脚本通过focus触发自动滚动
let originalFocus = HTMLElement.prototype.focus;
HTMLElement.prototype.focus = function() {
originalFocus.call(this, {preventScroll: true});
};
console.log('✅ 自动滚动已禁用,手动滚动不受影响');
效果如下:
