Advertisement
Flameso_o16

Script website

Jan 8th, 2025
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 4.99 KB | None | 0 0
  1. <html lang="en">
  2. <head>
  3.   <meta charset="UTF-8">
  4.   <meta name="viewport" content="width=device-width, initial-scale=1.0">
  5.   <title>Rscripts App</title>
  6.   <script src="https://cdn.tailwindcss.com"></script>
  7.   <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css">
  8.   <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.3.1/styles/default.min.css">
  9.   <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.3.1/highlight.min.js"></script>
  10.   <script>hljs.highlightAll();</script>
  11. </head>
  12. <body class="bg-gray-900 text-white">
  13.   <header class="flex items-center justify-between p-4 bg-gray-800 shadow-lg">
  14.     <div class="flex items-center space-x-4">
  15.       <img src="https://storage.googleapis.com/a1aa/image/az8sE4pcRWZgH5h3TFqfsTKQaxJRQbje1IaOlnD3b6ekxYGoA.jpg" alt="Logo" class="w-10 h-10">
  16.       <h1 class="text-2xl font-bold">Rscripts</h1>
  17.     </div>
  18.     <div class="flex items-center space-x-4">
  19.       <div class="relative">
  20.         <input type="text" placeholder="Search scripts..." class="bg-gray-700 text-white rounded-full pl-10 pr-4 py-2 focus:outline-none">
  21.         <i class="fas fa-search absolute left-3 top-2.5 text-gray-400"></i>
  22.       </div>
  23.       <img src="https://storage.googleapis.com/a1aa/image/gnwxZ7YNIfzxbCYtBomYSVVv2l2LnAcRc06WXJX1cvCaMmBKA.jpg" alt="User Avatar" class="w-10 h-10 rounded-full">
  24.     </div>
  25.   </header>
  26.   <main class="p-4">
  27.     <div id="scripts-container" class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6">
  28.       <!-- Scripts will be dynamically inserted here -->
  29.     </div>
  30.   </main>
  31.   <script>
  32.     // Fetch and display scripts
  33.     fetch("https://rscripts.net/api/v2/scripts?page=1&orderBy=date&sort=desc")
  34.      .then((response) => response.json())
  35.      .then((data) => {
  36.        const scriptsContainer = document.getElementById("scripts-container");
  37.  
  38.         data.scripts.forEach((script) => {
  39.           const hasUser = script.user;
  40.           const profilePicture = hasUser && script.user.image ? script.user.image : "https://i.pravatar.cc/300";
  41.           const username = hasUser ? script.user.username : script.creator;
  42.  
  43.           const scriptElement = document.createElement("div");
  44.           scriptElement.classList.add("bg-gray-800", "p-6", "rounded-lg", "shadow-lg", "hover:shadow-xl", "transition-shadow", "duration-300");
  45.           scriptElement.innerHTML = `
  46.             <img src="${script.image}" alt="${script.title}" class="w-full h-40 object-cover rounded-lg mb-4">
  47.             <div class="flex justify-between items-center mb-4">
  48.               <span class="text-gray-400"><i class="fas fa-eye"></i> ${script.views}</span>
  49.               <span class="text-gray-400">${new Date(script.createdAt).toLocaleString()}</span>
  50.             </div>
  51.             <p class="text-red-500 mb-2">${script.category}</p>
  52.             <h2 class="text-xl font-bold mb-2">${script.title}</h2>
  53.             <p class="mb-4">${script.description}</p>
  54.             <div class="flex items-center space-x-2 mb-4">
  55.               <img src="${profilePicture}" alt="Profile picture of ${username}" class="w-10 h-10 rounded-full">
  56.               <p>Creator: ${username}</p>
  57.             </div>
  58.             <pre><code id="script-${script._id}" class="lua w-full h-40 bg-gray-700 text-white rounded-lg p-2 mt-2 overflow-auto"></code></pre>
  59.             <div class="flex justify-between mt-4">
  60.               <button class="bg-blue-600 text-white px-4 py-2 rounded-full hover:bg-blue-700 transition" onclick="copyToClipboard('script-${script._id}')">Copy</button>
  61.               <a href="${script.rawScript}" download="${script.title}.lua" class="bg-green-600 text-white px-4 py-2 rounded-full hover:bg-green-700 transition">Download</a>
  62.             </div>
  63.           `;
  64.  
  65.           const downloadUrl = script.rawScript;
  66.  
  67.           // Fetch and display the script content
  68.           fetch(downloadUrl)
  69.             .then((response) => response.text())
  70.             .then((scriptContent) => {
  71.               const codeElement = scriptElement.querySelector(`#script-${script._id}`);
  72.               codeElement.textContent = scriptContent;
  73.               hljs.highlightElement(codeElement);
  74.             })
  75.             .catch((error) => {
  76.               console.error(`Error fetching script content for ${script.title}:`, error);
  77.             });
  78.  
  79.           scriptsContainer.appendChild(scriptElement);
  80.         });
  81.       })
  82.       .catch((error) => {
  83.         console.error("Error fetching scripts:", error);
  84.       });
  85.  
  86.     // Function to copy script content to clipboard
  87.     function copyToClipboard(elementId) {
  88.       const codeElement = document.getElementById(elementId);
  89.       const textArea = document.createElement("textarea");
  90.       textArea.value = codeElement.textContent;
  91.       document.body.appendChild(textArea);
  92.       textArea.select();
  93.       document.execCommand("copy");
  94.       document.body.removeChild(textArea);
  95.       alert("Script copied to clipboard!");
  96.     }
  97.   </script>
  98. </body>
  99. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement