Bilibili video collection list height adjustment

Adjust video collection's height on Bilibili video pages.

// ==UserScript==
// @name         Bilibili video collection list height adjustment
// @name:zh-CN   调整 Bilibili 视频合集高度
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Adjust video collection's height on Bilibili video pages.
// @description:zh-cn  在 Bilibili 视频播放页面调整视频合集栏目的高度。
// @author       cloudy-sfu
// @match        https://www.bilibili.com/video/*
// @grant        none
// @run-at       context-menu
// @license      GPLv3
// ==/UserScript==

(function() {
    'use strict';

    let adjust_height_form = document.createElement('div');
    adjust_height_form.innerHTML =
    `<div class="base-video-sections-v1" style="display: flex; justify-content: space-evenly;">
    <span>Height: </span>
    <input type="number" required>
    <button onclick="adjust_height()"> Apply </button>
    </div>`;
    adjust_height_form = adjust_height_form.firstChild; // equal to .outerHTML when parent node is unknown

    let video_list = document.getElementsByClassName("base-video-sections-v1");
    if (video_list.length > 0) {
        video_list = video_list[video_list.length - 1];
        video_list.parentNode.insertBefore(adjust_height_form, video_list);
        adjust_height_form.children[1].value = video_list.offsetHeight;
    }
    let content_list = document.getElementsByClassName("video-sections-content-list");
    if (content_list.length > 0) {
        content_list = content_list[content_list.length - 1];
    }

    function adjust_height() {
        let new_height = adjust_height_form.children[1].value;
        video_list.style.height = `${new_height}px`;
        let max_height = document.getElementsByClassName("video-section-list section-0");
        if (max_height.length > 0) {
            max_height = max_height[max_height.length - 1];
            content_list.style = `height: ${new_height-100}px; max-height: ${max_height.style.height};`;
        }
    }

    window.adjust_height = adjust_height; // This makes the function accessible from the HTML button's onclick
})();