Guest User

Untitled

a guest
Oct 30th, 2024
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (function() {
  2.     const rightElement = document.querySelector('.top-buttons .right');
  3.    
  4.     if (!rightElement) {
  5.         console.error('Nelze najít .top-buttons .right na stránce.');
  6.         return;
  7.     }
  8.  
  9.     const link = document.createElement('a');
  10.     link.textContent = 'Načíst raw obsah';
  11.     link.className = 'btn -small';
  12.     link.style.color = 'red';
  13.     link.href = '#';
  14.  
  15.     link.addEventListener('click', async function(event) {
  16.         event.preventDefault();
  17.         try {
  18.             let currentUrl = window.location.href;
  19.             const rawUrl = currentUrl.replace(/^(https:\/\/pastebin\.com\/)(\w+)$/, '$1raw/$2');
  20.             const response = await fetch(rawUrl);
  21.             if (!response.ok) throw new Error('Nepodařilo se načíst obsah.');
  22.  
  23.             const rawContent = await response.text();
  24.  
  25.             await navigator.clipboard.writeText(rawContent);
  26.             alert('Obsah byl zkopírován do schránky.');
  27.         } catch (error) {
  28.             console.error('Došlo k chybě:', error);
  29.             alert('Nepodařilo se načíst a zkopírovat obsah.');
  30.         }
  31.     });
  32.  
  33.     rightElement.insertBefore(link, rightElement.firstChild);
  34. })();
  35.  
Advertisement
Add Comment
Please, Sign In to add comment