您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
11/12/2024, 3:47:07 PM
当前为
- // ==UserScript==
- // @name Pull out issue numbers - drupal.org
- // @namespace Violentmonkey Scripts
- // @match https://www.drupal.org/project/issues/search/*
- // @grant none
- // @version 1.0
- // @author Chris Wells
- // @license MIT
- // @description 11/12/2024, 3:47:07 PM
- // ==/UserScript==
- (function() {
- 'use strict';
- // Select the table by class name
- const table = document.querySelector('.views-table.sticky-enabled');
- // If table is not found, exit
- if (!table) return;
- // Add a new header cell for the "Issue Number" column
- const headerRow = table.querySelector('thead tr');
- const newHeaderCell = document.createElement('th');
- newHeaderCell.className = 'views-field views-field-issue-number';
- newHeaderCell.scope = 'col';
- newHeaderCell.textContent = 'Issue Number';
- headerRow.appendChild(newHeaderCell);
- // Iterate over each row in the table body
- const rows = table.querySelectorAll('tbody tr');
- rows.forEach(row => {
- // Find the first column with the link containing the issue number
- const titleCell = row.querySelector('.views-field-title a');
- if (titleCell) {
- // Extract the issue number from the href attribute
- const issueNumber = titleCell.href.split('/').pop();
- const issueText = `[#${issueNumber}]`;
- // Create a new cell for the issue number with a click-to-copy functionality
- const issueCell = document.createElement('td');
- issueCell.className = 'views-field views-field-issue-number';
- issueCell.dataset.th = 'Issue Number';
- // Create a clickable span element
- const issueSpan = document.createElement('span');
- issueSpan.textContent = issueText;
- issueSpan.style.cursor = 'pointer';
- issueSpan.style.color = 'blue'; // Optional styling for better UX
- // Add event listener to copy text to clipboard on click
- issueSpan.addEventListener('click', () => {
- navigator.clipboard.writeText(issueText).then(() => {
- }).catch(err => {
- console.error('Failed to copy text: ', err);
- });
- });
- // Append the span to the new cell, and the cell to the row
- issueCell.appendChild(issueSpan);
- row.appendChild(issueCell);
- }
- });
- })();