MCPcopy Create free account
hub / github.com/Useful-Scripts-Extension/useful-script / renderCaptions

Function renderCaptions

scripts/youtube_getVideoCaption.js:39–116  ·  view source on GitHub ↗
(captions, title)

Source from the content-addressed store, hash-verified

37 const { parseXml } = await import("./libs/utils/xmlParser.js");
38
39 function renderCaptions(captions, title) {
40 const id = "ufs_youtube_getVideoCaption";
41 const exist = document.getElementById(id);
42 if (exist) exist.remove();
43
44 const div = document.createElement("div");
45 div.id = id;
46 div.innerHTML = /*html*/ `
47 <style>
48 #${id} {
49 position: fixed;
50 top: 0;
51 left: 0;
52 right: 0;
53 bottom: 0;
54 background: rgba(0, 0, 0, 0.8);
55 z-index: 9999999999999999;
56 display: flex;
57 justify-content: center;
58 align-items: center;
59 font-size: 18px;
60 }
61 #${id} a {
62 display: inline-block;
63 transition: all 0.3s ease;
64 text-decoration: none;
65 }
66 #${id} a:hover {
67 text-decoration: underline;
68 }
69 #${id} > div {
70 position: relative;
71 background: #eee;
72 padding: 20px;
73 border-radius: 5px;
74 max-width: 500px;
75 max-height: 500px;
76 overflow-y: scroll;
77 overflow-x: hidden;
78 }
79 #${id} button {
80 display: inline-block;
81 cursor: pointer;
82 }
83 </style>
84 <div>
85 <h3 style="text-align:center">Useful-scripts: Youtube captions</h3><br/>
86 <h4>${title}</h4><br/>
87 <ul>
88 ${captions
89 .map(
90 (caption) => `<li>
91 ${caption.name.simpleText} (${caption.languageCode})
92 <a href="${caption.baseUrl}" data-type="srt">srt</a>
93 <a href="${caption.baseUrl}" data-type="txt">txt</a>
94 <a href="${caption.baseUrl}" target="_blank">xml</a>
95 </li>`
96 )

Callers 1

Calls 2

downloadCaptionFunction · 0.85
removeMethod · 0.45

Tested by

no test coverage detected