// ==UserScript==
// @name Youtube block all, not interested in all, dismiss all
// @name:zh-CN Youtube block all, not interested in all, dismiss all
// @name:zh-TW Youtube block all, not interested in all, dismiss all
// @name:ja Youtube block all, not interested in all, dismiss all
// @name:ko Youtube block all, not interested in all, dismiss all
// @name:de Youtube block all, not interested in all, dismiss all
// @name:es Youtube block all, not interested in all, dismiss all
// @name:eo Youtube block all, not interested in all, dismiss all
// @name:fr Youtube block all, not interested in all, dismiss all
// @name:it Youtube block all, not interested in all, dismiss all
// @name:ru Youtube block all, not interested in all, dismiss all
// @name:vi Youtube block all, not interested in all, dismiss all
// @name:pt-BR Youtube block all, not interested in all, dismiss all
// @name:id Youtube block all, not interested in all, dismiss all
// @name:ar Youtube block all, not interested in all, dismiss all
// @name:bg Youtube block all, not interested in all, dismiss all
// @name:cs Youtube block all, not interested in all, dismiss all
// @name:tr Youtube block all, not interested in all, dismiss all
// @name:el Youtube block all, not interested in all, dismiss all
// @name:hu Youtube block all, not interested in all, dismiss all
// @name:th Youtube block all, not interested in all, dismiss all
// @icon https://img.icons8.com/?size=100&id=9a46bTk3awwI&format=png&color=000000
// @version 2.0.0
// @description 不感兴趣, दिलचस्पी नहीं है, 興味なし, 관심 없음, Kein Interesse,لا يهمني,Pas intéressé, Не интересует, Não tenho interesse, No me interesa
// @description:zh-CN 不感兴趣, दिलचस्पी नहीं है, 興味なし, 관심 없음, Kein Interesse,لا يهمني,Pas intéressé, Не интересует, Não tenho interesse, No me interesa
// @description:zh-TW 不感兴趣, दिलचस्पी नहीं है, 興味なし, 관심 없음, Kein Interesse,لا يهمني,Pas intéressé, Не интересует, Não tenho interesse, No me interesa
// @description:ja 不感兴趣, दिलचस्पी नहीं है, 興味なし, 관심 없음, Kein Interesse,لا يهمني,Pas intéressé, Не интересует, Não tenho interesse, No me interesa
// @description:ko 不感兴趣, दिलचस्पी नहीं है, 興味なし, 관심 없음, Kein Interesse,لا يهمني,Pas intéressé, Не интересует, Não tenho interesse, No me interesa
// @description:de 不感兴趣, दिलचस्पी नहीं है, 興味なし, 관심 없음, Kein Interesse,لا يهمني,Pas intéressé, Не интересует, Não tenho interesse, No me interesa
// @description:es 不感兴趣, दिलचस्पी नहीं है, 興味なし, 관심 없음, Kein Interesse,لا يهمني,Pas intéressé, Не интересует, Não tenho interesse, No me interesa
// @description:eo 不感兴趣, दिलचस्पी नहीं है, 興味なし, 관심 없음, Kein Interesse,لا يهمني,Pas intéressé, Не интересует, Não tenho interesse, No me interesa
// @description:fr 不感兴趣, दिलचस्पी नहीं है, 興味なし, 관심 없음, Kein Interesse,لا يهمني,Pas intéressé, Не интересует, Não tenho interesse, No me interesa
// @description:it 不感兴趣, दिलचस्पी नहीं है, 興味なし, 관심 없음, Kein Interesse,لا يهمني,Pas intéressé, Не интересует, Não tenho interesse, No me interesa
// @description:ru 不感兴趣, दिलचस्पी नहीं है, 興味なし, 관심 없음, Kein Interesse,لا يهمني,Pas intéressé, Не интересует, Não tenho interesse, No me interesa
// @description:vi 不感兴趣, दिलचस्पी नहीं है, 興味なし, 관심 없음, Kein Interesse,لا يهمني,Pas intéressé, Не интересует, Não tenho interesse, No me interesa
// @description:pt-BR 不感兴趣, दिलचस्पी नहीं है, 興味なし, 관심 없음, Kein Interesse,لا يهمني,Pas intéressé, Не интересует, Não tenho interesse, No me interesa
// @description:id 不感兴趣, दिलचस्पी नहीं है, 興味なし, 관심 없음, Kein Interesse,لا يهمني,Pas intéressé, Не интересует, Não tenho interesse, No me interesa
// @description:ar 不感兴趣, दिलचस्पी नहीं है, 興味なし, 관심 없음, Kein Interesse,لا يهمني,Pas intéressé, Не интересует, Não tenho interesse, No me interesa
// @description:bg 不感兴趣, दिलचस्पी नहीं है, 興味なし, 관심 없음, Kein Interesse,لا يهمني,Pas intéressé, Не интересует, Não tenho interesse, No me interesa
// @description:cs 不感兴趣, दिलचस्पी नहीं है, 興味なし, 관심 없음, Kein Interesse,لا يهمني,Pas intéressé, Не интересует, Não tenho interesse, No me interesa
// @description:tr 不感兴趣, दिलचस्पी नहीं है, 興味なし, 관심 없음, Kein Interesse,لا يهمني,Pas intéressé, Не интересует, Não tenho interesse, No me interesa
// @description:el 不感兴趣, दिलचस्पी नहीं है, 興味なし, 관심 없음, Kein Interesse,لا يهمني,Pas intéressé, Не интересует, Não tenho interesse, No me interesa
// @description:hu 不感兴趣, दिलचस्पी नहीं है, 興味なし, 관심 없음, Kein Interesse,لا يهمني,Pas intéressé, Не интересует, Não tenho interesse, No me interesa
// @description:th 不感兴趣, दिलचस्पी नहीं है, 興味なし, 관심 없음, Kein Interesse,لا يهمني,Pas intéressé, Не интересует, Não tenho interesse, No me interesa
// @author evanlai
// @match https://www.youtube.com/*
// @exclude https://www.youtube.com/shorts/*
// @require https://openuserjs.org/src/libs/sizzle/GM_config.js
// @require https://cdn.jsdelivr.net/npm/[email protected]/dist/sweetalert.min.js
// @require https://cdn.jsdelivr.net/npm/[email protected]/dist/cdn.min.js
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_addStyle
// @namespace https://greasyfork.org/users/732057
// ==/UserScript==
if (window.trustedTypes && window.trustedTypes.createPolicy) {
window.trustedTypes.createPolicy('default', {
createHTML: string => string,
createScriptURL: string => string,
createScript: string => string,
});
}
GM_addStyle(`
#J_dismiss_all,#J_open_settings{
display: inline-flex;
margin-left: 2em;
align-items: center;
vertical-align: middle;
color: gray;
font-size: 2em;
line-height: 2em;
text-decoration: none;
}
#J_open_settings{
margin-top:1px;
margin-left: 1em;
}
#Y_settings > div{
margin-bottom:10px;
}
.config-current-value{
font-weight: bold;
color:blueviolet;
}
`);
function wait(ms) {
return new Promise((resolve) => {
setTimeout(resolve, ms);
});
}
function inArray(array, element) {
return array.indexOf(element) !== -1;
}
function toNumber(value){
let num = Number(value);
if (isNaN(num) || !isFinite(num)) {
return 0;
}
return num;
}
var runflag = true;
var firstEnterThisPage = true;
async function dismissCurrent() {
let lastElementForClick = null;
[...document.querySelectorAll(`.ytListViewModelHost .yt-list-item-view-model path[d="${(typeof GM_getValue !== 'undefined' && GM_getValue('videoOrCreator') === "video") ? "M12 1C5.925 1 1 5.925 1 12s4.925 11 11 11 11-4.925 11-11S18.075 1 12 1Zm0 2a9 9 0 018.246 12.605L4.755 6.661A8.99 8.99 0 0112 3ZM3.754 8.393l15.491 8.944A9 9 0 013.754 8.393Z" : "M12 1C5.925 1 1 5.925 1 12s4.925 11 11 11 11-4.925 11-11S18.075 1 12 1Zm0 2a9 9 0 110 18.001A9 9 0 0112 3Zm4 8H8a1 1 0 000 2h8a1 1 0 000-2Z"}"]`)].forEach(d => {
d.closest('yt-list-item-view-model').click();
});
// lastElementForClick.click();
// lastElementForClick.remove();
return true;
}
async function dismissAll() {
let list = document.querySelectorAll('yt-lockup-metadata-view-model yt-touch-feedback-shape');
while (firstEnterThisPage && list.length < 5) {
await wait(1000);
list = document.querySelectorAll('yt-lockup-metadata-view-model yt-touch-feedback-shape');
}
firstEnterThisPage = false;
let i = 0;
for (let item of list) {
item.click();
await wait(50);
await dismissCurrent();
await wait(100);
i++;
if (i >= parseInt(GM_getValue('maximumNumberOfBlocksPerOperation'))) break;
}
if (runflag) {
runflag = false;
// await dismissAll();
}
window.location.reload();
}
window.dismissAll = function() {
dismissAll();
}
window.openGmcSettings = function() {
let settings = document.getElementById('J_settings');
settings.style.display = '';
swal({
content: settings,
buttons: {
cancel: "close",
},
}).then(async (value) => {
settings.style.display = 'none';
});
}
function createButton() {
var elementForInsertNewButton = document.querySelector('#start') || document.querySelector('#logo-icon') || document.querySelector('#country-code');
var dismissAllLink = document.createElement('a');
dismissAllLink.id = 'J_dismiss_all';
dismissAllLink.href = 'javascript:';
dismissAllLink.onclick = window.dismissAll;
dismissAllLink.textContent = '⟳';
var openGmcSettingsLink = document.createElement('a');
openGmcSettingsLink.id = 'J_open_settings';
openGmcSettingsLink.href = 'javascript:';
openGmcSettingsLink.onclick = window.openGmcSettings;
openGmcSettingsLink.textContent = '⋮';
elementForInsertNewButton.appendChild(dismissAllLink);
elementForInsertNewButton.appendChild(openGmcSettingsLink);
}
createButton();
// settings
document.addEventListener('alpine:init', async() => {
var maximumNumberOfBlocksPerOperation = GM_getValue('maximumNumberOfBlocksPerOperation');
if(typeof maximumNumberOfBlocksPerOperation === 'undefined') maximumNumberOfBlocksPerOperation = '12';
GM_setValue('maximumNumberOfBlocksPerOperation', maximumNumberOfBlocksPerOperation);
Alpine.store('maximumNumberOfBlocksPerOperation', {
value: maximumNumberOfBlocksPerOperation,
valueHasChanged(){
toNumber(this.value).toString();
GM_setValue('maximumNumberOfBlocksPerOperation', toNumber(this.value).toString());
}
})
var autoMode = GM_getValue('autoMode') === 'on' ? 'on' : 'off';
GM_setValue('autoMode', autoMode);
Alpine.store('autoMode', {
value: autoMode,
async toggle() {
const action = this.value === 'on' ? '关闭' : '开启';
if(this.value !== 'on'){
const confirmed = confirm(`Warning! Once enabled, the page will automatically refresh and process all videos. Are you sure you want to proceed?\n¡Advertencia! Una vez activado, la página se recargará automáticamente y procesará todos los videos. ¿Estás seguro de que quieres hacer esto?\n警告!一旦开启,将自动刷新页面并处理所有的视频,你确定要这么做?\nAttention ! Une fois activé, la page s'actualisera automatiquement et traitera toutes les vidéos. Êtes-vous sûr de vouloir continuer ?\nWarnung! Nach der Aktivierung wird die Seite automatisch neu geladen und alle Videos werden verarbeitet. Sind Sie sicher, dass Sie fortfahren möchten?\n警告! 一度有効にすると、ページが自動的に更新され、すべての動画が処理されます。本当に実行しますか?\n경고! 일단 활성화하면 페이지가 자동으로 새로 고침되고 모든 동영상이 처리됩니다. 계속 진행하시겠습니까?\nВнимание! После включения страница автоматически обновится, и все видео будут обработаны. Вы уверены, что хотите это сделать?\nAviso! Uma vez ativado, a página será atualizada automaticamente e processará todos os vídeos. Tem certeza de que deseja fazer isso?\nAvviso! Una volta abilitato, la pagina si aggiornerà automaticamente ed elaborerà tutti i video. Sei sicuro di voler procedere?\nتحذير! بمجرد التمكين، سيتم تحديث الصفحة تلقائيًا ومعالجة جميع مقاطع الفيديو. هل أنت متأكد أنك تريد المتابعة؟\nCảnh báo! Sau khi bật, trang sẽ tự động làm mới và xử lý tất cả các video. Bạn có chắc chắn muốn làm điều này không?`);
if (!confirmed) {
return;
}
}
let oldvalue = this.value;
this.value = this.value === 'on' ? 'off' : 'on';
GM_setValue('autoMode', this.value);
if(this.value === 'on') {
await wait(1000);
window.location.reload();
}
}
})
var videoOrCreator = GM_getValue('videoOrCreator') === 'creator' ? 'creator' : 'video';
GM_setValue('videoOrCreator', videoOrCreator);
Alpine.store('videoOrCreator', {
value: videoOrCreator,
toggle() {
let oldvalue = this.value;
this.value = this.value === "creator" ? "video" : "creator";
GM_setValue('videoOrCreator', this.value);
}
})
if(GM_getValue('autoMode') === 'on') {
await wait(10000);
window.dismissAll();
}
});
var gmcSettings = document.createElement('div');
gmcSettings.id = 'J_settings';
gmcSettings.style.display = 'none';
gmcSettings.innerHTML = `
<div id="Y_settings">
<div>
<span>Maximum number of blocks per operation:</span>
<input type="text" x-model="$store.maximumNumberOfBlocksPerOperation.value" x-init="$watch('$store.maximumNumberOfBlocksPerOperation.value', value => $store.maximumNumberOfBlocksPerOperation.valueHasChanged())">
</div>
<div>
<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>
</div>
<div>
<span></span>
<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>
</div>
</div>
`;
document.querySelector('body').appendChild(gmcSettings);