// ==UserScript==
// @name Youtube Tools All in one local download mp3 mp4 HIGT QUALITY return dislikes and more
// @name:zh-TW Youtube 工具 多合一本地下載 MP4、MP3
// @name:zh-HK Youtube 工具 多合一本地下載 MP4、MP3
// @name:zh-CN Youtube 工具 多合一本地下載 MP4、MP3
// @name:ja Youtube ツール オールインワンのローカル ダウンロード MP4、MP3
// @name:kr Youtube 도구 올인원 로컬 다운로드 외부 서비스 없이 MP4, MP3
// @name:ar Youtube Tools All in one local download mp3 mp4 HIGT QUALITY return dislikes and more
// @name:bg Youtube-Tools Alles in einem lokalen Download von MP4, MP3.
// @name:cs Nástroje YouTube Vše v jednom místní Stahujte MP4, MP3
// @name:da Youtube-værktøjer Alt i én lokal Download MP4, MP3
// @name:de Youtube-Tools Alles in einem lokalen Download von MP4, MP3
// @name:tel Youtube టూల్స్ అన్నీ ఒకే లోకల్ డౌన్లోడ్ MP4, Mp3
// @name:es Youtube Custom Todo en uno Descarga local MP4, MP3.
// @name:en Youtube Tools All in one local download mp3 mp4.
// @name:fr Outils Youtube Tout-en-un local Téléchargez MP4, MP3.
// @name:fr-CA Outils Youtube Tout-en-un local Téléchargez MP4, MP3.
// @name:he כלים של YouTube הכל במקום אחד מקומי הורדה MP4, MP3 באיכות גבוהה ללא שירות חיצוני ועוד.
// @name:hu Youtube Eszközök Minden egy helyen Letöltés MP4, MP3.
// @name:id Alat Youtube Semua dalam satu lokal Unduh MP4, MP3.
// @name:it Strumenti Youtube Tutto in uno Scarica locale MP4, MP3.
// @name:ko Youtube 도구 올인원 로컬 외부 서비스 없이 MP4, MP3
// @name:nb Youtube-verktøy Alt i ett lokalt Last ned MP4, MP3
// @name:nl Youtube Tools Alles in één lokaal Download MP4, MP3
// @name:pl Narzędzia YouTube Wszystko w jednym lokalnym. Pobierz MP4, MP3
// @name:pt-BR Ferramentas do Youtube Tudo em um local Baixe MP4, MP3 DE ALTA QUALIDAD.
// @name:ro YInstrumente Youtube Toate într-un singur local Descărcați MP4, MP3.
// @name:ru Инструменты Youtube Все в одном локальном формате. Загрузите MP4, MP3.
// @name:sk Nástroje YouTube Všetko v jednom miestne Stiahnite si MP4, MP3
// @name:sr Иоутубе алати Све у једном локалном Преузми МП4, МП3
// @name:sv Youtube-verktyg Allt i ett lokalt Ladda ner MP4, MP3
// @name:th เครื่องมือ Youtube ทั้งหมดในที่เดียว ดาวน์โหลด MP4, MP3
// @name:tr Youtube Araçları Hepsi bir arada yerel Harici hizmet olmadan MP4, MP3
// @name:uk Інструменти Youtube Все в одному локальному завантаженні MP4, MP3
// @name:ug Youtube قوراللىرى ھەممىسى بىر يەرلىك چۈشۈرۈش MP4,mp3
// @name:vi Công cụ Youtube Tất cả trong một cục bộ Tải xuống MP4, MP3
// @description:zh-TW Youtube 工具 多合一本地下載 mp4、MP3
// @description:zh-HK Youtube 工具 多合一本地下載 mp4、MP3
// @description:zh-CN Youtube 工具 多合一本地下載 mp4、MP3
// @description:ja Youtube ツール オールインワン ローカル ダウンロード mp4、MP3 、
// @description:kr Youtube 도구 올인원 로컬 다운로드 mp4, MP3
// @description:ar Herramientas de YouTube Todo en uno Descarga local mp4, MP3
// @description:bg Инструменти за Youtube Всичко в едно локално изтегляне mp4,
// @description:cs Nástroje YouTube Vše v jednom místní Stahování mp4, MP3
// @description:da Youtube-værktøjer Alt i ét lokalt Download mp4, MP3
// @description:de YouTube-Tools Alles in einem lokalen Laden Sie MP4, MP3
// @description:tel Youtube Tools All in one local Download mp4, MP3 HIGT QUALITY,
// @description:es Youtube tools todo en uno personlizada youtube a tu estilo y descarga MP4 y MP3
// @description:fr Outils Youtube Tout-en-un local Téléchargez des mp4, des MP3
// @description:fr-CA Outils Youtube Tout-en-un local Téléchargez des mp4, des MP3
// @description:he כלים של YouTube הכל במקום אחד מקומי הורד mp4, MP3
// @description:hu Youtube Eszközök Minden egyben helyi Letöltés mp4, MP3
// @description:id Alat Youtube Semua dalam satu lokal Unduh mp4, MP3
// @description:it Strumenti Youtube Tutto in uno locale Scarica mp4, MP3
// @description:ko Youtube 도구 올인원 로컬 다운로드 mp4, MP3
// @description:nb YoYoutube-verktøy Alt i ett lokalt Last ned mp4, MP3
// @description:nl YouTube-tools Alles in één lokaal Download mp4, MP3
// @description:pl Narzędzia Youtube Wszystko w jednym miejscu Pobierz mp4, MP3
// @description:pt-BR Ferramentas do YouTube Tudo em um só local Baixe mp4, MP3
// @description:ro Instrumente Youtube Toate într-un singur local Descărcați mp4, MP3
// @description:ru Инструменты Youtube Все в одном, локально. Загрузите mp4, MP3
// @description:sk Nástroje YouTube Všetko v jednom miestnom Sťahujte mp4, MP3
// @description:sr Иоутубе алати Све у једном локалном Преузми мп4, МП3
// @description:sv Youtube-verktyg Allt i ett lokalt Ladda ner mp4, MP3
// @description:th เครื่องมือ Youtube ทั้งหมดในที่เดียว ดาวน์โหลด mp4, MP3
// @description:tr Youtube Araçları Hepsi bir arada yerel Harici hizmet olmadan mp4, MP3
// @description:uk Інструменти Youtube Все в одному локальному завантаженні mp4, MP3
// @description:ug Youtube قورالىنىڭ ھەممىسى بىر يەرلىك چۈشۈرۈشتە mp4, MP3 HIGH QUAقنى قا
// @description:vi Công cụ Youtube Tất cả trong một cục bộ Tải xuống mp4, MP3
// @description:en Youtube Tools All in one local Download mp4, MP3 HIGT QUALITY
// @description Youtube Tools All in one local Download mp4, MP3 HIGT QUALITY
// @homepage https://github.com/DeveloperMDCM/
// @version 2.2
// @author MDCM
// @match https://*.youtube.com/*
// @exclude *://music.youtube.com/*
// @exclude *://*.music.youtube.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=youtube.com
// @grant GM_info
// @grant GM_setValue
// @grant GM_getValue
// @grant unsafeWindow
// @run-at document-end
// @compatible chrome
// @compatible firefox
// @compatible opera
// @compatible safari
// @compatible edge
// @compatible brave
// @license MIT
// @namespace https://github.com/DeveloperMDCM/
// @downloadURL none
// ==/UserScript==
// comming soon new update 13/06/2024 🟢
(function () {
// Youtube tools by: DeveloperMDCM
// https://github.com/DeveloperMDCM/Youtube-tools-extension
'use strict';
function paramsVideoURL() {
const parametrosURL = new URLSearchParams(window.location.search); // Url parametros
return parametrosURL.get('v');
}
function cargarScript() {
console.log('Scrip en ejecución by: DeveloperMDCM MDCM');
const HEADER_STYLE =
'color: #F00; font-size: 24px; font-family: sans-serif;';
const MESSAGE_STYLE =
'color: #00aaff; font-size: 16px; font-family: sans-serif;';
const CODE_STYLE = 'font-size: 14px; font-family: monospace;';
console.log(
'%cYoutube Tools Extension\n' +
'%cRun %c(v2.2)\n' +
'By: DeveloperMDCM.',
HEADER_STYLE,
CODE_STYLE,
MESSAGE_STYLE
);
let ad = true;
const stylesCss = `
`;
const button_colors_collapsible = `
`;
const thumbnailVideo = `
`;
const modeReverse = `
`;
const filterEyes = `
`;
const resetButton = `
`;
const repeatVideo = `
`;
const downloadMp4Mp3 = `
`;
const donwloadExternal = `
`;
const viewExternalVideo = `
`;
const pictureToPicture = `
`;
const screenShot = `
`;
const checkUpdates = `
`;
// Menu Buttons
const menuBotones = `
Document
${stylesCss}
`;
let validoBotones = true;
function inicializarColores() {
let coloresGuardados = localStorage.getItem('colores');
if (coloresGuardados) {
return JSON.parse(coloresGuardados);
} else {
// Color default empty string
return {
color_progress_bar: '#ff0000',
};
}
}
function obtenerColorPorId(colorId) {
let colores = inicializarColores();
return colores[colorId];
}
function guardarColores(colores) {
localStorage.setItem('colores', JSON.stringify(colores));
}
function applyStyles(isActive, color, styleProperty) {
const estilosGenerales = generarEstilosGenerales();
aplicarEstilos('estilos-combinados', estilosGenerales);
if (isActive) {
document.body.style.setProperty(styleProperty, color);
} else {
document.body.style.removeProperty(styleProperty);
}
}
// Función para verificar si una propiedad específica existe en el objeto colores almacenado en localStorage
function propiedadExiste(propiedad) {
// Obtener el objeto almacenado en localStorage
var colores = localStorage.getItem('colores');
// Verificar si colores es null o no
if (colores !== null) {
// Convertir la cadena JSON en un objeto JavaScript
var coloresObj = JSON.parse(colores);
// Verificar si la propiedad específica existe en el objeto
return coloresObj.hasOwnProperty(propiedad);
} else {
return false;
}
}
let styles_colors = '';
function generarEstilosGenerales() {
styles_colors = `
:root {
--icons-color: ${obtenerColorPorId('color_icons_color')};
--progress-bar-video: ${obtenerColorPorId('color_progress_bar')};
--header-background-color: ${obtenerColorPorId('color_header_background')};
}
.yt-spec-button-shape-next--mono.yt-spec-button-shape-next--tonal {
color: var(--icons-color);
background-color: #7070718d;
}`;
// Styles conditionals
if (propiedadExiste('color_icons_color')) {
styles_colors += `
#logo-icon {
color: var(--icons-color);
}
.yt-spec-button-shape-next--overlay.yt-spec-button-shape-next--text {
color: var(--icons-color);
}
.ytd-topbar-menu-button-renderer #button.ytd-topbar-menu-button-renderer {
color: var(--icons-color);
}
.yt-spec-icon-badge-shape--style-overlay .yt-spec-icon-badge-shape__icon {
color: var(--icons-color);
}
.ytp-svg-fill {
fill: var(--icons-color);
}
#ytp-id-30,#ytp-id-17,#ytp-id-19,#ytp-id-20{
fill: var(--icons-color);
}
`;
}
if (propiedadExiste('color_progress_bar')) {
styles_colors += `
.ytp-swatch-background-color {
background-color: var(--progress-bar-video);
}
`;
}
if (propiedadExiste('color_header_background')) {
styles_colors += `
#background.ytd-masthead {
background-color: var(--header-background-color);
}
`;
}
return styles_colors;
}
function aplicarEstilos(clase, estilos) {
let estiloExistente =
document.getElementById(clase) || document.createElement('style');
estiloExistente.id = clase;
estiloExistente.innerHTML = estilos;
if (!document.getElementById(clase)) {
document.head.appendChild(estiloExistente);
}
}
function actualizarColor(event) {
const estilosGenerales = generarEstilosGenerales();
aplicarEstilos('estilos-combinados', estilosGenerales);
var colores = inicializarColores();
var inputId = event.target.id;
var nuevoColor = event.target.value;
// Actualizar el color correspondiente en el objeto de colores
colores[inputId] = nuevoColor;
// primary color
applyStyles(
propiedadExiste('color_primary'),
`${obtenerColorPorId('color_primary')}`,
'--yt-spec-text-primary'
);
// Secondary color
applyStyles(
propiedadExiste('color_secondary'),
`${obtenerColorPorId('color_secondary')}`,
'--yt-spec-text-secondary'
);
// Icons color
applyStyles(
propiedadExiste('color_icons_color'),
`${obtenerColorPorId('color_icons_color')}`,
'--yt-spec-wordmark-text'
);
applyStyles(
propiedadExiste('color_icons_color'),
`${obtenerColorPorId('color_icons_color')}`,
'--yt-spec-brand-icon-inactive'
);
// Menu settings color
applyStyles(
propiedadExiste('color_menu'),
`${obtenerColorPorId('color_menu')}`,
'--yt-spec-menu-background'
);
// Line color previw
applyStyles(
propiedadExiste('color_line_preview'),
`${obtenerColorPorId('color_line_preview')}`,
'--yt-spec-static-brand-red'
);
// Time color previw
applyStyles(
propiedadExiste('color_time_preview'),
`${obtenerColorPorId('color_time_preview')}`,
'--yt-spec-static-brand-white'
);
applyStyles(
propiedadExiste('color_progress_bar'),
`${obtenerColorPorId('color_progress_bar')}`,
'--progress-bar-video'
);
applyStyles(
propiedadExiste('color_header_background'),
`${obtenerColorPorId('color_header_background')}`,
'--header-background-color'
);
// Guardar el objeto de colores actualizado en localStorage
guardarColores(colores);
}
// Función para link github project
const existeFormButton = document.querySelector(
'#below > ytd-watch-metadata > div.container > form'
);
function MDCM() {
if (!existeFormButton) {
const mdcm = document.querySelector('#MDCM');
const sms = document.querySelector('#below > ytd-watch-metadata');
if (!mdcm) {
if (sms != undefined) {
const mdcm = document.createElement('P');
mdcm.innerHTML =
'Link GitHub Repository ';
sms.appendChild(mdcm);
}
}
}
}
// TODO: Inicia y inserta los botones
function renderizarContenido() {
const addButton = document.querySelector(
'.style-scope .ytd-watch-metadata'
);
if (addButton != undefined && validoBotones) {
validoBotones = false;
addButton.insertAdjacentHTML('beforebegin', menuBotones);
// document.querySelector("video").style.borderRadius = "30px";
const containerButtons = document.querySelector('.containerButtons');
// Agregar cada contenido al contenedor si está activo
if (containerButtons) {
addButton.insertAdjacentHTML('beforebegin', menuBotones);
containerButtons.innerHTML = '';
const contentData = {
button_colors_collapsible: {
active: true,
html: button_colors_collapsible,
},
thumbnailVideo: {
active: true,
html: thumbnailVideo,
},
resetButton: {
active: true,
html: resetButton,
},
modeReverse: {
active: true,
html: modeReverse,
},
filterEyes: {
active: true,
html: filterEyes,
},
repeatVideo: {
active: true,
html: repeatVideo,
},
downloadMp4Mp3: {
active: true,
html: downloadMp4Mp3,
},
donwloadExternal: {
active: true,
html: donwloadExternal,
},
viewExternalVideo: {
active: true,
html: viewExternalVideo,
},
pictureToPicture: {
active: true,
html: pictureToPicture,
},
screenShot: {
active: true,
html: screenShot,
},
checkUpdates: {
active: true,
html: checkUpdates,
},
};
for (const key in contentData) {
if (contentData[key].active) {
containerButtons.innerHTML += contentData[key].html;
}
}
// Resto del código para formularios y eventos...
} else {
console.error('Elemento .containerButtons no encontrado');
}
// Collapsible colors content button
const button_collapsible = document.querySelector(
'.collapsible_colors'
);
const close_menu_colors = document.querySelector(
'#close_menu_colors'
);
const content_collapsible_colors = document.querySelector(
'.content_collapsible_colors'
);
if (button_collapsible || close_menu_colors) {
const close = (item) => {
item.onclick = () => {
button_collapsible.style.color =
content_collapsible_colors.style.display === 'block'
? '#ff0000'
: '';
content_collapsible_colors.style.display =
content_collapsible_colors.style.display == 'block'
? 'none'
: 'block';
};
}
close(button_collapsible)
close(close_menu_colors)
}
// Formulario de botones para descargar
const formulariodescarga = document.querySelector(
'.formulariodescarga'
);
const formulariodescargaaudio = document.querySelector(
'.formulariodescargaaudio'
);
const framedescarga = document.querySelector('#descargando');
const framedescargamp3 = document.querySelector('#descargandomp3');
if (formulariodescarga && formulariodescargaaudio) {
formulariodescarga.addEventListener('click', (e) => {
e.preventDefault();
});
formulariodescargaaudio.addEventListener('click', (e) => {
e.preventDefault();
});
}
const btn1mp4 = document.querySelector('.btn1');
const btn2mp3 = document.querySelector('.btn2');
const btn3cancel = document.querySelector('.btn3');
const selectcalidades = document.querySelector('.selectcalidades');
const selectcalidadesaudio = document.querySelector(
'.selectcalidadesaudio'
);
selectcalidades.addEventListener('change', (e) => {
framedescarga.src = `https://loader.to/api/button/?url=${window.location.href}&f=${e.target.value}&color=0af`;
framedescarga.classList.remove('ocultarframe');
});
selectcalidadesaudio.addEventListener('change', (e) => {
framedescargamp3.src = `https://loader.to/api/button/?url=${window.location.href}&f=${e.target.value}&color=049c16`;
// console.log(e.target.value)
framedescargamp3.classList.remove('ocultarframeaudio');
});
if (btn3cancel) {
btn3cancel.onclick = () => {
formulariodescarga.style.display = 'none';
formulariodescargaaudio.style.display = 'none';
};
}
if (btn1mp4) {
btn1mp4.onclick = () => {
selectcalidades.classList.remove('ocultarframe');
framedescarga.classList.add('ocultarframe');
formulariodescarga.classList.remove('ocultarframe');
formulariodescarga.style.display = '';
selectcalidadesaudio.classList.add('ocultarframeaudio');
formulariodescargaaudio.classList.add('ocultarframe');
formulariodescarga.reset();
};
}
MDCM();
if (btn2mp3) {
btn2mp3.onclick = () => {
formulariodescargaaudio.classList.remove('ocultarframe');
formulariodescarga.classList.add('ocultarframe');
framedescargamp3.classList.remove('ocultarframeaudio');
formulariodescargaaudio.style.display = '';
selectcalidadesaudio.classList.remove('ocultarframeaudio');
framedescargamp3.classList.add('ocultarframeaudio');
formulariodescargaaudio.reset();
};
}
const reverse = document.querySelector('#columns'); // Invertir contenido
const color_primary = document.querySelector('#color_primary');
const color_progress_bar = document.querySelector(
'#color_progress_bar'
);
const color_header_background = document.querySelector(
'#color_header_background'
);
const color_secondary = document.querySelector('#color_secondary');
const color_icons_color = document.querySelector('#color_icons_color');
const color_menu = document.querySelector('#color_menu');
const color_line_preview = document.querySelector(
'#color_line_preview'
);
const color_time_preview = document.querySelector(
'#color_time_preview'
);
color_primary.value = obtenerColorPorId('color_primary')
? obtenerColorPorId('color_primary')
: '#ffffff';
color_progress_bar.value = obtenerColorPorId('color_progress_bar')
? obtenerColorPorId('color_progress_bar')
: '#ffffff';
color_header_background.value = obtenerColorPorId(
'color_header_background'
)
? obtenerColorPorId('color_header_background')
: '#ffffff';
color_secondary.value = obtenerColorPorId('color_secondary')
? obtenerColorPorId('color_secondary')
: '#ffffff';
color_icons_color.value = obtenerColorPorId('color_icons_color')
? obtenerColorPorId('color_icons_color')
: '#ffffff';
color_menu.value = obtenerColorPorId('color_menu')
? obtenerColorPorId('color_menu')
: '#ffffff';
color_line_preview.value = obtenerColorPorId('color_line_preview')
? obtenerColorPorId('color_line_preview')
: '#ffffff';
color_time_preview.value = obtenerColorPorId('color_time_preview')
? obtenerColorPorId('color_time_preview')
: '#ffffff';
applyStyles(
propiedadExiste('color_primary'),
`${obtenerColorPorId('color_primary')}`,
'--yt-spec-text-primary'
);
// Secondary color
applyStyles(
propiedadExiste('color_secondary'),
`${obtenerColorPorId('color_secondary')}`,
'--yt-spec-text-secondary'
);
// Icons color
applyStyles(
propiedadExiste('color_icons_color'),
`${obtenerColorPorId('color_icons_color')}`,
'--yt-spec-wordmark-text'
);
applyStyles(
propiedadExiste('color_icons_color'),
`${obtenerColorPorId('color_icons_color')}`,
'--yt-spec-brand-icon-inactive'
);
// Menu settings color
applyStyles(
propiedadExiste('color_menu'),
`${obtenerColorPorId('color_menu')}`,
'--yt-spec-menu-background'
);
// Line color previw
applyStyles(
propiedadExiste('color_line_preview'),
`${obtenerColorPorId('color_line_preview')}`,
'--yt-spec-static-brand-red'
);
// Time color previw
applyStyles(
propiedadExiste('color_time_preview'),
`${obtenerColorPorId('color_time_preview')}`,
'--yt-spec-static-brand-white'
);
applyStyles(
propiedadExiste('color_progress_bar'),
`${obtenerColorPorId('color_progress_bar')}`,
'--progress-bar-video'
);
applyStyles(
propiedadExiste('color_header_background'),
`${obtenerColorPorId('color_header_background')}`,
'--header-background-color'
);
const btnImagen = document.querySelector('#imagen');
// Download image video
const formularioButtons = document.querySelector('#eyes'); // Filtro de pantalla
// const btnFondo = document.querySelector("#fondo"); // Fondo cinematica completa
const invertirVista = document.querySelector('#invertir'); // Intercambiar vista
const buttonsVideo = document.querySelector(
'#top-row.ytd-watch-metadata'
); // Botones para video
reverse.style.flexDirection = 'row';
buttonsVideo.style =
'display: flex;flex-direction: column;justify-content: center;align-items: center ;';
document.querySelector('#title > h1').style =
'text-align: center; color: red;';
document.querySelector('#owner').style.justifyContent = 'center';
//document.querySelector("#search-icon-legacy.ytd-searchbox").style.backgroundColor = "gray";
let countViewRow = 0; // Count
if (invertirVista) {
invertirVista.onclick = () => {
countViewRow += 1;
switch (countViewRow) {
case 1:
reverse.style.flexDirection = 'row-reverse';
break;
case 2:
reverse.style.flexDirection = 'row';
countViewRow = 0;
break;
}
};
}
// valido modo oscuro y venta de video
// Repeat video button
let countRepeat = 0; // count
const repeat = document.querySelector('#repeatvideo'); // Repeat button
const imarepeat = document.querySelector('.icon-tabler-repeat'); // img repeat
const videoFull = document.querySelector(
'#movie_player > div.html5-video-container > video'
);
repeat.onclick = () => {
if (
document.querySelector('#cinematics > div') != undefined ||
videoFull != undefined
) {
countRepeat += 1;
setInterval(() => {
switch (countRepeat) {
case 1:
document
.querySelector(
'#movie_player > div.html5-video-container > video'
)
.setAttribute('loop', 'true');
imarepeat.innerHTML = `
`; // img repeat
break;
case 2:
countRepeat = 0;
document
.querySelector(
'#movie_player > div.html5-video-container > video'
)
.removeAttribute('loop');
imarepeat.innerHTML = `
`;
break;
}
}, 1000);
} else {
mostrarAlerta('Active Dark Theme in Youtube page');
}
};
// Background transparent
reverse.style.flexDirection = 'row';
const cinematica = document.querySelector('#cinematics > div');
if (cinematica != undefined) {
cinematica.style =
'position: fixed; inset: 0px; pointer-events: none; transform: scale(1.5, 2)';
}
const btnReset = document.querySelector('#reset'); // Reset button
if (btnReset) {
btnReset.addEventListener('click', function () {
const colores = localStorage.getItem('colores');
if (colores) {
localStorage.removeItem('colores');
document.querySelector('#ojosprotect').style.backgroundColor =
'transparent';
}
});
}
if (btnImagen) {
btnImagen.onclick = () => {
if (
document.querySelector('#cinematics > div') != undefined ||
videoFull != undefined
) {
const parametrosURL = new URLSearchParams(window.location.search);
let enlace = parametrosURL.get('v');
// Construir la URL de la imagen
const imageUrl = `https://i.ytimg.com/vi/${enlace}/maxresdefault.jpg`;
// Realizar la solicitud para obtener la imagen
fetch(imageUrl)
.then((response) => {
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
return response.blob();
})
.then((blob) => {
// Obtener el tamaño de la imagen en kilobytes
const imageSizeKB = blob.size / 1024;
// Verificar si el tamaño de la imagen es menor o igual a 20 KB
if (imageSizeKB >= 20) {
window.open(
`https://i.ytimg.com/vi/${enlace}/maxresdefault.jpg`,
'popUpWindow',
'height=500,width=400,left=100,top=100,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,location=no,directories=no, status=yes'
);
// Crear una URL para la imagen
const imageUrlObject = URL.createObjectURL(blob);
// Crear un enlace para descargar la imagen
const enlaceDescarga = document.createElement('a');
enlaceDescarga.href = imageUrlObject;
const titleVideo = document.querySelector(
'h1.style-scope.ytd-watch-metadata'
).innerText;
enlaceDescarga.download = `${titleVideo}_maxresdefault.jpg`;
// Simular un clic en el enlace para iniciar la descarga
enlaceDescarga.click();
// Limpiar la URL del objeto después de la descarga
URL.revokeObjectURL(imageUrlObject);
} else {
console.log(
'La imagen no excede los 20 KB. No se descargará.'
);
}
})
.catch((error) => {
alert('No found image');
console.error('Error al obtener la imagen:', error);
});
} else {
mostrarAlerta('Active Dark Theme in Youtube page');
}
};
}
// Input color
if (color_primary) {
color_primary.addEventListener('input', actualizarColor);
}
if (color_progress_bar) {
color_progress_bar.addEventListener('input', actualizarColor);
}
if (color_header_background) {
color_header_background.addEventListener('input', actualizarColor);
}
if (color_secondary) {
color_secondary.addEventListener('input', actualizarColor);
}
if (color_icons_color) {
color_icons_color.addEventListener('input', actualizarColor);
}
if (color_menu) {
color_menu.addEventListener('input', actualizarColor);
}
if (color_line_preview) {
color_line_preview.addEventListener('input', actualizarColor);
}
if (color_time_preview) {
color_time_preview.addEventListener('input', actualizarColor);
}
const externalLink = document.querySelector('.external_link');
if (externalLink) {
externalLink.onclick = () => {
const parametrosURL = new URLSearchParams(window.location.search); // Url parametros
let enlace;
enlace = parametrosURL.get('v');
window.open(
`https://www.y2mate.com/es/convert-youtube/${enlace}`,
'popUpWindow',
'height=800,width=1000,left=50%,top=100,resizable=no,scrollbars=yes,toolbar=no,menubar=yes,location=no,directories=yes, status=no'
);
};
}
const viewExternalLink = document.querySelector('.view_external_link');
if (viewExternalLink) {
viewExternalLink.onclick = () => {
document.querySelector('video').click();
const parametrosURL = new URLSearchParams(window.location.search); // Url parametros
let enlace;
enlace = parametrosURL.get('v');
window.open(
`https://www.youtube.com/embed/${enlace}?rel=0&controls=2&color=white&iv_load_policy=3&showinfo=0&modestbranding=1&autoplay=1`
);
};
}
const viewPictureToPicture = document.querySelector(
'.video_picture_to_picture'
);
if (viewPictureToPicture) {
viewPictureToPicture.onclick = () => {
const video = document.querySelector('video');
// Verifica si el navegador admite Picture-in-Picture
if ('pictureInPictureEnabled' in document) {
// Verifica si el video aún no está en modo Picture-in-Picture
if (!document.pictureInPictureElement) {
// Intenta activar el modo Picture-in-Picture
video
.requestPictureInPicture()
.then(() => {
// El video está ahora en modo Picture-in-Picture
})
.catch((error) => {
console.error(
'Error al activar el modo Picture-in-Picture:',
error
);
});
} else {
// video picture
}
} else {
alert('Picture-in-Picture not supported');
}
};
// Filtro de pantalla
if (formularioButtons) {
formularioButtons.addEventListener('input', function () {
if (
document.querySelector('#cinematics > div') != undefined ||
videoFull != undefined
) {
document.querySelector('#ojosprotect').style.backgroundColor =
formularioButtons.value;
}
});
}
clearInterval(renderizarContenido);
}
const checked_updates = document.querySelector('.checked_updates');
if (checked_updates) {
checked_updates.onclick = () => {
window.open(
`https://update.greasyfork.org/scripts/460680/Youtube%20Tools%20All%20in%20one%20local%20download%20mp3%20mp4%20HIGT%20QUALITY%20return%20dislikes%20and%20more.user.js`
);
};
}
const screenShotVideo = document.querySelector('.screenshot_video');
if (screenShotVideo) {
screenShotVideo.onclick = () => {
const video = document.querySelector('video');
const canvas = document.createElement('canvas');
canvas.width = video.videoWidth;
canvas.height = video.videoHeight;
const context = canvas.getContext('2d');
context.drawImage(video, 0, 0, canvas.width, canvas.height);
const imagenURL = canvas.toDataURL('image/png');
const enlaceDescarga = document.createElement('a');
enlaceDescarga.href = imagenURL;
const titleVideo = document.querySelector(
'h1.style-scope.ytd-watch-metadata'
).innerText;
enlaceDescarga.download = `${video.currentTime.toFixed(
0
)}s_${titleVideo}.png`;
enlaceDescarga.click();
};
} else {
// Si result.GeneralIsActiveIconColor es falso, quitar contenido del DOM
const containerButtons = document.querySelector('.containerButtons');
if (containerButtons != undefined) {
containerButtons.innerHTML = '';
// También puedes ocultar o manipular otros elementos según tus necesidades
}
}
clearInterval(renderizarContenido);
}
}
renderizarContenido();
// Función para adaptar dislikes
// Función para formatear los dislikes
function FormatiarNumero(num, digits) {
const lookup = [
{
value: 1,
symbol: '',
},
{
value: 1e3,
symbol: ' K',
},
{
value: 1e6,
symbol: ' M',
},
];
const rx = /\.0+$|(\.[0-9]*[1-9])0+$/;
const item = lookup
.slice()
.reverse()
.find((item) => {
return num >= item.value;
});
return item
? (num / item.value).toFixed(digits).replace(rx, '$1') + item.symbol
: '0';
}
let validoUrl = document.location.href;
async function videoDislike() {
validoUrl = document.location.href;
const validoVentana = document.querySelector(
'#below > ytd-watch-metadata > div.container > form > div.containerButtons'
);
if (
validoVentana != undefined &&
document.location.href.split('?v=')[0].includes('youtube.com/watch')
) {
validoUrl = paramsVideoURL();
const urlShorts = `https://returnyoutubedislikeapi.com/Votes?videoId=${validoUrl}`;
try {
const respuesta = await fetch(urlShorts);
const datosShort = await respuesta.json();
const { dislikes } = datosShort;
// alert(dislikes, 'Video')
const dislikes_content = document.querySelector(
'#top-level-buttons-computed > segmented-like-dislike-button-view-model > yt-smartimation > div > div > dislike-button-view-model > toggle-button-view-model > button-view-model > button'
);
if (dislikes_content !== undefined) {
dislikes_content.style = 'width: 90px';
// document.querySelector('#top-level-buttons-computed > segmented-like-dislike-button-view-model > yt-smartimation > div > div > dislike-button-view-model > toggle-button-view-model > button > yt-touch-feedback-shape > div').insertAdjacentHTML("beforebegin", `${FormatiarNumero(dislikes, 0)}`);
dislikes_content.innerHTML = `
${FormatiarNumero(dislikes, 0)}`;
}
} catch (error) {
console.log(error);
}
}
}
// Función para mostrar los dislikes en shorts
async function shortDislike() {
validoUrl = document.location.href;
const validoVentanaShort = document.querySelectorAll(
'#dislike-button > yt-button-shape > label > div > span'
);
if (
validoVentanaShort != undefined &&
document.location.href.split('/')[3] === 'shorts'
) {
validoUrl = document.location.href.split('/')[4];
const urlShorts = `https://returnyoutubedislikeapi.com/Votes?videoId=${validoUrl}`;
try {
const respuesta = await fetch(urlShorts);
const datosShort = await respuesta.json();
const { dislikes } = datosShort;
for (let i = 0; i < validoVentanaShort.length; i++) {
validoVentanaShort[i].textContent = `${FormatiarNumero(
dislikes,
0
)}`;
}
} catch (error) {
console.log(error);
}
}
}
// Mostrar alerta de activar modo oscuro
function mostrarAlerta(mensaje) {
alert('Active Dark Theme in Youtube page');
const addButton = document.querySelector(
'#below > ytd-watch-metadata > div.container > form'
);
const existeAlerta = document.querySelector('.alerta');
if (!existeAlerta) {
if (addButton != undefined) {
const modeDark = document.createElement('P');
modeDark.innerHTML = `${mensaje} `;
addButton.appendChild(modeDark);
setTimeout(() => {
modeDark.remove();
}, 7000);
}
}
}
// Función para eliminar los posibles anuncios
function eliminarAnuancios() {
// Skip ads video / saltar publicidad
if (
document.querySelector('.ytp-ad-skip-button-modern.ytp-button') !==
null ||
document.querySelector(
'.ytp-ad-text.ytp-ad-preview-text-modern' !== null
) ||
document.querySelector('.ytp-ad-text') ||
document.querySelector('.ytp-ad-preview-container' !== null) ||
document.querySelector(
'.ytp-ad-preview-container.ytp-ad-preview-container-detached'
)
) {
if (
document.querySelector(
'.ytp-ad-preview-container.ytp-ad-preview-container-detached'
) != undefined
) {
document.querySelector(
'#movie_player > div.html5-video-container > video'
).currentTime = 100000;
}
const button = document.querySelector(
'.ytp-ad-skip-button-modern.ytp-button'
);
if (button !== undefined) {
document
.querySelector('.ytp-ad-skip-button-modern.ytp-button')
.click();
}
document.querySelector('.video-ads.ytp-ad-module').click();
}
const buttonSkip = document.querySelector(
'.ytp-ad-skip-button.ytp-button'
);
const validar = undefined;
let bannerAds = document.querySelector(
'.ytd-banner-promo-renderer-background'
);
let bannerProm = document.querySelector('#simple-ad-badge');
let ytpminiplayerscrim = document.querySelector('ytp-miniplayer-scrim');
let cross = document.getElementsByClassName(
'ytp-ad-overlay-close-container'
)[0];
let skip = document.getElementsByClassName('ytp-ad-skip-button')[0];
let ad1 = document.querySelector(
'#contents > ytd-promoted-sparkles-web-renderer'
);
let ad2 = document.querySelector(
'#player-ads > ytd-player-legacy-desktop-watch-ads-renderer'
);
let ad3 = document.querySelector('#action-companion-click-target');
let ad4 = document.querySelector(
'#player-overlay\\:0 > div.ytp-ad-player-overlay-flyout-cta.ytp-ad-player-overlay-flyout-cta-rounded'
);
let ad5 = document.querySelector(
'#invideo-overlay\\:0 > div > div.ytp-ad-image-overlay'
);
let ad6 = document.querySelector('#root');
let ad7 = document.querySelector(
'#rendering-content > ytd-video-masthead-ad-v3-renderer'
);
let ad8 = document.querySelector(
'#player-ads > ytd-player-legacy-desktop-watch-ads-renderer'
);
let ad9 = document.querySelector('.ytp-ad-text-overlay');
const adVideo = document.querySelectorAll('.ad-showing')[0];
const adTimeVideo = document.querySelector(
'.ytp-ad-text.ytp-ad-preview-text'
);
const video = document.querySelector('video');
if (adVideo != validar && video != validar && adTimeVideo != validar) {
video.currentTime = video.duration;
}
if (ytpminiplayerscrim != validar) alert('eliminado');
if (ad1 != validar) ad1.remove();
if (ad2 != validar) ad2.remove();
if (ad3 != validar) ad3.remove();
if (ad4 != validar) ad4.remove();
if (ad5 != validar) ad5.remove();
if (ad6 != validar && ad) {
ad6.style.display = 'none';
ad = false;
}
if (ad7 != validar) ad7.remove();
if (ad8 != validar) ad8.remove();
if (ad9 != validar) ad9.remove();
if (bannerAds != validar) bannerAds.remove();
if (bannerProm != validar) bannerProm.remove();
if (cross != validar) cross.click();
if (skip != validar) skip.click();
if (buttonSkip != validar) {
buttonSkip.click();
}
}
// Validar que la url a cambiado por una nueva
let prevUrl = undefined; // Sin cambios
setInterval(async () => {
// URL changed / Cambio
const currUrl2 = window.location.href;
const video = document.querySelector(
'#below > ytd-watch-metadata > div.container > form > div.containerButtons'
);
if (currUrl2 != prevUrl && video != undefined) {
setTimeout(() => {
videoDislike();
}, 2000);
}
const currUrl = window.location.href;
if (currUrl != prevUrl) {
setTimeout(() => {
shortDislike();
}, 1000);
const formulariodescarga = document.querySelector(
'.formulariodescarga'
);
const formulariodescargaaudio = document.querySelector(
'.formulariodescargaaudio'
);
setTimeout(() => {
if (formulariodescarga != undefined) {
formulariodescarga.classList.add('ocultarframe');
formulariodescargaaudio.classList.add('ocultarframe');
}
}, 500);
prevUrl = currUrl;
}
const ventanaShortComentarios = document.querySelector(
'body > ytd-app > ytd-popup-container > tp-yt-paper-dialog > ytd-engagement-panel-section-list-renderer'
);
const historias = document.querySelectorAll('#shorts-inner-container');
if (ventanaShortComentarios && historias) {
limpiarHTML();
}
eliminarAnuancios();
}, 500); // Cada 2 segundos se ejecuta mientras la url cambie
eliminarAnuancios();
}
// Variables para la traduccion de comentarios
let traducido; // Texto traducido
let urlLista; // Url lista
//TODO: Traducir comentarios
async function traductor() {
const texto = document.querySelectorAll('#content-text');
let o = `?client=dict-chrome-ex&sl=auto&tl=${navigator.language}&q=`;
for (let i = 0; i < texto.length; i++) {
const botonTraducir = document.createElement('BUTTON');
botonTraducir.classList.add('mdcm');
botonTraducir.textContent = 'Translate';
botonTraducir.setAttribute('id', `btn${i}`);
texto[i].insertAdjacentElement('afterend', botonTraducir);
const mdcm = document.querySelectorAll(`.mdcm`);
mdcm[i].onclick = function () {
traducido = o;
urlLista = traducido + texto[i].textContent;
fetch('https://translate.googleapis.com/translate_a/t' + urlLista) //API
.then((response) => response.json())
.then((datos) => {
texto[i].textContent = datos[0][0];
mdcm[i].textContent = 'Translated';
});
};
}
}
// Download avatar profile image
function getAvatarImage() {
const avatar = document.querySelectorAll(
'img#img.style-scope.yt-img-shadow'
);
for (let i = 0; i < avatar.length; i++) {
avatar[i].onclick = function () {
window.open(
`${avatar[i].src.split('=')[0]}`,
'popUpWindow',
'height=800,width=1000'
);
};
}
}
// Limpiar botones de comentarios
function limpiarHTML(element) {
const buttons = document.querySelectorAll(`${element}`);
[].forEach.call(buttons, function (buttons) {
buttons.remove();
});
traductor();
}
// Limpiar botones de Avatars
function limpiarHTMLAvatar(element) {
const buttons = document.querySelectorAll(`${element}`);
[].forEach.call(buttons, function (buttons) {
buttons.remove();
});
getAvatarImage();
// traductor();
}
// TODO: mostrar boton de traducir en comentarios cuando sean visibles
window.onscroll = () => {
const divEl = document.querySelector('#content-text');
const divEl2 = document.querySelector('yt-img-shadow');
if (divEl != undefined) {
limpiarHTML('.mdcm');
}
if (divEl2 != undefined) {
// limpiarHTML('.mdcm');
limpiarHTMLAvatar('.yt-image-avatar-download');
}
};
setTimeout(() => {
cargarScript();
}, 3000);
})();