优化愚蠢的交互方式和样式,让操作更便捷更人性!
当前为
// ==UserScript==
// @name WorkTile交互优化
// @namespace http://fulicat.com
// @version 1.0.7
// @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://*.worktile.com/*
// @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;
}
.toc-section.thy-menu{
padding-bottom: 80px;
}
mission-work-addon-group.thy-layout{
padding-bottom: 50px;
}
mission-work-addon-group .addon-task-table-body.addon-task-table-scroll{
bottom: 50px;
}
.textarea-show-wrapper .textarea-show-footer{
text-align: center;
background: #eee;
padding: 10px;
}
.textarea-show-wrapper .textarea-show-footer a{
padding: 10px 20px;
}
.textarea-show-body{
position: relative;
}
.markdown-body{
visibility: hidden;
}
.markdown-body-new{
visibility: visible;
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 1;
background: rgba(255 ,255, 255, 1);
}
.x-link{
width: auto !important;
}
`;
//window.localStorage.setItem('latestMissionPath', '/mission/my/following');
function init() {
document.createElement('shortcut-tray-list');
document.head.appendChild($style);
}
function addLink(delay) {
delay = delay || 0;
setTimeout(function() {
/*
// 左边二级导航 增加 我参与的
if (!document.querySelector('.body-list-new')) {
var $bodyList = document.querySelector('.body-list');
var $menu = $bodyList.querySelector('.thy-menu.thy-menu');
if ($bodyList && $menu) {
var $node = document.createElement('div');
$node.style.cssText = 'border-top: 1px #e5ecfc solid;border-bottom: 1px #e5ecfc solid;';
$node.innerHTML = `
<a href="/mission/my/following" routerlinkactive="active" class="section-item thy-menu-item active">
<div class="thy-menu-item-content" style="padding: 0 20px;">
<span thymenuitemicon="" class="pl-0 thy-menu-item-icon">
<thy-icon thyiconname="user-square-fill" class="font-size-md text-primary thy-icon-user-square-fill thy-icon">
<svg viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fit="" height="1em" width="1em" preserveAspectRatio="xMidYMid meet" focusable="false"><g id="uhnormal/user-square-fill" stroke-width="1" fill-rule="evenodd"><path d="M12.8 0C14.56 0 16 1.36 16 3.2v9.6c0 1.76-1.44 3.2-3.2 3.2H3.2A3.21 3.21 0 0 1 0 12.8V3.2C0 1.44 1.44 0 3.2 0zM8.053 3h-.092c-1.7 0-2.153 1.58-2.187 2.465C5.774 7.293 7 7.96 7 7.96s.152.18.152.498c0 .073-.12.22-.2.287-.699.577-3.212 1.159-3.375 2.402-.126.528-.344 1.577 1.609 1.701.687.044 1.612.177 2.865.148 4.484-.104 4.572-.62 4.403-1.83-.163-1.243-2.696-1.844-3.395-2.421-.08-.066-.126-.284-.126-.357 0-.318.077-.428.077-.428-.001.001 1.23-.667 1.23-2.495C10.205 4.58 9.678 3 8.052 3z" id="uh形状结合"></path></g></svg>
</thy-icon>
</span>
<span thymenuitemname="" translate="mission.MY_TASK" class="thy-menu-item-name thy-menu-item-name-ellipsis">我参与的</span>
</div>
</a>
`;
$node.addEventListener('click', function(event) {
event.preventDefault();
event.stopPropagation();
window.history.pushState(null, null, '/mission/my/following');
window.dispatchEvent(new HashChangeEvent('hashchange'));
return false;
}, false);
$bodyList.insertBefore($node, $menu);
$bodyList.classList.add('body-list-new');
}
}
*/
// 弹框
var $dialogs = document.querySelectorAll('.thy-dialog-container');
if ($dialogs && $dialogs.length) {
$dialogs.forEach(function($dialog) {
var $dialogNavSecondary = $dialog.querySelector('.thy-icon-nav-secondary');
if ($dialogNavSecondary) {
// 弹框: 在新窗口打开、复制链接
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();
event.stopPropagation();
var $textarea = document.createElement('textarea');
$textarea.style.cssText = 'position:fixed;top:0;left:-500px;z-index:9999;';
document.body.appendChild($textarea);
var $projectName = $dialog.querySelector('.project-name');
var projectName = $projectName ? $projectName.innerText : ''
var $taskTitle = $dialog.querySelector('.task-title');
var taskTitle = $taskTitle ? $taskTitle.innerText : '';
var value = `【${projectName}】 - ${taskTitle}\r\n${window.location.href}`;
$textarea.value = value;
$textarea.select();
document.execCommand('Copy');
$linkCopy.innerText = '复制成功';
setTimeout(function() {
$linkCopy.innerText = '复制链接';
document.body.removeChild($textarea);
}, 1500);
return false;
}, false);
$dialogNavSecondary.appendChild($linkCopy);
}
$linkOpen.href = window.location.href;
$linkCopy.href = window.location.href;
// 弹框:需求/任务 描述 编辑、复制
if (!$dialog.querySelector('.markdown-body-new')) {
var $markdownBody = $dialog.querySelector('.markdown-body');
if ($markdownBody && $markdownBody.parentNode) {
var $markdownBodyParent = $markdownBody.parentNode;
var $newMarkdownBody = $markdownBody.cloneNode(true);
$newMarkdownBody.classList.add('markdown-body-new');
$markdownBodyParent.appendChild($newMarkdownBody, $markdownBody);
var syncDescHandler = function(event) {
setTimeout(function() {
$newMarkdownBody.innerHTML = $markdownBody.innerHTML;
}, 300);
}
$dialog.addEventListener('mousedown', function(event) {
var $btns = $dialog.querySelectorAll('field-item-textarea-show-edit .thy-btn')
$btns.forEach(function($btn) {
$btn.removeEventListener('mouseup', syncDescHandler, false);
$btn.addEventListener('mouseup', syncDescHandler, false);
});
}, false);
$newMarkdownBody.addEventListener('dblclick', function(event) {
$markdownBodyParent.classList.toggle('textarea-show-body-collapse');
return false
}, false);
}
}
}
})
}
}, delay);
}
init();
document.body.addEventListener('mousedown', function(e) {
addLink(500);
}, false);
addLink(1500);
})();