|
3 | 3 | // @namespace Violentmonkey Scripts |
4 | 4 | // @match https://collaboration.dataminer.services/* |
5 | 5 | // @grant none |
6 | | -// @version 1.1 |
| 6 | +// @version 1.1.1 |
7 | 7 | // @author JKE, TCR |
8 | 8 | // @description 28/3/2024, 17:26:21 |
9 | 9 | // ==/UserScript== |
|
23 | 23 |
|
24 | 24 |
|
25 | 25 |
|
26 | | - function buttonClickFunction() { |
27 | | - // Execute your desired function here |
28 | | - // Find the <a> tag under the div with id "dropdownMenMoreOptions" |
29 | | - const taskTitleInput = document.getElementById('taskTitle'); |
30 | | - if(taskTitleInput) { |
31 | | - const dropdownMenu = document.getElementById('dropdownMenMoreOptions'); |
32 | | - if (dropdownMenu) { |
33 | | - const link = dropdownMenu.querySelector('a'); |
34 | | - if (link) { |
35 | | - // Extract the number from the URL |
36 | | - const url = link.getAttribute('href'); |
37 | | - const number = url.match(/\d+$/); |
38 | | - if (number) { |
39 | | - // Copy the extracted number to clipboard |
40 | | - copyToClipboard('<a href="https://collaboration.dataminer.services/task/' + number[0] + '">' + taskTitleInput.value + '</a> (' + number[0] + ')'); |
41 | | - //alert('Number copied to clipboard!'); |
42 | | - } else { |
43 | | - alert('Number not found in URL!'); |
44 | | - } |
45 | | - } else { |
46 | | - alert('Anchor tag not found under the dropdown menu!'); |
47 | | - } |
48 | | - } else { |
49 | | - alert('Dropdown menu with id "dropdownMenMoreOptions" not found!'); |
50 | | - } |
51 | | - } else { |
52 | | - alert('Input field with id "taskTitle" not found!'); |
| 26 | + function buttonClickFunction() { |
| 27 | + // Find the input field with id "taskTitle" |
| 28 | + const taskTitleInput = document.getElementById('taskTitle'); |
53 | 29 |
|
54 | | - } |
55 | | - } |
| 30 | + if (taskTitleInput) { |
| 31 | + // Get the current URL |
| 32 | + const currentUrl = window.location.href; |
| 33 | + |
| 34 | + if (currentUrl) { |
| 35 | + // Extract the number from the URL |
| 36 | + let number = currentUrl.substring(currentUrl.lastIndexOf('/') + 1); |
| 37 | + const queryIndex = number.indexOf('?'); |
| 38 | + |
| 39 | + if (queryIndex != -1) { |
| 40 | + number = number.substring(0, queryIndex); |
| 41 | + } |
| 42 | + |
| 43 | + // Copy the extracted number to the clipboard |
| 44 | + copyToClipboard('<a href="https://collaboration.dataminer.services/task/' + number + '">' + taskTitleInput.value + '</a> (' + number + ')'); |
| 45 | + } else { |
| 46 | + alert('URL could not be identified.'); |
| 47 | + } |
| 48 | + } else { |
| 49 | + alert('Input field with id "taskTitle" not found!'); |
| 50 | + } |
| 51 | +} |
56 | 52 |
|
57 | 53 | function addButtonToToolbar() { |
58 | 54 | //var toolbarButtonGroup = document.querySelector('.toolbar-btn-group'); |
|
0 commit comments