Rating Blur Script

Blur user and critics ratings by default and unblur on hover for filmweb.pl, imdb.com, and letterboxd.com.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         Rating Blur Script
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Blur user and critics ratings by default and unblur on hover for filmweb.pl, imdb.com, and letterboxd.com.
// @author       Balbi
// @match        *://*.filmweb.pl/*
// @match        *://*.imdb.com/*
// @match        *://*.letterboxd.com/*
// @icon         https://github.com/Balbiii/Movie-Rating-Blur-Extension/blob/main/icons/icon48.png?raw=true
// @license      GNUv3
// @grant        none
// ==/UserScript==


(function() {
    'use strict';

    function applyInitialBlur(element) {
        element.style.filter = 'blur(8px)';
        element.style.visibility = 'hidden';
    }

    function applyBlurWithTransition(element) {
        element.style.transition = 'filter 0.3s ease';
        element.style.filter = 'blur(8px)';
        element.style.visibility = 'visible';
        element.addEventListener('mouseover', function() {
            element.style.filter = 'blur(0)';
        });
        element.addEventListener('mouseout', function() {
            element.style.filter = 'blur(8px)';
        });
    }

    function observeAndApplyBlur(selector) {
        const observer = new MutationObserver((mutations, obs) => {
            const elements = document.querySelectorAll(selector);
            if (elements.length) {
                elements.forEach(element => {
                    applyInitialBlur(element);
                    void element.offsetWidth;
                    applyBlurWithTransition(element);
                });
                obs.disconnect();
            }
        });

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

    // Blur ratings on filmweb.pl
    observeAndApplyBlur('.filmCoverSection__ratings');

    // Blur ratings on imdb.com
    observeAndApplyBlur('.sc-3a4309f8-1.dggvUg');

    // Blur ratings on letterboxd.com
    observeAndApplyBlur('.section.ratings-histogram-chart');
})();