TAPD link clickable

tapd 链接可点击

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         TAPD link clickable
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  tapd 链接可点击
// @author       liuzp01
// @match        https://www.tapd.cn/*
// @grant        none
// @requir       https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js
// ==/UserScript==

/*jshint esversion: 6 */
(function() {
    'use strict';

    // Your code here...
    const needArr = ['分支链接','Jira链接','CodeReview链接', 'ykUpgrader链接'];
    var $ = window.jQuery;

    function init() {
        let arr = Array.from($(".left_3_col"));
        if (arr.length > 0) {
            // 处理链接
            arr.forEach(item => {
                // 创建 new-wrap 作为隔离区域
                let wrap = $(item).children(".new-wrap");
                if (wrap.length == 0) {
                    $(item).append(`<div class="new-wrap"></div>`);
                    wrap = $(item).children(".new-wrap")
                } else {
                    $(wrap[0]).empty();
                }

                let label = $(item).children(".tapd-view-title")[0].innerText;
                if (needArr.includes(label)) {
                    let value = $(item).find(".editable-value")[0].innerText;
                    let reg = /\s/g;
                    let valueArr = [];

                    if (reg.test(value)) {
                        valueArr = value.split(/\s/g);
                    } else {
                        valueArr = [value];
                    }

                    valueArr.forEach((child, index) => {
                        if (child !== '--') {
                            $(wrap[0]).append(`<a style="padding: 3px;display: inline-block;border: 1px solid #3582fb;border-radius: 5px;margin-bottom:5px;" href="${child}">Jump to ${label} ${index + 1}</a>`);
                        }
                    })

                };
                // 处理粘贴
                if (label === '分支名称') {
                    let value = $(item).find(".editable-value")[0].innerText;
                    $(wrap[0]).append(`<div style="padding: 3px;display: inline-block;cursor:pointer;border: 1px solid #3582fb;border-radius: 5px;color:#3582fb;font-size:12px;" id="copyBtn">Copy ${label}</div>`);
                    $('#copyBtn').click(() => {
                        copy(value);
                    });
                }
            })
        }
    }


    function copy(value) {
        const input = document.createElement('input');
        document.body.appendChild(input);
        input.setAttribute('value', value);
        input.select();
        if (document.execCommand('copy')) {
            document.execCommand('copy');
            console.log('复制成功');
        }
        document.body.removeChild(input);
    }

    // 监听右侧输入框失去焦点事件,重新执行init() 函数。
    $('#base_information').on('blur','input',function () {
        setTimeout(() => {
            init();
        },1000)
    })


    init();

})();