Greasy Fork is available in English.

YouTube Delete Liked Videos

Adds a button to delete liked videos on YouTube

  1. // ==UserScript==
  2. // @name YouTube Delete Liked Videos
  3. // @name:zh-TW YouTube 刪除已喜歡的影片
  4. // @name:zh-HK YouTube 刪除已喜歡的影片
  5. // @name:zh-CN YouTube 删除已喜欢的视频
  6. // @name:ja YouTube 好きな動画を削除する
  7. // @name:kr YouTube 좋아하는 동영상 삭제하기
  8. // @name:ar YouTube حذف الفيديوهات المعجب بها
  9. // @name:bg YouTube Изтриване на харесани видеоклипове
  10. // @name:cs YouTube Smazání oblíbených videí
  11. // @name:da YouTube Slet kanalliked videoer
  12. // @name:de YouTube Löschen von gemochten Videos
  13. // @name:tel YouTube లైక్ వీడియోలను తొలగించు
  14. // @name:es YouTube Eliminar vídeos marcados como gustados
  15. // @name:en YouTube Delete Liked Videos
  16. // @name:fr YouTube Supprimer les vidéos aimées
  17. // @name:fr-CA YouTube Supprimer les vidéos aimées
  18. // @name:he YouTube מחק סרטונים שאהבת
  19. // @name:hu YouTube Kedvelt videók törlése
  20. // @name:id YouTube Hapus Video yang Disukai
  21. // @name:it YouTube Elimina i video preferiti
  22. // @name:ko YouTube 좋아요 표시한 동영상 삭제하기
  23. // @name:nb YouTube Slett likte videoer
  24. // @name:nl YouTube Liked video's verwijderen
  25. // @name:pl YouTube Usuń polubione filmy
  26. // @name:pt-BR YouTube Excluir vídeos curtidos
  27. // @name:ro YouTube Ștergeți videoclipurile apreciate
  28. // @name:ru YouTube Удаление понравившихся видео
  29. // @name:sk YouTube Vymazanie obľúbených videí
  30. // @name:sr YouTube Брисање видеа која су свиђала
  31. // @name:sv YouTube Ta bort gillade videor
  32. // @name:th YouTube ลบวิดีโอที่ชอบ
  33. // @name:tr YouTube Beğenilen Videoları Sil
  34. // @name:uk YouTube Видалення вподобаних відео
  35. // @name:ug YouTube قوشۇلغان ۋىديولارنى ئۆچۈرۈش
  36. // @name:vi YouTube Xóa Video Đã Thích
  37. // @name:hi YouTube चाहते वीडियो हटाएं
  38. // @description:zh-TW 刪除已喜歡的影片 YouTube
  39. // @description:zh-HK 刪除已喜歡的影片 YouTube
  40. // @description:zh-CN 删除已喜欢的视频 YouTube
  41. // @description:ja 好きな動画を削除する YouTube
  42. // @description:kr 좋아하는 동영상 삭제하기 YouTube
  43. // @description:ar حذف الفيديوهات المعجب بها على YouTube
  44. // @description:bg Изтриване на харесани видеоклипове в YouTube
  45. // @description:cs Smazání oblíbených videí na YouTube
  46. // @description:da Slet kanalliked videoer på YouTube
  47. // @description:de Löschen von gemochten Videos auf YouTube
  48. // @description:tel లైక్ వీడియోలను తొలగించు YouTube
  49. // @description:es Eliminar vídeos marcados como gustados en YouTube
  50. // @description:en Delete liked videos on YouTube
  51. // @description:fr Supprimer les vidéos aimées sur YouTube
  52. // @description:fr-CA Supprimer les vidéos aimées sur YouTube
  53. // @description:he מחק סרטונים שאהבת ב-YouTube
  54. // @description:hu Kedvelt videók törlése a YouTube-on
  55. // @description:id Hapus Video yang Disukai di YouTube
  56. // @description:it Elimina i video preferiti su YouTube
  57. // @description:ko 좋아요 표시한 동영상 삭제하기 YouTube
  58. // @description:nb Slett likte videoer på YouTube
  59. // @description:nl Verwijder gelikete video's op YouTube
  60. // @description:pl Usuń polubione filmy na YouTube
  61. // @description:pt-BR Excluir vídeos curtidos no YouTube
  62. // @description:ro Ștergeți videoclipurile apreciate pe YouTube
  63. // @description:ru Удаление понравившихся видео на YouTube
  64. // @description:sk Vymazanie obľúbených videí na YouTube
  65. // @description:sr Брисање видеа која су свиђала на Јутубу
  66. // @description:sv Ta bort gillade videor på YouTube
  67. // @description:th ลบวิดีโอที่ชอบใน YouTube
  68. // @description:tr Beğenilen Videoları Sil YouTube
  69. // @description:uk Видалення вподобаних відео на YouTube
  70. // @description:ug يوتۇبدا قوشۇلغان ۋىديولارنى ئۆچۈرۈڭ
  71. // @description:vi Xóa Video Đã Thích trên YouTube
  72. // @description:hi चाहते वीडियो हटाएं YouTube
  73. // @description:fr Supprimer les vidéos aimées sur YouTube
  74. // @description:bn পছন্দ করা ভিডিও মুছে ফেলুন YouTube
  75. // @namespace http://tampermonkey.net/
  76. // @license MIT
  77. // @version 1.0
  78. // @description Adds a button to delete liked videos on YouTube
  79. // @author toxtodo
  80. // @match https://www.youtube.com/playlist?list=LL*
  81. // @grant none
  82. // ==/UserScript==
  83.  
  84. (function() {
  85. 'use strict';
  86.  
  87. function createButton() {
  88. var button = document.createElement('button');
  89. button.innerHTML = 'Delete Liked Videos';
  90. button.style.position = 'relative';
  91. button.style.zIndex = '1000';
  92. button.style.padding = '5px 10px';
  93. button.style.backgroundColor = '#ff0000';
  94. button.style.color = '#ffffff';
  95. button.style.border = 'none';
  96. button.style.borderRadius = '3px';
  97. button.style.cursor = 'pointer';
  98. button.style.marginLeft = '10px';
  99.  
  100. button.onclick = function() {
  101. deleteLikedVideos();
  102. };
  103.  
  104. var targetElement = document.querySelector('#end');
  105.  
  106. if (targetElement) {
  107. targetElement.insertBefore(button, targetElement.firstChild);
  108. } else {
  109. console.log('Target element not found.');
  110. }
  111. }
  112.  
  113. function sleep(ms) {
  114. return new Promise(resolve => setTimeout(resolve, ms));
  115. }
  116.  
  117. async function deleteLikedVideos() {
  118. 'use strict';
  119. var oldItems = document.querySelectorAll('#primary ytd-playlist-video-renderer yt-icon-button.dropdown-trigger > button[aria-label]');
  120. var newItems = document.querySelectorAll('#menu yt-icon-button.dropdown-trigger > button#button');
  121. var items;
  122. if (oldItems.length > 0) {
  123. items = oldItems;
  124. } else if (newItems.length > 0) {
  125. items = newItems;
  126. } else {
  127. console.log('No items found to delete.');
  128. return;
  129. }
  130. for (var i = 0; i < items.length; i++) {
  131. items[i].click();
  132. await sleep(100);
  133. var listBoxOld = document.querySelector('tp-yt-paper-listbox.style-scope.ytd-menu-popup-renderer');
  134. var listBoxNew = document.querySelector('tp-yt-paper-listbox#items');
  135. var listBox = listBoxOld || listBoxNew;
  136. if (listBox && listBox.lastElementChild) {
  137. listBox.lastElementChild.click();
  138. } else {
  139. console.log('No delete option found.');
  140. }
  141. await sleep(500);
  142. }
  143. }
  144.  
  145. window.addEventListener('load', createButton);
  146.  
  147. })();