美化文件目录

try to take over the world!

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         美化文件目录
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       fcz
// @match        http://chinanet.mirrors.ustc.edu.cn/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    function addHomeBtn(){
        var body = document.getElementsByTagName('body')[0];
        if(document.getElementById('mainFrame')) return;

        var btn = document.createElement('div');
        btn.innerText = 'Home';
        btn.classList.add('btnhome');
        btn.onclick = function(e){
            var root = top.location.origin;
            // top.location.href + '//' + top.location.hostname + ':' + top.location.
            top.location.assign(root);
        }
        body.appendChild(btn);
    }

    function addGlobalStyle(css) {
        var head, style;
        head = document.getElementsByTagName('head')[0];
        if (!head) { return; }
        style = document.createElement('style');
        style.type = 'text/css';
        style.innerHTML = css;
        head.appendChild(style);
    }

    addGlobalStyle(`
pre>a{
    display: inline-block;
    font-size: 1.2rem;
    padding: 8px;
    text-decoration: none;
    font-family: '微软雅黑';
    color: #5698c3;
    border-radius: 5px;
    transition: all 0.4s;
}
pre>a:hover{
    background-color: #e2e1e4;
    box-shadow:0px 15px 10px -15px #000;
}
div.btnhome{
    padding: 8px;
    cursor: pointer;
    background-color: #e2e1e4;
    border-radius: 5px;
    position: fixed;
    right: 8px;
    top: 8px;
    z-index: 1000;
}`);
    addHomeBtn()
})();