Title Cleaner

Clean up title strings

Ten skrypt nie powinien być instalowany bezpośrednio. Jest to biblioteka dla innych skyptów do włączenia dyrektywą meta // @require https://update.greatest.deepsurf.us/scripts/516757/1481584/Title%20Cleaner.js

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

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

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        Title Cleaner
// @namespace   Violentmonkey Scripts
// @match       *
// @version     1.0
// @description Clean up title strings
// @require      http://code.jquery.com/jquery-1.12.4.min.js
// @license      none
// ==/UserScript==

function cleanText(input) {
    // Add cleanText logic here as defined previously
}

function removeExplicit(text) {
    return text.replace(/\s*\(Explicit\)/i, '');
}

function removeDiacritics(text) {
    const diacriticsMap = {
        'á': 'a', 'é': 'e', 'í': 'i', 'ó': 'o', 'ú': 'u',
        'Á': 'A', 'É': 'E', 'Í': 'I', 'Ó': 'O', 'Ú': 'U'
    };
    return text.replace(/[áéíóúÁÉÍÓÚ]/g, match => diacriticsMap[match]);
}

function truncateAfterKeywords(text) {
    const keywords = [",", "ft", "feat", "(", "and"];
    let truncatePos = text.length;
    keywords.forEach(keyword => {
        const pos = text.indexOf(keyword);
        if (pos !== -1 && pos < truncatePos) truncatePos = pos;
    });
    return text.slice(0, truncatePos).trim();
}