Title Cleaner

Clean up title strings

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

  1. // ==UserScript==
  2. // @name Title Cleaner
  3. // @namespace Violentmonkey Scripts
  4. // @match *
  5. // @version 1.0
  6. // @description Clean up title strings
  7. // @require http://code.jquery.com/jquery-1.12.4.min.js
  8. // @license none
  9. // ==/UserScript==
  10.  
  11. function cleanText(input) {
  12. // Add cleanText logic here as defined previously
  13. }
  14.  
  15. function removeExplicit(text) {
  16. return text.replace(/\s*\(Explicit\)/i, '');
  17. }
  18.  
  19. function removeDiacritics(text) {
  20. const diacriticsMap = {
  21. 'á': 'a', 'é': 'e', 'í': 'i', 'ó': 'o', 'ú': 'u',
  22. 'Á': 'A', 'É': 'E', 'Í': 'I', 'Ó': 'O', 'Ú': 'U'
  23. };
  24. return text.replace(/[áéíóúÁÉÍÓÚ]/g, match => diacriticsMap[match]);
  25. }
  26.  
  27. function truncateAfterKeywords(text) {
  28. const keywords = [",", "ft", "feat", "(", "and"];
  29. let truncatePos = text.length;
  30. keywords.forEach(keyword => {
  31. const pos = text.indexOf(keyword);
  32. if (pos !== -1 && pos < truncatePos) truncatePos = pos;
  33. });
  34. return text.slice(0, truncatePos).trim();
  35. }