Rating Blur Script

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==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');
})();