// ==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 1.2.1
// @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/sweetalert@2.1.2/dist/sweetalert.min.js
// @require https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/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 clickedSomething = false;
let foundAusblenden = false;
for (const item of document.querySelectorAll('ytd-menu-service-item-renderer')) {
if (item.icon === (GM_getValue('videoOrCreator') === "video" ? "NOT_INTERESTED" : "REMOVE")) {
clickedSomething = true;
item.click();
}
// else if (item.icon === "__") {
// foundAusblenden = item;
// }
}
if (!clickedSomething && foundAusblenden !== false) {
foundAusblenden.click();
}
return true;
}
async function dismissAll() {
let list = document.querySelectorAll('ytd-rich-grid-media button[aria-label]');
while (firstEnterThisPage && list.length < 1) {
await wait(1000);
list = document.querySelectorAll('ytd-rich-grid-media button[aria-label]');
}
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', () => {
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() {
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') 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>
<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);