jupyter notebook auto scroll

Add auto scroll to bottom funtion for jupyter notebook pages.

06.12.2020 itibariyledir. En son verisyonu görün.

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         jupyter notebook auto scroll
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Add auto scroll to bottom funtion for jupyter notebook pages.
// @author       Scruel Tao
// @match        http*://*/notebook*/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    var scrollDelay = 100;
    var defalutEnabled = true;

    var scrollEnableMap = new Map();
    var scrollCheckIndex = 1;

    $(".output_scroll").each(function() {
        $(this)[0].scrollTop = $(this)[0].scrollHeight;
    });

    function callScrollToBottom() {
        setTimeout(scrollToBottom, scrollDelay);
    }

    function scrollToBottom() {
        $(".output_scroll").each(function() {
            if (!$(this).attr('scroll_checkbox_index')){
                $(this).attr('scroll_checkbox_index', scrollCheckIndex);
                var div = document.createElement('div');
                var checkbox = document.createElement('input');
                checkbox.type = "checkbox";
                checkbox.setAttribute('scroll_checkbox_index', scrollCheckIndex);
                if (defalutEnabled) {
                    checkbox.checked = "checked";
                }
                checkbox.onclick = function(){
                    scrollEnableMap.set($(this).attr('scroll_checkbox_index'), checkbox.checked);
                };

                div.append("Auto Scroll: ");
                div.append(checkbox);
                $(this).parent().before(div);
                scrollEnableMap.set(scrollCheckIndex++, defalutEnabled);
            }

            if (!scrollEnableMap.has($(this).attr('scroll_checkbox_index'))){
                scrollEnableMap.set($(this).attr('scroll_checkbox_index'), defalutEnabled);
            }
            var flag = scrollEnableMap.get($(this).attr('scroll_checkbox_index'));
            if (flag){
                $(this)[0].scrollTop = $(this)[0].scrollHeight;
            }
        });
        callScrollToBottom();
    }
    scrollToBottom();
})();