-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathws2.html
105 lines (92 loc) · 3.73 KB
/
ws2.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Link Preview Example</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
}
.preview {
margin-top: 20px;
border: 1px solid #ccc;
padding: 10px;
}
.preview img {
max-width: 200px;
display: block;
}
</style>
</head>
<body>
<h1>Link Preview Example</h1>
<form id="urlForm">
<label for="urlInput">Enter a URL:</label><br><br>
<input type="url" id="urlInput" name="url" required>
<button type="submit">Get Preview</button>
</form>
<div class="preview" id="preview" style="display: none;">
<h2>Preview</h2>
<p><strong>Title:</strong> <span id="ogTitle"></span></p>
<p><strong>Description:</strong> <span id="ogDescription"></span></p>
<p><strong>Image:</strong><br> <img id="ogImage" src="" alt="OG Image"></p>
<button id="submitAPI">Submit API</button>
</div>
<script>
document.getElementById('urlForm').addEventListener('submit', async function (event) {
event.preventDefault();
const url = document.getElementById('urlInput').value;
try {
const response = await fetch(url);
const html = await response.text();
const parser = new DOMParser();
const doc = parser.parseFromString(html, 'text/html');
const ogTitle = doc.querySelector('meta[property="og:title"]').getAttribute('content');
const ogDescription = doc.querySelector('meta[property="og:description"]').getAttribute('content');
const ogImage = doc.querySelector('meta[property="og:image"]').getAttribute('content');
document.getElementById('ogTitle').innerText = ogTitle || 'N/A';
document.getElementById('ogDescription').innerText = ogDescription || 'N/A';
document.getElementById('ogImage').src = ogImage || '';
document.getElementById('ogImage').style.display = ogImage ? 'block' : 'none';
document.getElementById('preview').style.display = 'block';
} catch (error) {
console.error('Error fetching or parsing HTML:', error);
alert('Failed to fetch or parse HTML.');
}
});
document.getElementById('submitAPI').addEventListener('click', async function () {
const ogTitle = document.getElementById('ogTitle').innerText || '';
const ogDescription = document.getElementById('ogDescription').innerText || '';
const ogImage = document.getElementById('ogImage').src || '';
try {
const apiResponse = await fetch('https://playchat.live/storiez/post', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
"cat": "news",
"img": ogImage,
"texts": [ogTitle, ogDescription],
"template": "news"
})
});
if (apiResponse.ok) {
alert('Data submitted successfully!');
} else {
alert('Failed to submit data.');
}
} catch (error) {
console.error('Error submitting data:', error);
alert('Failed to submit data.');
}
});
</script>
<!--<img src="https://preview.redd.it/whuuo7eb1wz81.jpg?auto=webp&s=bc0e14f07fd1fc70c425f553fb506d01de4ce2f3" >-->
<video width="600" controls>
<source src="https://v.redd.it/wf1l4wikyqla1/DASH_1080.mp4" type="video/mp4">
Your browser does not support the video tag.
</video></body>
</html>