Yandex Music Explicit Mark Replacement

Replaces the exclamation explicit mark with a classic one on Yandex Music

  1. // ==UserScript==
  2. // @name Yandex Music Explicit Mark Replacement
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.5
  5. // @description Replaces the exclamation explicit mark with a classic one on Yandex Music
  6. // @author wileyfoxyx
  7. // @match https://music.yandex.ru/*
  8. // @match https://music.yandex.com/*
  9. // @match https://music.yandex.by/*
  10. // @match https://music.yandex.kz/*
  11. // @grant none
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16.  
  17. function handleExplicitMarks() {
  18. const explicitElements = document.querySelectorAll('.d-explicit-mark');
  19.  
  20. explicitElements.forEach(element => {
  21. const title = element.title;
  22.  
  23. if (title.includes("УЧАСТНИК ГРУППЫ ПРИЗНАН ИНОАГЕНТОМ") && title.includes("Возрастное ограничение 18+")) {
  24. element.remove();
  25. }
  26. else if (title.includes("ИСПОЛНИТЕЛЬ ПРИЗНАН ИНОАГЕНТОМ") && title.includes("Возрастное ограничение 18+")) {
  27. element.remove();
  28. }
  29. else if (title.includes("THE ARTIST IS RECOGNIZED AS A FOREIGN AGENT") && title.includes("Age restriction 18+")) {
  30. element.remove();
  31. }
  32. else if (title.includes("A BAND MEMBER IS RECOGNIZED AS A FOREIGN AGENT") && title.includes("Age restriction 18+")) {
  33. element.remove();
  34. }
  35. else if (title === "Возрастное ограничение 18+" || title === "Age restriction 18+") {
  36. const newSpan = document.createElement('span');
  37. newSpan.className = 'd-explicit-mark d-explicit-mark--e';
  38. newSpan.title = 'Сервис Яндекс Музыка может содержать информацию, не предназначенную для несовершеннолетних';
  39. element.replaceWith(newSpan);
  40. }
  41. });
  42. }
  43.  
  44. function removeAgentDiv() {
  45. const agentDivs = document.querySelectorAll('.page-artist__agent');
  46.  
  47. agentDivs.forEach(agentDiv => {
  48. const textContent = agentDiv.textContent.trim();
  49.  
  50. if (textContent === "ИСПОЛНИТЕЛЬ ПРИЗНАН ИНОАГЕНТОМ" || textContent === "УЧАСТНИК ГРУППЫ ПРИЗНАН ИНОАГЕНТОМ" || textContent === "THE ARTIST IS RECOGNIZED AS A FOREIGN AGENT" || textContent === "A BAND MEMBER IS RECOGNIZED AS A FOREIGN AGENT") {
  51. agentDiv.remove();
  52. }
  53. });
  54. }
  55.  
  56. handleExplicitMarks();
  57. removeAgentDiv();
  58.  
  59. const observer = new MutationObserver(() => {
  60. handleExplicitMarks();
  61. removeAgentDiv();
  62. });
  63.  
  64. observer.observe(document.body, { childList: true, subtree: true });
  65.  
  66. })();