-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscript.js
More file actions
26 lines (23 loc) · 1.04 KB
/
script.js
File metadata and controls
26 lines (23 loc) · 1.04 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
async function searchAd() {
const debugInfo = document.getElementById('debugInfo').value;
const resultDiv = document.getElementById('result');
try {
const debugData = JSON.parse(debugInfo);
const adVideoId = debugData.addocid;
if (adVideoId) {
const adUrl = `https://youtu.be/${adVideoId}`;
try {
await navigator.clipboard.writeText(adUrl);
resultDiv.innerHTML = `<p>Link copied to clipboard: <a href="${adUrl}" target="_blank">${adUrl}</a></p>`;
alert('Link copied to clipboard!');
} catch (err) {
console.error('Error copying URL: ', err);
resultDiv.innerHTML = `<p>Error copying to clipboard. Here's your link: <a href="${adUrl}" target="_blank">${adUrl}</a></p>`;
}
} else {
resultDiv.innerHTML = 'Ad video ID not found in the provided debug info.';
}
} catch (error) {
resultDiv.innerHTML = 'Invalid debug info provided.';
}
}