F95zone Ratings on Bookmarks Page

Display game ratings on F95zone bookmarks page

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         F95zone Ratings on Bookmarks Page
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Display game ratings on F95zone bookmarks page
// @match        https://f95zone.to/account/bookmarks*
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    // When the document is ready...
    $(document).ready(function() {
        // Loop through each bookmark list item.
        // In our case, each bookmark is an <li> with the class "block-row"
        $('ol.listPlain > li.block-row').each(function() {
            var $bookmarkItem = $(this);
            // Find the thread title link within this bookmark item.
            var $titleLink = $bookmarkItem.find('.contentRow-title a').first();
            if (!$titleLink.length) return; // If no title link is found, skip

            // Get the thread URL from the href attribute.
            var threadUrl = $titleLink.attr('href');
            if (!threadUrl) return;

            // Create a placeholder element where the rating will be displayed.
            var $ratingSpan = $('<span class="thread-rating" style="margin-left: 5px; color: #888;"></span>');
            // Insert it immediately after the title link.
            $titleLink.after($ratingSpan);

            // Use jQuery's AJAX to load the thread page.
            $.ajax({
                url: threadUrl,
                method: 'GET',
                success: function(response) {
                    // Create a temporary container and set its HTML to the response.
                    var $tempDiv = $('<div></div>').html(response);
                    // Look for the element with the rating info.
                    var $ratingElem = $tempDiv.find('[data-xf-init="rating"]');
                    if ($ratingElem.length) {
                        // Get the value from the data-initial-rating attribute.
                        var rating = $ratingElem.attr('data-initial-rating');
                        if (rating !== undefined) {
                            $ratingSpan.text('[Rating: ' + rating + ']');
                        } else {
                            $ratingSpan.text('[No rating]');
                        }
                    } else {
                        $ratingSpan.text('[Rating not found]');
                    }
                },
                error: function() {
                    $ratingSpan.text('[Error loading rating]');
                }
            });
        });
    });
})();