Youtube block all, not interested in all, dismiss all

不感兴趣, दिलचस्पी नहीं है, 興味なし, 관심 없음, Kein Interesse,لا يهمني,Pas intéressé, Не интересует, Não tenho interesse, No me interesa

  1. // ==UserScript==
  2. // @name Youtube block all, not interested in all, dismiss all
  3. // @name:zh-CN Youtube block all, not interested in all, dismiss all
  4. // @name:zh-TW Youtube block all, not interested in all, dismiss all
  5. // @name:ja Youtube block all, not interested in all, dismiss all
  6. // @name:ko Youtube block all, not interested in all, dismiss all
  7. // @name:de Youtube block all, not interested in all, dismiss all
  8. // @name:es Youtube block all, not interested in all, dismiss all
  9. // @name:eo Youtube block all, not interested in all, dismiss all
  10. // @name:fr Youtube block all, not interested in all, dismiss all
  11. // @name:it Youtube block all, not interested in all, dismiss all
  12. // @name:ru Youtube block all, not interested in all, dismiss all
  13. // @name:vi Youtube block all, not interested in all, dismiss all
  14. // @name:pt-BR Youtube block all, not interested in all, dismiss all
  15. // @name:id Youtube block all, not interested in all, dismiss all
  16. // @name:ar Youtube block all, not interested in all, dismiss all
  17. // @name:bg Youtube block all, not interested in all, dismiss all
  18. // @name:cs Youtube block all, not interested in all, dismiss all
  19. // @name:tr Youtube block all, not interested in all, dismiss all
  20. // @name:el Youtube block all, not interested in all, dismiss all
  21. // @name:hu Youtube block all, not interested in all, dismiss all
  22. // @name:th Youtube block all, not interested in all, dismiss all
  23. // @icon https://img.icons8.com/?size=100&id=9a46bTk3awwI&format=png&color=000000
  24. // @version 1.2.1
  25. // @description 不感兴趣, दिलचस्पी नहीं है, 興味なし, 관심 없음, Kein Interesse,لا يهمني,Pas intéressé, Не интересует, Não tenho interesse, No me interesa
  26. // @description:zh-CN 不感兴趣, दिलचस्पी नहीं है, 興味なし, 관심 없음, Kein Interesse,لا يهمني,Pas intéressé, Не интересует, Não tenho interesse, No me interesa
  27. // @description:zh-TW 不感兴趣, दिलचस्पी नहीं है, 興味なし, 관심 없음, Kein Interesse,لا يهمني,Pas intéressé, Не интересует, Não tenho interesse, No me interesa
  28. // @description:ja 不感兴趣, दिलचस्पी नहीं है, 興味なし, 관심 없음, Kein Interesse,لا يهمني,Pas intéressé, Не интересует, Não tenho interesse, No me interesa
  29. // @description:ko 不感兴趣, दिलचस्पी नहीं है, 興味なし, 관심 없음, Kein Interesse,لا يهمني,Pas intéressé, Не интересует, Não tenho interesse, No me interesa
  30. // @description:de 不感兴趣, दिलचस्पी नहीं है, 興味なし, 관심 없음, Kein Interesse,لا يهمني,Pas intéressé, Не интересует, Não tenho interesse, No me interesa
  31. // @description:es 不感兴趣, दिलचस्पी नहीं है, 興味なし, 관심 없음, Kein Interesse,لا يهمني,Pas intéressé, Не интересует, Não tenho interesse, No me interesa
  32. // @description:eo 不感兴趣, दिलचस्पी नहीं है, 興味なし, 관심 없음, Kein Interesse,لا يهمني,Pas intéressé, Не интересует, Não tenho interesse, No me interesa
  33. // @description:fr 不感兴趣, दिलचस्पी नहीं है, 興味なし, 관심 없음, Kein Interesse,لا يهمني,Pas intéressé, Не интересует, Não tenho interesse, No me interesa
  34. // @description:it 不感兴趣, दिलचस्पी नहीं है, 興味なし, 관심 없음, Kein Interesse,لا يهمني,Pas intéressé, Не интересует, Não tenho interesse, No me interesa
  35. // @description:ru 不感兴趣, दिलचस्पी नहीं है, 興味なし, 관심 없음, Kein Interesse,لا يهمني,Pas intéressé, Не интересует, Não tenho interesse, No me interesa
  36. // @description:vi 不感兴趣, दिलचस्पी नहीं है, 興味なし, 관심 없음, Kein Interesse,لا يهمني,Pas intéressé, Не интересует, Não tenho interesse, No me interesa
  37. // @description:pt-BR 不感兴趣, दिलचस्पी नहीं है, 興味なし, 관심 없음, Kein Interesse,لا يهمني,Pas intéressé, Не интересует, Não tenho interesse, No me interesa
  38. // @description:id 不感兴趣, दिलचस्पी नहीं है, 興味なし, 관심 없음, Kein Interesse,لا يهمني,Pas intéressé, Не интересует, Não tenho interesse, No me interesa
  39. // @description:ar 不感兴趣, दिलचस्पी नहीं है, 興味なし, 관심 없음, Kein Interesse,لا يهمني,Pas intéressé, Не интересует, Não tenho interesse, No me interesa
  40. // @description:bg 不感兴趣, दिलचस्पी नहीं है, 興味なし, 관심 없음, Kein Interesse,لا يهمني,Pas intéressé, Не интересует, Não tenho interesse, No me interesa
  41. // @description:cs 不感兴趣, दिलचस्पी नहीं है, 興味なし, 관심 없음, Kein Interesse,لا يهمني,Pas intéressé, Не интересует, Não tenho interesse, No me interesa
  42. // @description:tr 不感兴趣, दिलचस्पी नहीं है, 興味なし, 관심 없음, Kein Interesse,لا يهمني,Pas intéressé, Не интересует, Não tenho interesse, No me interesa
  43. // @description:el 不感兴趣, दिलचस्पी नहीं है, 興味なし, 관심 없음, Kein Interesse,لا يهمني,Pas intéressé, Не интересует, Não tenho interesse, No me interesa
  44. // @description:hu 不感兴趣, दिलचस्पी नहीं है, 興味なし, 관심 없음, Kein Interesse,لا يهمني,Pas intéressé, Не интересует, Não tenho interesse, No me interesa
  45. // @description:th 不感兴趣, दिलचस्पी नहीं है, 興味なし, 관심 없음, Kein Interesse,لا يهمني,Pas intéressé, Не интересует, Não tenho interesse, No me interesa
  46. // @author evanlai
  47. // @match https://www.youtube.com/*
  48. // @exclude https://www.youtube.com/shorts/*
  49. // @require https://openuserjs.org/src/libs/sizzle/GM_config.js
  50. // @require https://cdn.jsdelivr.net/npm/sweetalert@2.1.2/dist/sweetalert.min.js
  51. // @require https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js
  52. // @grant GM_getValue
  53. // @grant GM_setValue
  54. // @grant GM_addStyle
  55. // @namespace https://greatest.deepsurf.us/users/732057
  56. // ==/UserScript==
  57.  
  58. if (window.trustedTypes && window.trustedTypes.createPolicy) {
  59. window.trustedTypes.createPolicy('default', {
  60. createHTML: string => string,
  61. createScriptURL: string => string,
  62. createScript: string => string,
  63. });
  64. }
  65.  
  66. GM_addStyle(`
  67. #J_dismiss_all,#J_open_settings{
  68. display: inline-flex;
  69. margin-left: 2em;
  70. align-items: center;
  71. vertical-align: middle;
  72. color: gray;
  73. font-size: 2em;
  74. line-height: 2em;
  75. text-decoration: none;
  76. }
  77.  
  78. #J_open_settings{
  79. margin-top:1px;
  80. margin-left: 1em;
  81. }
  82.  
  83. #Y_settings > div{
  84. margin-bottom:10px;
  85. }
  86. .config-current-value{
  87. font-weight: bold;
  88. color:blueviolet;
  89. }
  90. `);
  91.  
  92. function wait(ms) {
  93. return new Promise((resolve) => {
  94. setTimeout(resolve, ms);
  95. });
  96. }
  97. function inArray(array, element) {
  98. return array.indexOf(element) !== -1;
  99. }
  100.  
  101. function toNumber(value){
  102. let num = Number(value);
  103.  
  104. if (isNaN(num) || !isFinite(num)) {
  105. return 0;
  106. }
  107.  
  108. return num;
  109. }
  110.  
  111. var runflag = true;
  112. var firstEnterThisPage = true;
  113. async function dismissCurrent() {
  114. let clickedSomething = false;
  115. let foundAusblenden = false;
  116.  
  117. for (const item of document.querySelectorAll('ytd-menu-service-item-renderer')) {
  118.  
  119. if (item.icon === (GM_getValue('videoOrCreator') === "video" ? "NOT_INTERESTED" : "REMOVE")) {
  120. clickedSomething = true;
  121. item.click();
  122. }
  123. // else if (item.icon === "__") {
  124. // foundAusblenden = item;
  125. // }
  126. }
  127. if (!clickedSomething && foundAusblenden !== false) {
  128. foundAusblenden.click();
  129. }
  130. return true;
  131. }
  132. async function dismissAll() {
  133. let list = document.querySelectorAll('ytd-rich-grid-media button[aria-label]');
  134.  
  135. while (firstEnterThisPage && list.length < 1) {
  136. await wait(1000);
  137. list = document.querySelectorAll('ytd-rich-grid-media button[aria-label]');
  138. }
  139. firstEnterThisPage = false;
  140.  
  141. let i = 0;
  142. for (let item of list) {
  143. item.click();
  144. await wait(50);
  145. await dismissCurrent();
  146. await wait(100);
  147. i++;
  148. if (i >= parseInt(GM_getValue('maximumNumberOfBlocksPerOperation'))) break;
  149. }
  150. if (runflag) {
  151. runflag = false;
  152. // await dismissAll();
  153. }
  154. window.location.reload();
  155. }
  156.  
  157. window.dismissAll = function() {
  158. dismissAll();
  159. }
  160. window.openGmcSettings = function() {
  161. let settings = document.getElementById('J_settings');
  162. settings.style.display = '';
  163.  
  164. swal({
  165. content: settings,
  166. buttons: {
  167. cancel: "close",
  168. },
  169. }).then(async (value) => {
  170. settings.style.display = 'none';
  171. });
  172. }
  173.  
  174. function createButton() {
  175. var elementForInsertNewButton = document.querySelector('#start') || document.querySelector('#logo-icon') || document.querySelector('#country-code');
  176.  
  177. var dismissAllLink = document.createElement('a');
  178. dismissAllLink.id = 'J_dismiss_all';
  179. dismissAllLink.href = 'javascript:';
  180. dismissAllLink.onclick = window.dismissAll;
  181. dismissAllLink.textContent = '⟳';
  182.  
  183. var openGmcSettingsLink = document.createElement('a');
  184. openGmcSettingsLink.id = 'J_open_settings';
  185. openGmcSettingsLink.href = 'javascript:';
  186. openGmcSettingsLink.onclick = window.openGmcSettings;
  187. openGmcSettingsLink.textContent = '⋮';
  188.  
  189. elementForInsertNewButton.appendChild(dismissAllLink);
  190. elementForInsertNewButton.appendChild(openGmcSettingsLink);
  191. }
  192.  
  193. createButton();
  194.  
  195. // settings
  196. document.addEventListener('alpine:init', () => {
  197. var maximumNumberOfBlocksPerOperation = GM_getValue('maximumNumberOfBlocksPerOperation');
  198. if(typeof maximumNumberOfBlocksPerOperation === 'undefined') maximumNumberOfBlocksPerOperation = '12';
  199. GM_setValue('maximumNumberOfBlocksPerOperation', maximumNumberOfBlocksPerOperation);
  200. Alpine.store('maximumNumberOfBlocksPerOperation', {
  201. value: maximumNumberOfBlocksPerOperation,
  202. valueHasChanged(){
  203. toNumber(this.value).toString();
  204. GM_setValue('maximumNumberOfBlocksPerOperation', toNumber(this.value).toString());
  205. }
  206. })
  207.  
  208.  
  209. var autoMode = GM_getValue('autoMode') === 'on' ? 'on' : 'off';
  210. GM_setValue('autoMode', autoMode);
  211.  
  212. Alpine.store('autoMode', {
  213. value: autoMode,
  214. async toggle() {
  215.  
  216. let oldvalue = this.value;
  217. this.value = this.value === 'on' ? 'off' : 'on';
  218. GM_setValue('autoMode', this.value);
  219.  
  220. if(this.value === 'on') {
  221. await wait(1000);
  222. window.location.reload();
  223. }
  224.  
  225. }
  226. })
  227.  
  228.  
  229. var videoOrCreator = GM_getValue('videoOrCreator') === 'creator' ? 'creator' : 'video';
  230. GM_setValue('videoOrCreator', videoOrCreator);
  231.  
  232.  
  233. Alpine.store('videoOrCreator', {
  234. value: videoOrCreator,
  235. toggle() {
  236. let oldvalue = this.value;
  237. this.value = this.value === "creator" ? "video" : "creator";
  238. GM_setValue('videoOrCreator', this.value);
  239. }
  240. })
  241.  
  242. if(GM_getValue('autoMode') === 'on') window.dismissAll()
  243. });
  244.  
  245. var gmcSettings = document.createElement('div');
  246. gmcSettings.id = 'J_settings';
  247. gmcSettings.style.display = 'none';
  248.  
  249. gmcSettings.innerHTML = `
  250. <div id="Y_settings">
  251. <div>
  252. <span>Maximum number of blocks per operation:</span>
  253. <input type="text" x-model="$store.maximumNumberOfBlocksPerOperation.value" x-init="$watch('$store.maximumNumberOfBlocksPerOperation.value', value => $store.maximumNumberOfBlocksPerOperation.valueHasChanged())">
  254. </div>
  255. <div>
  256. <button style x-data @click="$store.videoOrCreator.toggle()">Block video or creator: <span class="config-current-value" x-text="$store.videoOrCreator.value.toUpperCase()"></span></button>
  257. </div>
  258. <div>
  259. <button style="display: flex; align-items: center; margin:auto" x-data @click="$store.autoMode.toggle()"><span>Automatically refresh the page and process all: </span><img x-show="$store.autoMode.value === 'on'" style='display:inline-block; width:1.5em; height:1.5em; line-height:1.5em' src='https://img.icons8.com/?size=100&id=12226&format=png&color=000000'><span class="config-current-value" x-text="$store.autoMode.value.toUpperCase()"></span></button>
  260. </div>
  261. </div>
  262.  
  263.  
  264. `;
  265. document.querySelector('body').appendChild(gmcSettings);