CSFD porovnání hodnocení

Show your own ratings on other users ratings list

目前為 2021-04-14 提交的版本,檢視 最新版本

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

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

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

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

你需要先安裝一款使用者腳本管理器擴展,比如 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;
    }

})();