|
2720 | 2720 | }
|
2721 | 2721 |
|
2722 | 2722 | function downloadDescriptionVideo() {
|
2723 |
| - if($e('#button_copy_description')) return; |
| 2723 | + if ($e('#button_copy_description')) return; |
| 2724 | + |
| 2725 | + const containerDescription = $e('#bottom-row.style-scope.ytd-watch-metadata'); |
| 2726 | + if (!containerDescription) { |
| 2727 | + console.warn('No se encontró el contenedor de descripción. No se insertará el botón.'); |
| 2728 | + return; |
| 2729 | + } |
| 2730 | + |
2724 | 2731 | const buttomHTML = `
|
2725 |
| - <div id="button_copy_description" style="display: flex; justify-content: end; align-items: center;margin-top: 10px;" > |
2726 |
| - <button id="copy-description" class="botones_div" type="button" style="cursor: pointer;"> |
2727 |
| - <i style="font-size: 20px;" class="fa-solid fa-copy"></i> |
2728 |
| - </button> |
2729 |
| - </div> |
2730 |
| - `; |
2731 |
| - const containerDescription = $e('#bottom-row.style-scope.ytd-watch-metadata'); |
2732 |
| - containerDescription.insertAdjacentHTML('beforebegin', buttomHTML); |
2733 |
| - $id('copy-description').addEventListener('click', () => { |
2734 |
| - const ldJson = [...document.querySelectorAll('script[type="application/ld+json"]')]; |
2735 |
| - for (let script of ldJson) { |
2736 |
| - try { |
2737 |
| - const data = JSON.parse(script.innerText); |
2738 |
| - |
2739 |
| - if (data['@type'] === 'VideoObject') { |
2740 |
| - const description = |
2741 |
| - `📅 Date published: ${data.uploadDate || 'No available'}\n` + |
2742 |
| - `Author: ${data.author || 'No available'}\n` + |
2743 |
| - `🎬 Name video: ${data.name || 'No available'}\n` + |
2744 |
| - `🖼️ Thumbnail: ${Array.isArray(data.thumbnailUrl) ? data.thumbnailUrl.join(', ') : data.thumbnailUrl || 'No available'}\n` + |
2745 |
| - `📝 description: ${data.description || 'No available'}\n\n\n` + |
2746 |
| - `🎭 Category: ${data.genre || 'No available'}\n`; |
2747 |
| - |
2748 |
| - navigator.clipboard.writeText(`${description}`) |
| 2732 | + <div id="button_copy_description" style="display: flex; justify-content: end; align-items: center;margin-top: 10px;" > |
| 2733 | + <button id="copy-description" class="botones_div" type="button" style="cursor: pointer;"> |
| 2734 | + <i style="font-size: 20px;" class="fa-solid fa-copy"></i> |
| 2735 | + </button> |
| 2736 | + </div> |
| 2737 | + `; |
| 2738 | + |
| 2739 | + containerDescription.insertAdjacentHTML('beforebegin', buttomHTML); |
| 2740 | + |
| 2741 | + $id('copy-description').addEventListener('click', () => { |
| 2742 | + const ldJson = [...document.querySelectorAll('script[type="application/ld+json"]')]; |
| 2743 | + for (let script of ldJson) { |
| 2744 | + try { |
| 2745 | + const data = JSON.parse(script.innerText); |
| 2746 | + if (data['@type'] === 'VideoObject') { |
| 2747 | + const description = |
| 2748 | + `📅 Date published: ${data.uploadDate || 'No disponible'}\n` + |
| 2749 | + `Author: ${data.author || 'No disponible'}\n` + |
| 2750 | + `🎬 Name video: ${data.name || 'No disponible'}\n` + |
| 2751 | + `🖼️ Thumbnail: ${Array.isArray(data.thumbnailUrl) ? data.thumbnailUrl.join(', ') : data.thumbnailUrl || 'No disponible'}\n` + |
| 2752 | + `📝 Description: ${data.description || 'No disponible'}\n\n\n` + |
| 2753 | + `🎭 Category: ${data.genre || 'No disponible'}\n`; |
| 2754 | + |
| 2755 | + navigator.clipboard.writeText(description); |
| 2756 | + } |
| 2757 | + } catch (e) { |
| 2758 | + Notify('error', 'Error parsing JSON-LD'); |
| 2759 | + } finally { |
| 2760 | + Notify('success', 'Descripción copiada'); |
2749 | 2761 | }
|
2750 |
| - } catch (e) { |
2751 |
| - Notify('error', 'Error data JSON'); |
2752 |
| - } finally { |
2753 |
| - Notify('success', 'Description video copied'); |
2754 | 2762 | }
|
2755 |
| - } |
2756 |
| - }); |
2757 |
| - |
| 2763 | + }); |
2758 | 2764 | }
|
2759 |
| - |
| 2765 | + |
2760 | 2766 | downloadDescriptionVideo();
|
2761 | 2767 |
|
2762 | 2768 |
|
2763 |
| - |
2764 | 2769 | async function traductor() {
|
2765 | 2770 | const texto = $m('#content-text');
|
2766 | 2771 | if ($e('.buttons-tranlate')) return;
|
|
0 commit comments