WorkTile交互优化

优化愚蠢的交互方式和样式,让操作更便捷更人性!

目前為 2021-11-25 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         WorkTile交互优化
// @namespace    http://fulicat.com
// @version      1.0.0
// @description  优化愚蠢的交互方式和样式,让操作更便捷更人性!
// @author       Jack.Chan
// @license MIT
// @url          https://greasyfork.org/zh-CN/scripts/436038-worktile%E4%BA%A4%E4%BA%92%E4%BC%98%E5%8C%96
// @match        https://shebaochina.worktile.com/dashboard
// @match        https://*.worktile.com/mission/*
// @icon         https://cdn.pingcode.com/static/portal/favicon.ico
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    var $style = document.createElement('style');
    $style.type = 'text/css';
    $style.innerHTML = `
.app-nav-new-area-x,
.thy-header-self-adaption-x,
.shortcut-tray-content{
    z-index: 3000 !important;
}
.dialog-max-lg{
    width: 90% !important;
}
.task-table-next{
    padding: 16px 16px 46px 16px !important;
}

.shortcut-main{
    position: relative;
}
.shortcut-main shortcut-tray-list{
    box-shadow: 5px 0 10px 0 rgb(0 0 0 / 20%);
    background: #fafafa;
    position: fixed;
    right: 0;
    left: 108px;
    bottom: 0;
}
.shortcut-main .shortcut-list-content{
    justify-content: center;
}

.textarea-show-wrapper .textarea-show-footer{
    text-align: center;
    background: #eee;
    padding: 10px;
}
.textarea-show-wrapper .textarea-show-footer a{
    padding: 10px 20px;
}
.x-link{
    width: auto !important;
}
    `;

    function init() {
        document.createElement('shortcut-tray-list');
        document.head.appendChild($style);
    }

    function addLink(delay) {
        delay = delay || 0;
        setTimeout(function() {
            var $dialog = document.querySelector('.thy-dialog-container');
            if ($dialog) {
                var $dialogNavSecondary = $dialog.querySelector('.thy-icon-nav-secondary');
                if ($dialogNavSecondary) {
                    // add link
                    var $linkOpen = $dialogNavSecondary.querySelector('.x-link-open-new');
                    var $linkCopy = $dialogNavSecondary.querySelector('.x-link-copy');
                    if (!$linkOpen) {
                        $linkOpen = document.createElement('a');
                        $linkOpen.className = 'thy-icon-nav-link x-link x-link-open-new';
                        $linkOpen.target = '_blank';
                        $linkOpen.innerText = '新窗口打开';
                        $linkOpen.title = '在新窗口中打开';
                        $dialogNavSecondary.appendChild($linkOpen);

                        $linkCopy = document.createElement('a');
                        $linkCopy.className = 'thy-icon-nav-link x-link x-link-copy';
                        $linkCopy.innerText = '复制链接';
                        $linkCopy.title = '复制链接';
                        $linkCopy.addEventListener('click', function(event) {
                            event.preventDefault();
                            var $input = document.createElement('input');
                            $input.style.cssText = 'position:fixed;top:0;left:-500px;z-index:9999;';
                            document.body.appendChild($input);
                            $input.value = window.location.href;
                            $input.select();
                            document.execCommand('Copy');
                            $linkCopy.innerText = '复制成功';
                            setTimeout(function() {
                                $linkCopy.innerText = '复制链接';
                                document.body.removeChild($input);
                            }, 1500);
                            return false;
                        }, false);
                        $dialogNavSecondary.appendChild($linkCopy);
                    }
                    $linkOpen.href = window.location.href;
                    $linkCopy.href = window.location.href

                    // stop click to edit
                    var $markdownBody = document.querySelector('.markdown-body');
                    var $markdownBodyParent = $markdownBody.parentNode;
                    $markdownBodyParent.replaceChild($markdownBody.cloneNode(true), $markdownBody);
                    $markdownBodyParent.addEventListener('dblclick', function(event) {
                        this.classList.toggle('textarea-show-body-collapse');
                    }, false);
                }
            }
        }, delay);
    }

    init();

    document.body.addEventListener('mousedown', function(e) {
        addLink(500);
    }, false);

    addLink(1500);
})();