Greasy Fork

Greasy Fork is available in English.

吾爱破解论坛左侧文章目录移到右边

吾爱破解论坛左侧文章目录移到右边,未使用的时候收起,鼠标移到上面的时候展开,目录较长的时候可以滚动

当前为 2019-04-13 提交的版本,查看 最新版本

// ==UserScript==
// @name         吾爱破解论坛左侧文章目录移到右边
// @namespace    https://www.52pojie.cn/thread-918614-1-1.html
// @version      0.1
// @description  吾爱破解论坛左侧文章目录移到右边,未使用的时候收起,鼠标移到上面的时候展开,目录较长的时候可以滚动
// @author       Ganlv
// @match        https://www.52pojie.cn/*
// @icon         https://www.52pojie.cn/favicon.ico
// @grant        none
// ==/UserScript==

(function () {
    'use stricit';

    function getOffset( el ) {
        var _x = 0;
        var _y = 0;
        while( el && !isNaN( el.offsetLeft ) && !isNaN( el.offsetTop ) ) {
            _x += el.offsetLeft - el.scrollLeft;
            _y += el.offsetTop - el.scrollTop;
            el = el.offsetParent;
        }
        return { top: _y, left: _x };
    }

    // toc 对象
    function Toc(tocElement) {
        // toc 元素
        this.tocElement = tocElement;
        var matches = this.tocElement.id.match(/^markdown_toc_(\d+)$/);
        if (!matches) {
            return null;
        }
        // post 元素
        this.postId = parseInt(matches[1]);
        this.postElement = document.getElementById('postmessage_' + this.postId);
        this.tocElement.className += ' toc-side-right';
        this.tocElement.style.maxHeight = (window.innerHeight - 112) + 'px'