Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* This goes to User JS */
- function wrapVideoAndAddUrl() {
- document.querySelectorAll('.video-container').forEach(container => {
- if (container.parentElement.classList.contains('video-wrapper')) return;
- const link = container.querySelector('a[href]');
- if (!link) return;
- const url = link.href;
- if (!url) return;
- const wrapper = document.createElement('div');
- wrapper.classList.add('video-wrapper');
- container.parentNode.insertBefore(wrapper, container);
- wrapper.appendChild(container);
- const urlTextLink = document.createElement('a');
- urlTextLink.href = url;
- urlTextLink.textContent = url;
- urlTextLink.classList.add('embed-url');
- urlTextLink.target = '_blank';
- urlTextLink.rel = 'noopener noreferrer';
- wrapper.appendChild(urlTextLink);
- });
- }
- window.addEventListener('DOMContentLoaded', wrapVideoAndAddUrl);
- /* This goes to User CSS */
- .video-wrapper {
- display: inline-flex;
- flex-direction: column;
- align-items: flex-start;
- }
- .embed-url {
- margin-top: -5px;
- margin-left: 5px;
- font-size: 0.75em;
- color: #666 !important;
- text-decoration: underline;
- }
- .embed-url:hover {
- color: #777 !important;
- }
Advertisement
Add Comment
Please, Sign In to add comment