Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Rscripts App</title>
- <script src="https://cdn.tailwindcss.com"></script>
- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css">
- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.3.1/styles/default.min.css">
- <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.3.1/highlight.min.js"></script>
- <script>hljs.highlightAll();</script>
- </head>
- <body class="bg-gray-900 text-white">
- <header class="flex items-center justify-between p-4 bg-gray-800 shadow-lg">
- <div class="flex items-center space-x-4">
- <img src="https://storage.googleapis.com/a1aa/image/az8sE4pcRWZgH5h3TFqfsTKQaxJRQbje1IaOlnD3b6ekxYGoA.jpg" alt="Logo" class="w-10 h-10">
- <h1 class="text-2xl font-bold">Rscripts</h1>
- </div>
- <div class="flex items-center space-x-4">
- <div class="relative">
- <input type="text" placeholder="Search scripts..." class="bg-gray-700 text-white rounded-full pl-10 pr-4 py-2 focus:outline-none">
- <i class="fas fa-search absolute left-3 top-2.5 text-gray-400"></i>
- </div>
- <img src="https://storage.googleapis.com/a1aa/image/gnwxZ7YNIfzxbCYtBomYSVVv2l2LnAcRc06WXJX1cvCaMmBKA.jpg" alt="User Avatar" class="w-10 h-10 rounded-full">
- </div>
- </header>
- <main class="p-4">
- <div id="scripts-container" class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6">
- <!-- Scripts will be dynamically inserted here -->
- </div>
- </main>
- <script>
- // Fetch and display scripts
- fetch("https://rscripts.net/api/v2/scripts?page=1&orderBy=date&sort=desc")
- .then((response) => response.json())
- .then((data) => {
- const scriptsContainer = document.getElementById("scripts-container");
- data.scripts.forEach((script) => {
- const hasUser = script.user;
- const profilePicture = hasUser && script.user.image ? script.user.image : "https://i.pravatar.cc/300";
- const username = hasUser ? script.user.username : script.creator;
- const scriptElement = document.createElement("div");
- scriptElement.classList.add("bg-gray-800", "p-6", "rounded-lg", "shadow-lg", "hover:shadow-xl", "transition-shadow", "duration-300");
- scriptElement.innerHTML = `
- <img src="${script.image}" alt="${script.title}" class="w-full h-40 object-cover rounded-lg mb-4">
- <div class="flex justify-between items-center mb-4">
- <span class="text-gray-400"><i class="fas fa-eye"></i> ${script.views}</span>
- <span class="text-gray-400">${new Date(script.createdAt).toLocaleString()}</span>
- </div>
- <p class="text-red-500 mb-2">${script.category}</p>
- <h2 class="text-xl font-bold mb-2">${script.title}</h2>
- <p class="mb-4">${script.description}</p>
- <div class="flex items-center space-x-2 mb-4">
- <img src="${profilePicture}" alt="Profile picture of ${username}" class="w-10 h-10 rounded-full">
- <p>Creator: ${username}</p>
- </div>
- <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>
- <div class="flex justify-between mt-4">
- <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>
- <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>
- </div>
- `;
- const downloadUrl = script.rawScript;
- // Fetch and display the script content
- fetch(downloadUrl)
- .then((response) => response.text())
- .then((scriptContent) => {
- const codeElement = scriptElement.querySelector(`#script-${script._id}`);
- codeElement.textContent = scriptContent;
- hljs.highlightElement(codeElement);
- })
- .catch((error) => {
- console.error(`Error fetching script content for ${script.title}:`, error);
- });
- scriptsContainer.appendChild(scriptElement);
- });
- })
- .catch((error) => {
- console.error("Error fetching scripts:", error);
- });
- // Function to copy script content to clipboard
- function copyToClipboard(elementId) {
- const codeElement = document.getElementById(elementId);
- const textArea = document.createElement("textarea");
- textArea.value = codeElement.textContent;
- document.body.appendChild(textArea);
- textArea.select();
- document.execCommand("copy");
- document.body.removeChild(textArea);
- alert("Script copied to clipboard!");
- }
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement