1<!DOCTYPE html>
2<html lang="en">
3
4<head>
5 <meta charset="UTF-8">
6 <meta name="viewport" content="width=device-width, initial-scale=1.0">
7 <title>Scripts</title>
8 <script src="https://cdn.tailwindcss.com"></script>
9 <link rel="icon" href="/assets/favicon.png" type="image/png">
10 <link rel="stylesheet" href="./assets/common.css">
11 <script src="./assets/common.js"></script>
12</head>
13
14<body class="h-screen flex items-center justify-center bg-black flex-col font-black">
15
16 <!-- Warning Modal Section -->
17 <input class="modal-state" id="warning" type="checkbox" />
18 <div class="modal">
19 <div class="modal__inner">
20 <h2 class="text-center">Warning</h2>
21 <p class="modal__p">
22 Kindly use a desktop or laptop for a better experience.
23 </p>
24 </div>
25 </div>
26
27 <!-- Script Detailed Modal -->
28 <div id="script-modal" class="hidden fixed inset-0 bg-black bg-opacity-70 z-50 justify-center items-center">
29 <div class="bg-white text-black p-6 rounded-lg max-w-lg w-full relative">
30 <button id="closeModal" class="absolute top-2 right-2 text-xl font-bold">×</button>
31 <h2 id="modalTitle" class="text-xl font-bold mb-2"></h2>
32 <ul id="modalContent" class="list-disc ml-5 text-sm"></ul>
33 <div class="flex justify-between mt-4 gap-2">
34 <button id="copyExecutionCommand"
35 class="mt-4 p-2 bg-black text-white rounded hover:bg-gray-800 disabled:opacity-50">
36 <svg viewBox="0 -0.5 25 25" class="h-3 w-3 inline-block mr-1 fill-current text-white"
37 xmlns="http://www.w3.org/2000/svg">
38 <path
39 d="M8.25005 8.5C8.25005 8.91421 8.58584 9.25 9.00005 9.25C9.41426 9.25 9.75005 8.91421 9.75005 8.5H8.25005ZM9.00005 8.267H9.75006L9.75004 8.26283L9.00005 8.267ZM9.93892 5.96432L10.4722 6.49171L9.93892 5.96432ZM12.2311 5V4.24999L12.2269 4.25001L12.2311 5ZM16.269 5L16.2732 4.25H16.269V5ZM18.5612 5.96432L18.0279 6.49171V6.49171L18.5612 5.96432ZM19.5 8.267L18.75 8.26283V8.267H19.5ZM19.5 12.233H18.75L18.7501 12.2372L19.5 12.233ZM18.5612 14.5357L18.0279 14.0083L18.5612 14.5357ZM16.269 15.5V16.25L16.2732 16.25L16.269 15.5ZM16 14.75C15.5858 14.75 15.25 15.0858 15.25 15.5C15.25 15.9142 15.5858 16.25 16 16.25V14.75ZM9.00005 9.25C9.41426 9.25 9.75005 8.91421 9.75005 8.5C9.75005 8.08579 9.41426 7.75 9.00005 7.75V9.25ZM8.73105 8.5V7.74999L8.72691 7.75001L8.73105 8.5ZM6.43892 9.46432L6.97218 9.99171L6.43892 9.46432ZM5.50005 11.767H6.25006L6.25004 11.7628L5.50005 11.767ZM5.50005 15.734L6.25005 15.7379V15.734H5.50005ZM8.73105 19L8.72691 19.75H8.73105V19ZM12.769 19V19.75L12.7732 19.75L12.769 19ZM15.0612 18.0357L14.5279 17.5083L15.0612 18.0357ZM16 15.733H15.25L15.2501 15.7372L16 15.733ZM16.75 15.5C16.75 15.0858 16.4143 14.75 16 14.75C15.5858 14.75 15.25 15.0858 15.25 15.5H16.75ZM9.00005 7.75C8.58584 7.75 8.25005 8.08579 8.25005 8.5C8.25005 8.91421 8.58584 9.25 9.00005 9.25V7.75ZM12.7691 8.5L12.7732 7.75H12.7691V8.5ZM15.0612 9.46432L15.5944 8.93694V8.93694L15.0612 9.46432ZM16.0001 11.767L15.2501 11.7628V11.767H16.0001ZM15.2501 15.5C15.2501 15.9142 15.5858 16.25 16.0001 16.25C16.4143 16.25 16.7501 15.9142 16.7501 15.5H15.2501ZM9.75005 8.5V8.267H8.25005V8.5H9.75005ZM9.75004 8.26283C9.74636 7.60005 10.0061 6.96296 10.4722 6.49171L9.40566 5.43694C8.65985 6.19106 8.24417 7.21056 8.25006 8.27117L9.75004 8.26283ZM10.4722 6.49171C10.9382 6.02046 11.5724 5.75365 12.2352 5.74999L12.2269 4.25001C11.1663 4.25587 10.1515 4.68282 9.40566 5.43694L10.4722 6.49171ZM12.2311 5.75H16.269V4.25H12.2311V5.75ZM16.2649 5.74999C16.9277 5.75365 17.5619 6.02046 18.0279 6.49171L19.0944 5.43694C18.3486 4.68282 17.3338 4.25587 16.2732 4.25001L16.2649 5.74999ZM18.0279 6.49171C18.494 6.96296 18.7537 7.60005 18.7501 8.26283L20.25 8.27117C20.2559 7.21056 19.8402 6.19106 19.0944 5.43694L18.0279 6.49171ZM18.75 8.267V12.233H20.25V8.267H18.75ZM18.7501 12.2372C18.7537 12.8999 18.494 13.537 18.0279 14.0083L19.0944 15.0631C19.8402 14.3089 20.2559 13.2894 20.25 12.2288L18.7501 12.2372ZM18.0279 14.0083C17.5619 14.4795 16.9277 14.7463 16.2649 14.75L16.2732 16.25C17.3338 16.2441 18.3486 15.8172 19.0944 15.0631L18.0279 14.0083ZM16.269 14.75H16V16.25H16.269V14.75ZM9.00005 7.75H8.73105V9.25H9.00005V7.75ZM8.72691 7.75001C7.6663 7.75587 6.65146 8.18282 5.90566 8.93694L6.97218 9.99171C7.43824 9.52046 8.07241 9.25365 8.73519 9.24999L8.72691 7.75001ZM5.90566 8.93694C5.15985 9.69106 4.74417 10.7106 4.75006 11.7712L6.25004 11.7628C6.24636 11.1001 6.50612 10.463 6.97218 9.99171L5.90566 8.93694ZM4.75005 11.767V15.734H6.25005V11.767H4.75005ZM4.75006 15.7301C4.73847 17.9382 6.51879 19.7378 8.72691 19.75L8.7352 18.25C7.35533 18.2424 6.2428 17.1178 6.25004 15.7379L4.75006 15.7301ZM8.73105 19.75H12.769V18.25H8.73105V19.75ZM12.7732 19.75C13.8338 19.7441 14.8486 19.3172 15.5944 18.5631L14.5279 17.5083C14.0619 17.9795 13.4277 18.2463 12.7649 18.25L12.7732 19.75ZM15.5944 18.5631C16.3402 17.8089 16.7559 16.7894 16.75 15.7288L15.2501 15.7372C15.2537 16.3999 14.994 17.037 14.5279 17.5083L15.5944 18.5631ZM16.75 15.733V15.5H15.25V15.733H16.75ZM9.00005 9.25H12.7691V7.75H9.00005V9.25ZM12.7649 9.24999C13.4277 9.25365 14.0619 9.52046 14.5279 9.99171L15.5944 8.93694C14.8486 8.18282 13.8338 7.75587 12.7732 7.75001L12.7649 9.24999ZM14.5279 9.99171C14.994 10.463 15.2537 11.1001 15.2501 11.7628L16.75 11.7712C16.7559 10.7106 16.3402 9.69106 15.5944 8.93694L14.5279 9.99171ZM15.2501 11.767V15.5H16.7501V11.767H15.2501Z"
40 />
41 </svg>
42
43 <span>
44 Copy Command
45 </span>
46 </button>
47 <button id="showCodeBtn" class="mt-4 px-3 py-2 bg-black text-white rounded hover:bg-gray-800">
48
49 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512"
50 class="h-3 w-3 inline-block mr-1 fill-current text-white">
51 <path
52 d="M392.8 1.2c-17-4.9-34.7 5-39.6 22l-128 448c-4.9 17 5 34.7 22 39.6s34.7-5 39.6-22l128-448c4.9-17-5-34.7-22-39.6zm80.6 120.1c-12.5 12.5-12.5 32.8 0 45.3L562.7 256l-89.4 89.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0l112-112c12.5-12.5 12.5-32.8 0-45.3l-112-112c-12.5-12.5-32.8-12.5-45.3 0zm-306.7 0c-12.5-12.5-32.8-12.5-45.3 0l-112 112c-12.5 12.5-12.5 32.8 0 45.3l112 112c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L77.3 256l89.4-89.4c12.5-12.5 12.5-32.8 0-45.3z" />
53 </svg>
54 <span>
55 Show Code
56 </span></button>
57 <button id="downloadBtn" class="mt-4 px-3 py-2 bg-black text-white rounded hover:bg-gray-800">
58 <svg xmlns="http://www.w3.org/2000/svg" class="h-3 w-3 inline-block mr-1 fill-current text-white"
59 viewBox="0 0 512 512">
60 <path
61 d="M288 32c0-17.7-14.3-32-32-32s-32 14.3-32 32l0 242.7-73.4-73.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l128 128c12.5 12.5 32.8 12.5 45.3 0l128-128c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L288 274.7 288 32zM64 352c-35.3 0-64 28.7-64 64l0 32c0 35.3 28.7 64 64 64l384 0c35.3 0 64-28.7 64-64l0-32c0-35.3-28.7-64-64-64l-101.5 0-45.3 45.3c-25 25-65.5 25-90.5 0L165.5 352 64 352zm368 56a24 24 0 1 1 0 48 24 24 0 1 1 0-48z" />
62 </svg>
63 <span>
64 Download
65 </span>
66 </button>
67 </div>
68
69 </div>
70 </div>
71
72 <!-- Fullscreen Code Modal -->
73 <div id="code-modal" class="hidden fixed inset-0 z-50 flex flex-col">
74 <div class="flex justify-end p-2 gap-3">
75 <button id="copyCode"
76 class="bg-gray-900 text-white px-4 py-2 rounded hover:bg-gray-800 disabled:opacity-50">
77 copy code
78 </button>
79 <button id="closeCodeModal"
80 class="bg-gray-900 text-white text-3xl font-bold px-3 rounded hover:bg-gray-800">×</button>
81 </div>
82 <div id="editor" class="w-full h-full rounded-md overflow-hidden self-center"></div>
83 </div>
84
85 <!-- Main context -->
86 <img src="./assets/favicon.png" alt="icon" class="w-[100px] h-[100px] mb-1" />
87 <h1 class="text-white text-[30px]">.Scripts.</h1>
88 <div id="scriptsList" class="flex flex-col text-white gap-y-2 p-10"></div>
89
90 <!-- Footer -->
91 <div class="footer">
92 <div class="flex items-center gap-6">
93 <a href="https://github.com/The-Robin-Hood/scripts" target="_blank">
94 <img src="https://cdn.jsdelivr.net/npm/simple-icons@v9/icons/github.svg" class="h-8 w-8" alt="GitHub" />
95 </a>
96 <a href="https://x.com/ansariwtf" target="_blank">
97 <img src="https://cdn.jsdelivr.net/npm/simple-icons@v9/icons/x.svg" class="h-8 w-8" alt="X/Twitter" />
98 </a>
99 </div>
100 </div>
101
102 <script>
103 const scriptsList = document.getElementById('scriptsList');
104 const modal = document.getElementById('script-modal');
105 const modalTitle = document.getElementById('modalTitle');
106 const modalContent = document.getElementById('modalContent');
107 const closeModal = document.getElementById('closeModal');
108 const showCodeBtn = document.getElementById('showCodeBtn');
109 const downloadBtn = document.getElementById('downloadBtn');
110 const copyExecutionCommand = document.getElementById('copyExecutionCommand');
111 const codeModal = document.getElementById('code-modal');
112 const closeCodeModal = document.getElementById('closeCodeModal');
113 const copyCode = document.getElementById('copyCode');
114
115 let currentScript = null;
116
117 closeModal.addEventListener('click', () => modal.classList.add('hidden'));
118 closeCodeModal.addEventListener('click', () => {
119 codeModal.classList.add('hidden');
120 if (monaco.editor.getModels().length > 0) {
121 monaco.editor.getModels()[0].dispose();
122 }
123 const editor = document.getElementById('editor');
124 if (editor.children.length > 0) {
125 editor.innerHTML = '';
126 }
127 });
128
129 fetch('./scripts.json')
130 .then(res => res.json())
131 .then(data => {
132 data.forEach(script => {
133 const label = document.createElement('label');
134 label.textContent = `${script.id}. ${script.title}`;
135 label.className = 'opacity-75 hover:opacity-100 hover:text-yellow-400 cursor-pointer';
136 label.addEventListener('click', () => {
137 currentScript = script;
138 modalTitle.textContent = script.title;
139 if (!script.description) {
140 script.description = 'No description available.';
141 } else if (Array.isArray(script.description)) {
142 script.description = script.description.join('</li><li>');
143 }
144 modalContent.innerHTML = `<li>${script.description || 'No description available.'}</li>`;
145 modal.classList.remove('hidden');
146 modal.classList.add('flex');
147 });
148 scriptsList.appendChild(label);
149 });
150 })
151 .catch(err => console.error('Error loading scripts.json:', err));
152
153 showCodeBtn.addEventListener('click', async () => {
154 if (!currentScript || !currentScript.filename) return;
155 const response = await fetch(`./${currentScript.filename}`);
156 const code = await response.text();
157 codeModal.classList.remove('hidden');
158
159 //delete previous editor instance if exists
160 const editor = document.getElementById('editor');
161 if (editor.children.length > 0) {
162 editor.innerHTML = '';
163 }
164
165 require.config({ paths: { vs: 'https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.52.2/min/vs' } });
166 require(['vs/editor/editor.main'], () => {
167 monaco.editor.defineTheme("myTheme", {
168 base: "vs-dark",
169 inherit: true,
170 rules: [],
171 colors: {
172 "editor.background": "#191a21",
173 },
174 });
175 monaco.editor.setTheme("myTheme");
176
177 monaco.editor.create(document.getElementById('editor'), {
178 value: code,
179 language: `${currentScript.language || 'plaintext'}`,
180 fontSize: 14,
181 minimap: { enabled: false },
182 scrollBeyondLastLine: false,
183 readOnly: true,
184 lineNumbers: false,
185 });
186 });
187 });
188
189 downloadBtn.addEventListener('click', () => {
190 if (!currentScript || !currentScript.filename) return;
191 const link = document.createElement('a');
192 link.href = `./${currentScript.filename}`;
193 link.download = currentScript.filename;
194 document.body.appendChild(link);
195 link.click();
196 document.body.removeChild(link);
197 });
198
199 copyExecutionCommand.addEventListener('click', () => {
200 if (!currentScript || !currentScript.filename) return;
201 const command = `curl -s https://scripts.ansariwtf.sh/${currentScript.filename} | bash`;
202 navigator.clipboard.writeText(command).then(() => {
203 copyExecutionCommand.children[1].textContent = 'Cmnd Copied!';
204 copyExecutionCommand.disabled = true;
205 setTimeout(() => {
206 copyExecutionCommand.children[1].textContent = 'Copy Command';
207 copyExecutionCommand.disabled = false;
208 }, 2000);
209 }).catch(err => {
210 console.error('Failed to copy command:', err);
211 });
212 });
213
214 copyCode.addEventListener('click', () => {
215 const editor = monaco.editor.getModels()[0];
216 if (editor) {
217 const code = editor.getValue();
218 navigator.clipboard.writeText(code).then(() => {
219 copyCode.textContent = 'copied!';
220 copyCode.disabled = true;
221 setTimeout(() => {
222 copyCode.textContent = 'copy code';
223 copyCode.disabled = false;
224 }, 2000);
225 }).catch(err => {
226 console.error('Failed to copy code:', err);
227 });
228 }
229 });
230 </script>
231
232 <script src="https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.34.1/min/vs/loader.min.js"></script>
233</body>
234
235</html>