Skip to content

Commit 8373e1c

Browse files
authored
Update main.js
1 parent b3897e8 commit 8373e1c

File tree

1 file changed

+26
-30
lines changed

1 file changed

+26
-30
lines changed

main.js

Lines changed: 26 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// @namespace Violentmonkey Scripts
44
// @match https://collaboration.dataminer.services/*
55
// @grant none
6-
// @version 1.1
6+
// @version 1.1.1
77
// @author JKE, TCR
88
// @description 28/3/2024, 17:26:21
99
// ==/UserScript==
@@ -23,36 +23,32 @@
2323

2424

2525

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');
5329

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+
}
5652

5753
function addButtonToToolbar() {
5854
//var toolbarButtonGroup = document.querySelector('.toolbar-btn-group');

0 commit comments

Comments
 (0)