-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgerar_link_youtube.html
More file actions
127 lines (108 loc) · 3.37 KB
/
gerar_link_youtube.html
File metadata and controls
127 lines (108 loc) · 3.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<title>Gerador de Link do YouTube</title>
<style>
body {
font-family: Arial, sans-serif;
background: #f5f5f5;
padding: 20px;
}
textarea {
width: 100%;
height: 220px;
font-family: monospace;
padding: 10px;
box-sizing: border-box;
margin-bottom: 10px;
resize: vertical;
}
button {
padding: 10px 15px;
background-color: #27ae60;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
user-select: none;
}
button:hover {
background-color: #219653;
}
.output {
margin-top: 15px;
display: flex;
align-items: center;
gap: 10px;
}
a.link {
font-weight: bold;
word-break: break-word;
color: #007bff;
text-decoration: none;
}
a.link:hover {
text-decoration: underline;
}
</style>
</head>
<body>
<a href="https://felipebros.github.io/Codigos/">Página Inicial</a>
| <a href="./gerar_link_youtube.html">Site</a>
| <a href="https://github.com/Felipebros/Codigos/blob/main/src/gerar_link_youtube.html">Repositório</a>
<h1></h1>
<h3>1. Clique botão direito na propaganda ou vídeo do YouTube</h3>
<h3>2. E clique em "Copiar informações de depuração"</h3>
<img src="images/copiar_informacoes_de_depuracao_youtube.png" />
<h2>3. Cole o JSON ou ID para gerar o link do YouTube</h2>
<textarea id="jsonInput" placeholder="Cole o JSON ou apenas o ID aqui..."
aria-label="Campo para colar JSON ou ID"></textarea>
<div class="output" id="output" style="display:none">
<a id="youtubeLink" class="link" href="#" target="_blank" rel="noopener noreferrer"></a>
<button id="copyButton" type="button">Copiar</button>
</div>
</div>
<script>
const jsonInput = document.getElementById("jsonInput");
const outputDiv = document.getElementById("output");
const youtubeLink = document.getElementById("youtubeLink");
let linkGerado = "";
jsonInput.addEventListener("input", () => {
let addebug_videoId = "";
const input = jsonInput.value.trim();
try {
const data = JSON.parse(input);
addebug_videoId = data.addebug_videoId;
if (!addebug_videoId) throw new Error("addebug_videoId ausente");
} catch (e) {
addebug_videoId = input;
}
if (addebug_videoId) {
linkGerado = `https://www.youtube.com/watch?v=${encodeURIComponent(addebug_videoId)}`;
youtubeLink.href = linkGerado;
youtubeLink.textContent = linkGerado;
outputDiv.style.display = "flex";
} else {
youtubeLink.href = "#";
youtubeLink.textContent = "";
outputDiv.style.display = "none";
}
});
document.getElementById("copyButton").addEventListener("click", function () {
const linkGerado = youtubeLink.href;
if (!linkGerado || linkGerado === "#") return;
copyToClipboard(linkGerado, this);
});
function copyToClipboard(text, buttonEl) {
navigator.clipboard.writeText(text).then(function () {
const originalText = buttonEl.textContent;
buttonEl.textContent = 'Copiado!';
setTimeout(() => {
buttonEl.textContent = originalText;
}, 2000);
}).catch(err => alert("Erro ao copiar o link: " + err));
}
</script>
</body>
</html>