Rearrange Links on animestars.org

Располагает ссылки в заданном порядке на странице animestars.org и заменяет ссылку на "Моя коллекция" на "Ответы на вопросы" с новой иконкой. Добавлены специфические размеры для ПК и телефонов.

目前為 2024-10-06 提交的版本,檢視 最新版本

// ==UserScript==
// @name         Rearrange Links on animestars.org
// @namespace    http://tampermonkey.net/
// @version      2.9
// @description  Располагает ссылки в заданном порядке на странице animestars.org и заменяет ссылку на "Моя коллекция" на "Ответы на вопросы" с новой иконкой. Добавлены специфические размеры для ПК и телефонов.
// @author       eretly
// @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 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%;">
                <svg xmlns="http://www.w3.org/2000/svg" width="25" height="25" viewBox="0 0 14 14" class="fal" style="opacity: 0.9; margin-bottom: 4px;">
                    <circle cx="7" cy="7" r="6.5" fill="none" stroke="#b3b3b3" stroke-linecap="round" stroke-linejoin="round"/>
                    <path fill="none" stroke="#b3b3b3" stroke-linecap="round" stroke-linejoin="round" d="M5.5 5.5A1.5 1.5 0 1 1 7 7v1"/>
                    <path fill="#b3b3b3" d="M7 9.5a.75.75 0 1 0 .75.75A.76.76 0 0 0 7 9.5Z"/>
                </svg>
                Ответы на вопросы
            </a>`;
    }

const style = document.createElement('style');
style.textContent = `
    .login__menu a[href="https://animestars.org/faq/"]:hover {
        color: var(--accent);
        text-decoration: none;
    }
    .login__menu a[href="https://animestars.org/newposts/"],
    .login__menu a[href="https://animestars.org/index.php?action=logout"] {
        min-width: 100px;
    }
    @media (max-width: 768px) {
        .login__menu {
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            width: 100%;
            gap: 1px;
        }
        .login__menu a {
            display: flex;
            justify-content: center;
            align-items: center;
            padding: 10px 5px;
            text-align: center;
            border: 1px solid rgba(0, 0, 0, 0.1);
            background-color: #fff;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        .login__menu a:last-child:nth-child(odd) {
            grid-column: 1 / -1;
        }
    }
`;
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]);
        }
    });

})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址