CSFD porovnání hodnocení

Show your own ratings on other users ratings list

当前为 2021-04-14 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         CSFD porovnání hodnocení
// @namespace    csfd.cz
// @version      0.2
// @description  Show your own ratings on other users ratings list
// @author       SonGokussj4
// @match        http://csfd.cz/*
// @include      *csfd.cz/uzivatel/*
// @icon         http://img.csfd.cz/assets/b1733/images/apple_touch_icon.png
// @grant        none
// @require      http://code.jquery.com/jquery-3.4.1.min.js
// ==/UserScript==


(function() {
    'use strict';
    /* globals jQuery, $, waitForKeyElements */

    // Get Logged-in user
    var loggedInUserHref = document.querySelector('.logged ul.first li h3 a').href;
    var loggedInUserName = loggedInUserHref.split('/')[loggedInUserHref.split('/').length - 2];
    console.log("Logged-in user:", loggedInUserName);

    // Add column to table header
    $(".ui-table-list thead tr th:nth-child(2)").after('<th>Moje</th>');

    var tblData = $('.ui-table-list tbody');
    var idx = 0;
    tblData.find('tr').each( function() {
        idx = idx + 1;
        if(idx === 19) {
            return false;
        }
        var tblRow = $(this);
        var url = tblRow.find('td:nth-child(1) a')[0].href + 'komentare/';
        console.log("Checking URL:", url);
        var vysledek = getStars(url, tblRow);
        console.log("Vysledek:", vysledek);
    });

    function getStars(titleUrl, tblRow) {
        var cislo = "";
        $.ajax({
            url: titleUrl,
            type: 'GET',
            // async: false,
            success: function(data) {
                var kolko = 0;
                try {
                    kolko = $(data).find("#my-rating > div.content > span > span")[0].childElementCount;
                }
                catch(err) {
                }
                cislo = kolko.toString();
                tblRow.find('td').eq(1).after('<td>' + '*'.repeat(cislo) + '</td>');
            }
        });
        return cislo;
    }

})();