Greasy Fork is available in English.
Ну и говна кусок этот код
当前为
// ==UserScript==
// @name LZT_Trophy
// @namespace http://tampermonkey.net/
// @version 0.4
// @description Ну и говна кусок этот код
// @author llimonix
// @match https://zelenka.guru/*
// @icon https://cdn-icons-png.flaticon.com/512/2830/2830919.png
// @grant none
// @license MIT
// ==/UserScript==
(function() {
// Получение ссылки на элемент "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;
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;
trophiesList.push(trophyid);
});
let trophiesstyle = trophy.querySelectorAll('.trophy-icon');
let trophystyleList = [];
trophiesstyle.forEach(trophy => {
let trophystyle = trophy.style.cssText;
trophystyleList.push(trophystyle.replace(/"/g, ''));
});
let titletrophy = trophy.querySelectorAll('.title');
let titleTexttrophyList = [];
titletrophy.forEach(trophy => {
let titleTexttrophy = trophy.textContent;
titleTexttrophyList.push(titleTexttrophy);
});
console.log(screen.width)
let htmlTrophy = ''
if( screen.width <= 480 ) {
// Видимость трофеев в мобильной версии
let mobileTrophy = '.Responsive .memberViewTrophies {display: block!important;} .memberViewTrophies {position: relative;margin: 20px0 0;overflow-x: scroll;white-space: nowrap;}',
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));
}
//htmlTrophy = `<div class="ToggleTriggerAnchor bbCodeSpoilerContainer">
//<button type="button" class="button bbCodeSpoilerButton ToggleTrigger Tooltip JsOnly LZT_Trophy" title="" data-target="> .SpoilerTarget" data-cachedtitle="Раскрыть или скрыть спойлер"><span><span class="SpoilerTitle">Трофеи</span>
//<span class="arrowWidget"></span>
//</span>
//</button>
//<div class="SpoilerTarget bbCodeSpoilerText" style="display: none;">`
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>`;
}
htmlTrophy += "</ol>";
//htmlTrophy += "</div></div>";
document.querySelector('.memberViewTrophies').innerHTML = htmlTrophy;
} else {
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>`;
}
htmlTrophy += "</ol>";
document.querySelector('.memberViewTrophies').innerHTML = htmlTrophy;
}
//let spoiler = document.querySelector('button.button.LZT_Trophy');
//if (spoiler){
// spoiler.addEventListener('click', function(event){
// console.log(event.target.closest('.bbCodeSpoilerContainer'));
// $(event.target.closest('.bbCodeSpoilerContainer').querySelector('.SpoilerTarget.bbCodeSpoilerText')).toggle();
// });
//}
})
.catch(error => console.error("Ошибка:", error));
}
})();