Title Cleaner

Clean up title strings

此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.cn-greasyfork.org/scripts/516757/1481584/Title%20Cleaner.js

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

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