Greasy Fork is available in English.
Ну и говна кусок этот код
当前为
// ==UserScript==
// @name LZT_Trophy
// @namespace http://tampermonkey.net/
// @version 0.2
// @description Ну и говна кусок этот код
// @author llimonix
// @match https://zelenka.guru/*
// @icon https://cdn-icons-png.flaticon.com/512/2830/2830919.png
// @grant none
// @license MIT
// ==/UserScript==
(function() {
// Видимость трофеев в мобильной версии
let mobileTrophy = '.Responsive .memberViewTrophies {display: block!important;}',
mobilehead = document.head || document.getElementsByTagName('head')[0],
mobilestyle = document.createElement('style');
mobilehead.appendChild(mobilestyle);
mobilestyle.type = 'text/css';
if (mobilestyle.styleSheet){
// This is required for IE8 and below.
mobilestyle.styleSheet.cssText = mobileTrophy;
} else {
mobilestyle.appendChild(document.createTextNode(mobileTrophy));
}
// Получение ссылки на элемент "page_counter"
let pageCounter = document.querySelector('.page_counter');
// Проверка наличия элемента "page_counter"
if (pageCounter) {
// Получение значения атрибута "href" элемента "page_counter"
let hrefValue = pageCounter.getAttribute('href');
console.log(hrefValue);
// Использование регулярного выражения для получения текста после последнего слэша в значении атрибута "href"
let parts = hrefValue.split("/");
let value = parts[0];
let trophy
let xfToken = document.querySelector("input[name=_xfToken").value;
fetch(`https://zelenka.guru/${value}/trophies?_xfRequestUri=%2F${value}%2F&_xfNoRedirect=1&_xfToken=${xfToken}&_xfResponseType=json`)
.then(response => response.json())
.then(data => {
trophy = data.templateHtml;
console.log(trophy);
let parser = new DOMParser();
trophy = parser.parseFromString(trophy, 'text/html');
let overlayScrollElements = trophy.querySelectorAll('.overlayScroll');
let totalCount = overlayScrollElements.length;
if (totalCount > 1) {
overlayScrollElements[0].parentNode.removeChild(overlayScrollElements[0]);
}
let trophies = trophy.querySelectorAll('.trophy');
let trophiesList = [];
trophies.forEach(trophy => {
let trophyid = trophy.id;
console.log(trophyid);
trophiesList.push(trophyid);
});
let trophiesstyle = trophy.querySelectorAll('.trophy-icon');
let trophystyleList = [];
trophiesstyle.forEach(trophy => {
let trophystyle = trophy.style.cssText;
console.log(trophystyle);
trophystyleList.push(trophystyle.replace(/"/g, ''));
});
let titletrophy = trophy.querySelectorAll('.title');
let titleTexttrophyList = [];
titletrophy.forEach(trophy => {
let titleTexttrophy = trophy.textContent;
console.log(titleTexttrophy);
titleTexttrophyList.push(titleTexttrophy);
});
let htmlTrophy = "<ol>";
for (let index = 0; index < trophystyleList.length; index++) {
htmlTrophy += `<li class="trophy DelayedTooltip" title="${titleTexttrophyList[index]}" id="${trophiesList[index]}" tabindex="0"><div class="trophy-icon" style="${trophystyleList[index]}"></div></li>`;
console.log(htmlTrophy);
}
htmlTrophy += "</ol>";
document.querySelector('.memberViewTrophies').innerHTML = htmlTrophy;
})
.catch(error => console.error("Ошибка:", error));
}
})();