Располагает ссылки в заданном порядке на странице animestars.org и заменяет ссылку на "Моя коллекция" на "Ответы на вопросы" с новой иконкой. Меняет расположение оставленных комментариев по клику на div ваших комментов. Кнопка коллекций на главной странице перекидывает на коллекции. Добавляет ссылку на Промокоды (внизу сайта, вместо faq). Добавлены специфические размеры для ПК и телефонов.
当前为
// ==UserScript==
// @name Rearrange Links on animestars.org
// @namespace http://tampermonkey.net/
// @version 3.7
// @description Располагает ссылки в заданном порядке на странице animestars.org и заменяет ссылку на "Моя коллекция" на "Ответы на вопросы" с новой иконкой. Меняет расположение оставленных комментариев по клику на div ваших комментов. Кнопка коллекций на главной странице перекидывает на коллекции. Добавляет ссылку на Промокоды (внизу сайта, вместо faq). Добавлены специфические размеры для ПК и телефонов.
// @author eretly
// @icon https://animestars.org/favicon.ico
// @match https://animestars.org/*
// @grant none
// @license MIT
// ==/UserScript==
(function() {
'use strict';
function getElementByXpath(path) {
return document.evaluate(path, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
}
function generateLinkXPath(number) {
return `/html/body/div[2]/ul/li[${number}]/a`;
}
let linksToSwap = [3, 2, 5, 6, 7, 10, 9, 4, 8, 1, 11];
let originalLinks = [];
for (let i = 1; i <= 11; i++) {
let linkXPath = generateLinkXPath(i);
let linkElement = getElementByXpath(linkXPath);
if (linkElement) {
originalLinks.push(linkElement);
}
}
const headerElement = document.querySelector('header');
const linkElement = Array.from(headerElement.querySelectorAll('a')).find(link => link.href.match(/https:\/\/animestars\.org\/user\/(.+)\/$/));
if (linkElement) {
const oldHref = linkElement.href;
const usernameMatch = oldHref.match(/https:\/\/animestars\.org\/user\/(.+)\/$/);
if (usernameMatch) {
const username = usernameMatch[1];
linkElement.href = `https://animestars.org/user/${username}/watchlist/`;
}
}
const myListsLinkXPath = '/html/body/div[2]/ul/li[6]/a';
const myListsLink = getElementByXpath(myListsLinkXPath);
if (myListsLink) {
myListsLink.childNodes[1].textContent = "Мои списки";
}
const collectionLinkXPath = generateLinkXPath(10);
const collectionLink = getElementByXpath(collectionLinkXPath);
if (collectionLink) {
collectionLink.outerHTML = `
<a href="https://animestars.org/faq/" style="display: flex; flex-direction: column; justify-content: center; align-items: center; border-radius: 6px; padding: 8.3px; text-align: center; white-space: nowrap; background-color: var(--ui-bg-darker); box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.1); font-size: 13px; color: var(--tt); text-decoration: none; transition: all .3s; height: 100%; position: relative;">
<svg xmlns="http://www.w3.org/2000/svg" width="26" height="26" viewBox="0 0 14 14" class="fal" style="opacity: 0.27; position: absolute; top: 8px;">
<circle cx="7" cy="7" r="6.5" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"/>
<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" d="M5.5 5.5A1.5 1.5 0 1 1 7 7v1"/>
<path fill="currentColor" d="M7 9.5a.75.75 0 1 0 .75.75A.76.76 0 0 0 7 9.5Z"/>
</svg>
<span style="margin-top: 30px;">Ответы на вопросы</span>
</a>`;
}
const promoCodeLinkXPath = '/html/body/div[1]/div/footer/a[1]';
const promoCodeLink = getElementByXpath(promoCodeLinkXPath);
if (promoCodeLink) {
promoCodeLink.href = "https://animestars.org/promo_codes";
promoCodeLink.textContent = "Промокоды";
}
const noLabelElements = document.querySelectorAll('.usp__list .no-label');
noLabelElements.forEach(element => {
element.style.display = 'none';
});
const commentsLinkXPath = '//*[@id="userinfo"]/div[1]/div/ul[2]/li/a';
const commentsLink = getElementByXpath(commentsLinkXPath);
const commentsContainerUserinfoXPath = '//*[@id="userinfo"]/div[1]/div/div[2]/div/div[3]';
const commentsContainerUserinfo = getElementByXpath(commentsContainerUserinfoXPath);
const commentsContainerDleContentXPath = '//*[@id="dle-content"]/div[1]/div/div[2]/div/div[3]';
const commentsContainerDleContent = getElementByXpath(commentsContainerDleContentXPath);
const commentsLinkDleContentXPath = '//*[@id="dle-content"]/div[1]/div/ul[2]/li/a';
const commentsLinkDleContent = getElementByXpath(commentsLinkDleContentXPath);
function addLinkToContainer(container, link) {
if (container && link) {
const commentsLinkWrapper = document.createElement('a');
commentsLinkWrapper.href = link.href;
commentsLinkWrapper.style.position = "absolute";
commentsLinkWrapper.style.width = "100%";
commentsLinkWrapper.style.height = "100%";
commentsLinkWrapper.style.top = "0";
commentsLinkWrapper.style.left = "0";
commentsLinkWrapper.style.cursor = "pointer";
commentsLinkWrapper.style.borderRadius = "5px";
commentsLinkWrapper.style.backgroundColor = "transparent";
commentsLinkWrapper.style.display = "flex";
commentsLinkWrapper.style.justifyContent = "center";
commentsLinkWrapper.style.alignItems = "center";
container.style.position = "relative";
if (!container.querySelector('a[href*="lastcomments"]')) {
container.appendChild(commentsLinkWrapper);
}
}
}
addLinkToContainer(commentsContainerUserinfo, commentsLink);
addLinkToContainer(commentsContainerDleContent, commentsLinkDleContent);
const style = document.createElement('style');
style.textContent = `
.login__menu a {
min-width: 105px;
}
@media (max-width: 768px) {
.login__menu {
display: flex;
flex-wrap: wrap;
gap: 0px;
}
.login__menu a {
flex-basis: calc(50% - 1px);
justify-content: center;
box-sizing: border-box;
}
.login__menu a:last-child:nth-child(odd) {
flex-basis: 100%;
}
}
a:hover, a:focus {
color: #9e294f !important;
text-decoration: none !important;
}
a[style*="Ответы на вопросы"]:hover {
color: #9e294f !important;
text-decoration: none !important;
}
`;
document.head.appendChild(style);
linksToSwap.forEach((newPosition, index) => {
let parent = originalLinks[index].parentNode;
if (originalLinks[newPosition - 1] && parent) {
parent.replaceChild(originalLinks[newPosition - 1].cloneNode(true), originalLinks[index]);
}
});
})();