(captions, title)
| 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 | ) |
no test coverage detected