您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Adds an "Copy" button to the SWC Events page, which adds the event details to the clipboard.
当前为
// ==UserScript== // @name SWC Events Clipboard // @namespace https://www.swcombine.com/ // @version 1.1 // @description Adds an "Copy" button to the SWC Events page, which adds the event details to the clipboard. // @author code-syl // @match https://www.swcombine.com/members/events/index.php?mode=* // @icon https://www.swcombine.com/favicon.ico // @grant none // @license MIT // @require https://greasyfork.org/scripts/383527-wait-for-key-elements/code/Wait_for_key_elements.js?version=701631 // ==/UserScript== /* @require https://code.jquery.com/jquery-3.6.3.min.js /* <-- enable when not using waitForKeyElements.js */ (function() { 'use strict'; const styles = ` .eventmsg:not(:hover) #alani-copy { display: none; } .eventmsg:hover #alani-copy, .eventpriv { align-self: center; } .eventpriv img { padding-top: 0 !important; }`; let styleSheet = document.createElement("style"); styleSheet.innerText = styles; document.head.appendChild(styleSheet); const onCopyClick = (jNode) => { const swcDateTime = jNode.find('.eventdate')[0].outerText; const eventText = jNode.find('.eventtext')[0].outerText; navigator.clipboard.writeText(swcDateTime + ' ' + eventText) .then(() => { console.info('Copied event details to clipboard.'); }) .catch(error => { console.error('Failed to copy event details to clipboard: ', error); }); }; const addCopyButton = (jNode) => { let button = document.createElement('button'); button.id = 'alani-copy'; button.textContent = 'Copy'; button.style.height = '2rem'; button.addEventListener('click', () => onCopyClick(jNode)); jNode.find('.eventpriv') .before(button); } waitForKeyElements('.eventmsg', addCopyButton); })();