Youtube block all, not interested in all, dismiss all

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

当前为 2024-09-23 提交的版本,查看 最新版本

  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.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. // @require https://openuserjs.org/src/libs/sizzle/GM_config.js
  49. // @require https://cdn.jsdelivr.net/npm/sweetalert@2.1.2/dist/sweetalert.min.js
  50. // @require https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js
  51. // @grant GM_getValue
  52. // @grant GM_setValue
  53. // @grant GM_addStyle
  54. // @namespace https://greasyfork.org/users/732057
  55. // ==/UserScript==
  56.  
  57. if (window.trustedTypes && window.trustedTypes.createPolicy) {
  58. window.trustedTypes.createPolicy('default', {
  59. createHTML: string => string,
  60. createScriptURL: string => string,
  61. createScript: string => string,
  62. });
  63. }
  64.  
  65. GM_addStyle(`
  66. #J_dismiss_all,#J_open_settings{
  67. display: inline-flex;
  68. margin-left: 2em;
  69. align-items: center;
  70. vertical-align: middle;
  71. color: gray;
  72. font-size: 2em;
  73. line-height: 2em;
  74. text-decoration: none;
  75. }
  76.  
  77. #J_open_settings{
  78. margin-top:1px;
  79. margin-left: 1em;
  80. }
  81.  
  82. #Y_settings > div{
  83. margin-bottom:10px;
  84. }
  85. .config-current-value{
  86. font-weight: bold;
  87. color:blueviolet;
  88. }
  89. `);
  90.  
  91. function wait(ms) {
  92. return new Promise((resolve) => {
  93. setTimeout(resolve, ms);
  94. });
  95. }
  96. function inArray(array, element) {
  97. return array.indexOf(element) !== -1;
  98. }
  99.  
  100. function toNumber(value){
  101. let num = Number(value);
  102.  
  103. if (isNaN(num) || !isFinite(num)) {
  104. return 0;
  105. }
  106.  
  107. return num;
  108. }
  109.  
  110. var runflag = true;
  111. var firstEnterThisPage = true;
  112. async function dismissCurrent() {
  113. let clickedSomething = false;
  114. let foundAusblenden = false;
  115.  
  116. for (const item of document.querySelectorAll('ytd-menu-service-item-renderer')) {
  117.  
  118. if (item.icon === (GM_getValue('videoOrCreator') === "video" ? "NOT_INTERESTED" : "REMOVE")) {
  119. clickedSomething = true;
  120. item.click();
  121. }
  122. // else if (item.icon === "__") {
  123. // foundAusblenden = item;
  124. // }
  125. }
  126. if (!clickedSomething && foundAusblenden !== false) {
  127. foundAusblenden.click();
  128. }
  129. return true;
  130. }
  131. async function dismissAll() {
  132. let list = document.querySelectorAll('ytd-rich-grid-media button[aria-label]');
  133.  
  134. while (firstEnterThisPage && list.length < 1) {
  135. await wait(1000);
  136. list = document.querySelectorAll('ytd-rich-grid-media button[aria-label]');
  137. }
  138. firstEnterThisPage = false;
  139.  
  140. let i = 0;
  141. for (let item of list) {
  142. item.click();
  143. await wait(50);
  144. await dismissCurrent();
  145. await wait(100);
  146. i++;
  147. if (i >= parseInt(GM_getValue('maximumNumberOfBlocksPerOperation'))) break;
  148. }
  149. if (runflag) {
  150. runflag = false;
  151. // await dismissAll();
  152. }
  153. window.location.reload();
  154. }
  155.  
  156. window.dismissAll = function() {
  157. dismissAll();
  158. }
  159. window.openGmcSettings = function() {
  160. let settings = document.getElementById('J_settings');
  161. settings.style.display = '';
  162.  
  163. swal({
  164. content: settings,
  165. buttons: {
  166. cancel: "close",
  167. },
  168. }).then(async (value) => {
  169. settings.style.display = 'none';
  170. });
  171. }
  172.  
  173. function createButton() {
  174. var elementForInsertNewButton = document.querySelector('#start') || document.querySelector('#logo-icon') || document.querySelector('#country-code');
  175.  
  176. var dismissAllLink = document.createElement('a');
  177. dismissAllLink.id = 'J_dismiss_all';
  178. dismissAllLink.href = 'javascript:';
  179. dismissAllLink.onclick = window.dismissAll;
  180. dismissAllLink.textContent = '⟳';
  181.  
  182. var openGmcSettingsLink = document.createElement('a');
  183. openGmcSettingsLink.id = 'J_open_settings';
  184. openGmcSettingsLink.href = 'javascript:';
  185. openGmcSettingsLink.onclick = window.openGmcSettings;
  186. openGmcSettingsLink.textContent = '⋮';
  187.  
  188. elementForInsertNewButton.appendChild(dismissAllLink);
  189. elementForInsertNewButton.appendChild(openGmcSettingsLink);
  190. }
  191.  
  192. createButton();
  193.  
  194. // settings
  195. document.addEventListener('alpine:init', () => {
  196. var maximumNumberOfBlocksPerOperation = GM_getValue('maximumNumberOfBlocksPerOperation');
  197. if(typeof maximumNumberOfBlocksPerOperation === 'undefined') maximumNumberOfBlocksPerOperation = '12';
  198. GM_setValue('maximumNumberOfBlocksPerOperation', maximumNumberOfBlocksPerOperation);
  199. Alpine.store('maximumNumberOfBlocksPerOperation', {
  200. value: maximumNumberOfBlocksPerOperation,
  201. valueHasChanged(){
  202. toNumber(this.value).toString();
  203. GM_setValue('maximumNumberOfBlocksPerOperation', toNumber(this.value).toString());
  204. }
  205. })
  206.  
  207.  
  208. var autoMode = GM_getValue('autoMode') === 'on' ? 'on' : 'off';
  209. GM_setValue('autoMode', autoMode);
  210.  
  211. Alpine.store('autoMode', {
  212. value: autoMode,
  213. async toggle() {
  214. let oldvalue = this.value;
  215. this.value = this.value === 'on' ? 'off' : 'on';
  216. GM_setValue('autoMode', this.value);
  217.  
  218. if(this.value === 'on') {
  219. await wait(1000);
  220. window.location.reload();
  221. }
  222.  
  223. }
  224. })
  225.  
  226.  
  227. var videoOrCreator = GM_getValue('videoOrCreator') === 'creator' ? 'creator' : 'video';
  228. GM_setValue('videoOrCreator', videoOrCreator);
  229.  
  230.  
  231. Alpine.store('videoOrCreator', {
  232. value: videoOrCreator,
  233. toggle() {
  234. let oldvalue = this.value;
  235. this.value = this.value === "creator" ? "video" : "creator";
  236. GM_setValue('videoOrCreator', this.value);
  237. }
  238. })
  239.  
  240. if(GM_getValue('autoMode') === 'on') window.dismissAll()
  241. });
  242.  
  243. var gmcSettings = document.createElement('div');
  244. gmcSettings.id = 'J_settings';
  245.  
  246. gmcSettings.innerHTML = `
  247. <div id="Y_settings">
  248. <div>
  249. <span>Maximum number of blocks per operation:</span>
  250. <input type="text" x-model="$store.maximumNumberOfBlocksPerOperation.value" x-init="$watch('$store.maximumNumberOfBlocksPerOperation.value', value => $store.maximumNumberOfBlocksPerOperation.valueHasChanged())">
  251. </div>
  252. <div>
  253. <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>
  254. </div>
  255. <div>
  256. <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>
  257. </div>
  258. </div>
  259.  
  260.  
  261. `;
  262. document.querySelector('body').appendChild(gmcSettings);