Greasy Fork is available in English.

FIX for "Bing Search returns to the top" !

Stop doing weird things, Bing ;)

< Feedback on FIX for "Bing Search returns to the top" !

Review: OK - script works, but has bugs

§
Posted: 26.08.2023.

非常感谢,不过有一些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);
        }
    };
}
§
Posted: 05.12.2023.

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

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

Post reply

Sign in to post a reply.