FIX for "Bing Search returns to the top" !

Stop doing weird things, Bing ;)

< 脚本 FIX for "Bing Search returns to the top" ! 的反馈

评价:一般 - 脚本能用,但还有一些问题

§
发布于:2023-08-26

非常感谢,不过有一些bug
// Thank you very much, but there are some bugs

这个代码在直接调用window.scrollTo函数的时候可能导致栈溢出:
// This code may cause a stack overflow when calling the window.scrollTo function directly:

// Disable the scroll to top functionality
function disableScrollToTop() {
    window.scrollTo = function(x, y) {
        if (y !== 0) {
            window.scrollTo.originalFunc(x, y);
        }
    };
    window.scrollTo.originalFunc = window.scrollTo;
}

可以用下面的代码替换:
// Can be replaced with the following code:

// Disable the scroll to top functionality
function disableScrollToTop() {
    let originalFunc = window.scrollTo;
    window.scrollTo = function(x, y) {
        if (y !== 0) {
            originalFunc(x, y);
        }
    };
}
§
发布于:2023-12-05

感觉好奇怪啊,originalFunc 在定义之前就被访问了,程序竟然可以正常运行。

It feels so strange. originalFunc is accessed before it is defined, but the program can run normally.

发布留言

登录以发布留言。