Bing TopScroll Blocker

防止Bing自动滚动到顶部

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

You will need to install an extension such as Tampermonkey to install this script.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

You will need to install an extension such as Tampermonkey to install this script.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name         Bing TopScroll Blocker
// @namespace    https://tampermonkey.net/
// @version      0.4.0
// @description  防止Bing自动滚动到顶部
// @author       FakerJMS
// @match        http*://*.bing.com/*
// @icon         https://www.bing.com/sa/simg/favicon-trans-bg-blue-mg.ico
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';
    
    //
    let fk_timer_id = 0;
    //
    let fk_origin_scrollTo = window.scrollTo;
    //
    let fk_new_scrollTo = function(x, y) {
        // TODO
    };

    // 禁用"滚动到顶部"
    function disable_scrollToTop() {
        if (fk_timer_id > 0) {
            clearTimeout(fk_timer_id);
            fk_timer_id = 0;
        }
        
        window.scrollTo = fk_new_scrollTo;
    }

    // 使能"滚动到顶部"
    function _enable_scrollToTop() {
        window.scrollTo = fk_origin_scrollTo;
    }

    // 延时使能"滚动到顶部"
    function enable_scrollToTop() {
        fk_timer_id = setTimeout(_enable_scrollToTop, 1000);
    }

    // 监听"窗口获取焦点"事件, 使能"滚动到顶部"
    window.addEventListener('focus', enable_scrollToTop);
    // 监听"鼠标进入窗口"事件, 使能"滚动到顶部"
    document.addEventListener('mouseenter', enable_scrollToTop);
    // 监听"窗口失去焦点"事件, 禁用"滚动到顶部"
    window.addEventListener('blur', disable_scrollToTop);
})();