Fix "Show Another Film" Position

Positions the "Show Another Recommendation" link on Criticker.com statically below the Top Recommendation headline.

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Fix "Show Another Film" Position
// @namespace    http://tampermonkey.net/
// @version      0.0.4
// @description  Positions the "Show Another Recommendation" link on Criticker.com statically below the Top Recommendation headline.
// @author       Alsweider
// @match        https://www.criticker.com/
// @match        https://games.criticker.com/
// @icon         https://www.criticker.com/favicon.ico
// @grant        none
// @license MIT
// ==/UserScript==

(function () {
    'use strict';

    const fixLinkPosition = () => {
        const mainRecDiv = document.querySelector('.rc_toprec'); // Hauptcontainer für die Top-Empfehlung
        const header = mainRecDiv?.querySelector('h3.bold'); // Überschrift "Top Recommendation"
        const linkDiv = mainRecDiv?.querySelector('.titlerow_showanother'); // "Show Another Recommendation"-Link

        if (mainRecDiv && header && linkDiv) {
            // Link an der alten Position entfernen, falls noch vorhanden
            document.querySelectorAll('.titlerow_showanother').forEach(el => {
                if (el !== linkDiv) el.remove();
            });

            // Falls der Link noch nicht an der richtigen Stelle ist, verschieben
            if (linkDiv.parentElement !== mainRecDiv) {
                mainRecDiv.insertBefore(linkDiv, header.nextSibling);
                linkDiv.style.marginTop = '-20px'; // Abstand nach oben
                linkDiv.style.marginBottom = '0px'; // Abstand nach unten
            }
        }
    };

    // MutationObserver zur Erkennung von Änderungen auf der Seite
    const observer = new MutationObserver(() => {
        fixLinkPosition();
    });

    observer.observe(document.body, { childList: true, subtree: true });

    // Initiales Fixieren des Links
    window.addEventListener('load', fixLinkPosition);
})();