// ==UserScript== // @name 复制标题超链接 // @namespace tapd // @match https://www.tapd.cn/*/*/*/view* // @grant none // @version 1.0 // @author wangy // @license MIT // @description 2024/4/9 15:01:15 // @downloadURL none // ==/UserScript== function addTitleLink(event) { let url = document.location.href let title = $('#story_name_view,#task_name_view,#bug_title_view').children('.editable-value').attr('title') if(title === undefined || title == ''){ // 处理标题异步加载的场景,如果取不到标题则等500ms后重试 setTimeout(addTitleLink, 500) return } let a = $('') .attr('href', url) .css('font-size', 14) .text(title) let markdown = '[' + title + ']('+ url +')' let btn = $('') .addClass('btn') .css('margin-left', 20) .append($('') .text('标题markdown') .css('width','auto')) .click(async function() { let format1 = 'text/plain'; let promise_text_blob = Promise.resolve(new Blob([markdown], {type: format1})); let clipboardItemInput = new ClipboardItem( {[format1]: promise_text_blob}, {presentationStyle: "unspecified"}); await navigator.clipboard.write([ clipboardItemInput ]); }) .prependTo('.right-operation') a.prependTo('.right-operation') } addEventListener("load", addTitleLink);