More-Useful-ScombZ

より快適なScombZライフのために、サイドメニュー、テスト、ログインを改善します

当前为 2022-04-24 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         More-Useful-ScombZ
// @namespace    https://twitter.com/yudai1204
// @version      1.0
// @description  より快適なScombZライフのために、サイドメニュー、テスト、ログインを改善します
// @author       @yudai1204
// @match        https://scombz.shibaura-it.ac.jp/*
// @match        https://adfs.sic.shibaura-it.ac.jp/adfs/ls/*
// @icon         https://scombz.shibaura-it.ac.jp/favicon.ico
// @grant        none
// ==/UserScript==


(function() {
    'use strict';
    //ADFSスキップ
    if (document.domain == 'adfs.sic.shibaura-it.ac.jp'){
        const $adfsButton = document.getElementById("continueButton");
        if ($adfsButton) {
            $adfsButton.click();
        }
    }
    //ログインボタン自動クリック
    else if (location.href == 'https://scombz.shibaura-it.ac.jp/login'){
        window.onload = function(){
            document.querySelector('.login-btn:nth-child(1)').click();
        };

    }
    //その他
    else{
        //テスト改善
        if (location.href.indexOf('lms/course/examination/')){

            const $exa_contsize = document.getElementById('pageContents');
            const $exa_examImgList = document.querySelectorAll('.downloadFile');
            const $exa_cheadList = document.querySelectorAll('.contents-header');
            const $exa_img = document.querySelector('.exam-question-img');
            const $exa_footer = document.getElementById('page_foot');
            const $exa_timer = document.getElementById('examTimer');
            if ($exa_footer){
                $exa_footer.style.visibility = 'hidden';
            }

            for (const $exa_chead of $exa_cheadList){
                $exa_chead.style.width = '8%';
                $exa_chead.style.background = '#f6f6ff';
            }
            if ($exa_img){
                for (const $exa_examImg of $exa_examImgList){
                    $exa_examImg.style.maxHeight = '100vh';
                    $exa_examImg.style.boxShadow= '0 0 1px #000000 ';
                }
                $exa_examImgList[0].style.maxHeight = '95vh';
                $exa_examImgList[0].style.maxWidth = '50vw';
                $exa_examImgList[0].style.position = 'fixed';
                $exa_examImgList[0].style.right= '1px';
                $exa_examImgList[0].style.top= '5vh';
                $exa_examImgList[0].style.boxShadow= '0 0 1px #000000 ';
                if ($exa_contsize) {
                    $exa_contsize.style.width = document.body.clientWidth - $exa_examImgList[0].clientWidth - 3 + 'px';
                }
                if($exa_timer){
                $exa_timer.style.width = document.body.clientWidth - $exa_examImgList[0].clientWidth + 'px';
                }
            }
        }
        //メニューを閉じる
        const $closeButton = document.getElementById('sidemenuClose');
            $closeButton.click();
        window.onload = function(){
            //head追加
            const $head = document.head;
            $head.insertAdjacentHTML('beforeEnd',`
            <style>
                .page-main #graylayer{
                        width:100%;
                        height:100%;
                        position:fixed;
                        z-index:11;
                        background:#000000;
                        opacity:0.3;
                        visibility:visible;
                        transition:opacity 300ms;
                    }
                .sidemenu-hide.page-main #graylayer{
                        width:100%;
                        height:100%;
                        position:fixed;
                        z-index:11;
                        background:#000000;
                        opacity:0;
                        visibility:hidden;
                }

                .sidemenu-open.hamburger-icon{
                    display:block;
                }
                .sidemenu-pull{
                    width:301px;
                }
                @media(max-width:480px){
                    .sidemenu-pull{
                        width:280px;
                    }
                }

            </style>
            `);
            //サイドメニューの重なりが出るように
            const $sidemenu = document.getElementById('sidemenu');
                $sidemenu.style.boxShadow = ('none');
                $sidemenu.style.overflowY = ('auto');
                $sidemenu.style.position = ('fixed');
                $sidemenu.style.top = ('0');
                $sidemenu.style.left = ('0');
                $sidemenu.style.float = ('left');
                $sidemenu.style.zIndex = ('100');
            const $pageMain = document.getElementById('pageMain');
                $pageMain.style.position = ('absolute');
                $pageMain.style.top = ('0');
                $pageMain.style.left = ('0');
                $pageMain.style.width = ('100%');
                $pageMain.style.minWidth = ('693px');
            //サイドメニューをモノトーンに
            const $menuIconList = document.querySelectorAll('.sidemenu-icon');
            for (const $menuIcon of $menuIconList){
                //通常時
                $menuIcon.style.background = '#ffffff';
                $menuIcon.addEventListener('mouseleave', function(){
                    $menuIcon.style.background = '#ffffff';
                })
                //マウスホバー時
                $menuIcon.addEventListener('mouseover', function(){
                    $menuIcon.style.background = '#f0f0f0';
                })
            }
            //サイドメニューのヘッドサイズを小さくする
            const $sidemenuHead = document.querySelector('.sidemenu-head');
                $sidemenuHead.style.height = '60px';
                $sidemenuHead.style.width = '301px';
            //サイドメニューのロゴ小さく
            const $sidemenuLogo = document.querySelector('.sidemenu-logo');
                $sidemenuLogo.style.height = '60px';
                $sidemenuLogo.style.width = '115px';
                $sidemenuLogo.style.paddingTop = '0px';
                $sidemenuLogo.style.margin = '0 auto';
            //サイドメニューの開閉ボタンを変える
                $closeButton.classList.add('hamburger-icon');
                $closeButton.innerHTML = '<div class="hamburger-line"></div>\n<div class="hamburger-line"></div>\n<div class="hamburger-line"></div>';
                $closeButton.style.left = '0';
                $closeButton.style.top = '0';
            //グレーレイヤーの追加
            $pageMain.insertAdjacentHTML('beforeEnd',`
            <div id="graylayer" onclick="document.getElementById('sidemenuClose').click();"></div>
            `);
            //お知らせを変更する
            const $sidemenuInfoList = document.querySelectorAll('.sidemenu-link.info-icon');
            if($sidemenuInfoList[0]){
                //お知らせページへの遷移へと変更
                $sidemenuInfoList[0].innerHTML=`お知らせ`;
                $sidemenuInfoList[0].setAttribute('href', 'https://scombz.shibaura-it.ac.jp/portal/home/information/list');
                $sidemenuInfoList[0].removeAttribute("onclick");
                $sidemenuInfoList[0].style.borderTop = '1px solid #ccc';
                //2,3個目のお知らせメニューを削除
                for (let i=1; i < $sidemenuInfoList.length; i++){
                    $sidemenuInfoList[i].remove();
                }
            }
            
            //各メニューの縦幅をすべて50pxにする
            const $sidemenuLinkList = document.querySelectorAll('.sidemenu-link');
            if($sidemenuLinkList[0]){
                for (const $sidemenuLink of $sidemenuLinkList){
                    $sidemenuLink.style.height = '50px';
                    $sidemenuLink.style.width = '301px';
                }
            }
            const $sidemenuPullList = document.querySelectorAll('.sidemenu-pull');
            if($sidemenuPullList[0]){
                for (const $sidemenuPull of $sidemenuPullList){
                    $sidemenuPull.style.height = '53px';
                    $sidemenuPull.style.padding = '17px 40px 12px 81px';
                }
            }
        };
    }
})();