TianchiNotebook

天池Notebook界面优化。

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         TianchiNotebook
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  天池Notebook界面优化。
// @author       You
// @match        https://tianchi.aliyun.com/ailab/notebook-ai/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=aliyun.com
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';
    window.onload = function () {
        var iframe = document.getElementsByClassName('detail-html')[0];
        if (iframe) {
            var iframeWin = iframe.contentWindow || iframe.contentDocument.parentWindow;
            if (iframeWin.document.body) {
                var arr = iframeWin.document.getElementsByClassName('p-Widget');
                setTimeout(function () {
                    iframe.style.height = (arr[arr.length - 1].getBoundingClientRect().top) + 200 + 'px';
                }, 1000);
            }
        }

        document.body.insertAdjacentHTML('beforeBegin','<style>\n' +
                                         '    .GTGoToTop{\n' +
                                         '        cursor: pointer;\n' +
                                         '        position: fixed;\n' +
                                         '        right: 50px;\n' +
                                         '        bottom: 50px;\n' +
                                         '        width: 50px;\n' +
                                         '        height: 50px;\n' +
                                         '        color: #fff;\n' +
                                         '        background: #ff8929;\n' +
                                         '        box-shadow: 5px 2px 5px #ffe4d1;\n' +
                                         '        line-height: 15px;\n' +
                                         '        padding: 10px;\n' +
                                         '    }\n' +
                                         '    .ailab-common-breadcrumb{\n' +
                                         '        display: none !important;\n' +
                                         '    }\n' +
                                         '    .ant-layout-header{\n' +
                                         '        display: none !important;\n' +
                                         '    }\n' +
                                         '    .ailab-notebook{\n' +
                                         '        height: unset;\n' +
                                         '    }\n' +
                                         '    .mynotebook-btn-container{\n' +
                                         '        padding: 16px 13px 22px;\n' +
                                         '        border-top: none;\n' +
                                         '        position: fixed;\n' +
                                         '        bottom: 0;\n' +
                                         '        left: 0;\n' +
                                         '        width: 295px !important;\n' +
                                         '        background: #fff;\n' +
                                         '    }\n' +
                                         '    .right-content-wrap{\n' +
                                         '        height: unset;\n' +
                                         '    }\n' +
                                         '</style>');

        document.body.insertAdjacentHTML('beforeEnd','<span class="GTGoToTop" onclick="window.scrollTo(0,0)">回到顶部</span>');

        var list_height = document.getElementsByClassName('left-menu')[0].offsetHeight;
        var btn_line_body = document.getElementsByClassName('mynotebook-btn-container')[0];
        var list_body = document.getElementsByClassName('list-container')[0];
        btn_line_body.style.position = "fixed";
        window.onscroll = function () {
            //为了保证兼容性,这里取两个值,哪个有值取哪一个
            //scrollTop就是触发滚轮事件时滚轮的高度
            var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
            if(scrollTop + document.body.offsetHeight >= list_height){
                btn_line_body.style.position = "relative";
                list_body.style.marginBottom = "0";
            }else{
                btn_line_body.style.position = "fixed";
                list_body.style.marginBottom = "70px";
            }
        };
    };
        // Your code here...
})();