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.

답글 게시

답글을 게시하려면 로그인하세요.

长期地址
遇到问题?请前往 GitHub 提 Issues。