61 lines
2.1 KiB
JavaScript
61 lines
2.1 KiB
JavaScript
// ==UserScript==
|
|
// @name Test Go link 2
|
|
// @namespace http://tampermonkey.net/
|
|
// @version 2024-07-23
|
|
// @description try to take over the world!
|
|
// @author You
|
|
// @match https://traefik-sdsdcrsoita9e6uknkyn.skynet.kz/dashboard/
|
|
// @icon https://www.google.com/s2/favicons?sz=64&domain=skynet.kz
|
|
// @grant none
|
|
// ==/UserScript==
|
|
|
|
|
|
(function() {
|
|
'use strict';
|
|
console.log('Start 15')
|
|
// Utility function to select elements by attribute pattern
|
|
function querySelectorAllByAttrPattern(attributePattern) {
|
|
const allElements = document.getElementsByTagName('*');
|
|
const matchingElements = [];
|
|
for (let el of allElements) {
|
|
for (let attr of el.attributes) {
|
|
if (attributePattern.test(attr.name)) {
|
|
matchingElements.push(el);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
return matchingElements;
|
|
}
|
|
|
|
// Utility function to create and insert the link
|
|
function createAndInsertLink(hostElem, protocol) {
|
|
const hostName = hostElem.textContent.match(/Host\(`([^`]+)`\)/)[1];
|
|
const url = `${protocol}://${hostName}`;
|
|
const linkDiv = document.createElement('div');
|
|
const link = document.createElement('a');
|
|
link.href = url;
|
|
link.target = '_blank';
|
|
link.textContent = `Open ${hostName}`;
|
|
linkDiv.appendChild(link);
|
|
hostElem.parentNode.insertBefore(linkDiv, hostElem);
|
|
}
|
|
|
|
// Select all elements with the specified attribute pattern
|
|
const elements = querySelectorAllByAttrPattern(/^data-v-.*/);
|
|
console.log('Start 46')
|
|
elements.forEach(element => {
|
|
const hostElem = element.querySelector('.q-chip.app-chip-rule .q-chip__content');
|
|
const protocolElem = element.querySelector('.q-chip.app-chip-entry-points .q-chip__content');
|
|
|
|
if (hostElem && protocolElem) {
|
|
const protocol = protocolElem.textContent.trim();
|
|
if (protocol === 'http' || protocol === 'https') {
|
|
createAndInsertLink(hostElem, protocol);
|
|
console.log('Start 55')
|
|
}
|
|
}
|
|
});
|
|
|
|
})();
|