Update index.html
Browse files- index.html +27 -14
index.html
CHANGED
|
@@ -90,6 +90,16 @@
|
|
| 90 |
@keyframes spin {
|
| 91 |
to { transform: rotate(360deg); }
|
| 92 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
</style>
|
| 94 |
</head>
|
| 95 |
<body class="min-h-screen">
|
|
@@ -174,12 +184,12 @@
|
|
| 174 |
|
| 175 |
// Function to check Tor connection
|
| 176 |
function checkTorConnection() {
|
| 177 |
-
//
|
| 178 |
-
fetch('
|
| 179 |
method: 'GET',
|
| 180 |
mode: 'no-cors'
|
| 181 |
})
|
| 182 |
-
.then(
|
| 183 |
// If we get here, we're probably not using Tor (since the request would fail otherwise)
|
| 184 |
showTorStatus(false);
|
| 185 |
})
|
|
@@ -202,7 +212,7 @@
|
|
| 202 |
// If the image fails to load, we're not using Tor
|
| 203 |
showTorStatus(false);
|
| 204 |
};
|
| 205 |
-
img.src = 'https://duckduckgogg42xjoc72x3sjasowoarfbgcmvfimaftt6twagswzczad.onion/static-assets/favicons/DDG-icon_256x256.png'
|
| 206 |
}
|
| 207 |
|
| 208 |
// Update UI based on Tor status
|
|
@@ -242,11 +252,12 @@
|
|
| 242 |
loadingIndicator.classList.remove('hidden');
|
| 243 |
noResults.classList.add('hidden');
|
| 244 |
|
| 245 |
-
//
|
|
|
|
| 246 |
const proxyUrl = 'https://cors-anywhere.herokuapp.com/';
|
| 247 |
-
const searchUrl = `
|
| 248 |
|
| 249 |
-
fetch(
|
| 250 |
headers: {
|
| 251 |
'X-Requested-With': 'XMLHttpRequest'
|
| 252 |
}
|
|
@@ -256,18 +267,20 @@
|
|
| 256 |
return response.text();
|
| 257 |
})
|
| 258 |
.then(html => {
|
| 259 |
-
//
|
| 260 |
const parser = new DOMParser();
|
| 261 |
const doc = parser.parseFromString(html, 'text/html');
|
| 262 |
|
| 263 |
-
// Extract results
|
| 264 |
-
const resultElements = doc.querySelectorAll('.result');
|
| 265 |
|
| 266 |
if (resultElements.length > 0) {
|
| 267 |
resultElements.forEach(result => {
|
| 268 |
-
const
|
| 269 |
-
const
|
| 270 |
-
const
|
|
|
|
|
|
|
| 271 |
|
| 272 |
// Create result card
|
| 273 |
const resultCard = document.createElement('div');
|
|
@@ -298,5 +311,5 @@
|
|
| 298 |
setInterval(checkTorConnection, 30000);
|
| 299 |
});
|
| 300 |
</script>
|
| 301 |
-
|
| 302 |
</html>
|
|
|
|
| 90 |
@keyframes spin {
|
| 91 |
to { transform: rotate(360deg); }
|
| 92 |
}
|
| 93 |
+
|
| 94 |
+
.truncate {
|
| 95 |
+
white-space: nowrap;
|
| 96 |
+
overflow: hidden;
|
| 97 |
+
text-overflow: ellipsis;
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
.hidden {
|
| 101 |
+
display: none;
|
| 102 |
+
}
|
| 103 |
</style>
|
| 104 |
</head>
|
| 105 |
<body class="min-h-screen">
|
|
|
|
| 184 |
|
| 185 |
// Function to check Tor connection
|
| 186 |
function checkTorConnection() {
|
| 187 |
+
// First method: Check if we can access a Tor-only resource
|
| 188 |
+
fetch('http://check.torproject.org/', {
|
| 189 |
method: 'GET',
|
| 190 |
mode: 'no-cors'
|
| 191 |
})
|
| 192 |
+
.then(response => {
|
| 193 |
// If we get here, we're probably not using Tor (since the request would fail otherwise)
|
| 194 |
showTorStatus(false);
|
| 195 |
})
|
|
|
|
| 212 |
// If the image fails to load, we're not using Tor
|
| 213 |
showTorStatus(false);
|
| 214 |
};
|
| 215 |
+
img.src = 'https://duckduckgogg42xjoc72x3sjasowoarfbgcmvfimaftt6twagswzczad.onion/static-assets/favicons/DDG-icon_256x256.png'
|
| 216 |
}
|
| 217 |
|
| 218 |
// Update UI based on Tor status
|
|
|
|
| 252 |
loadingIndicator.classList.remove('hidden');
|
| 253 |
noResults.classList.add('hidden');
|
| 254 |
|
| 255 |
+
// Use a proxy to bypass CORS since ahmia.fi doesn't allow direct access
|
| 256 |
+
// Note: In a real Tor environment, you would directly query the .onion version of ahmia
|
| 257 |
const proxyUrl = 'https://cors-anywhere.herokuapp.com/';
|
| 258 |
+
const searchUrl = `http://juhanurmihxlp77nkq76byazcldy2hlmovfu2epvl5ankdibsot4csyd.onion/search/?q=${encodeURIComponent(query)}`;
|
| 259 |
|
| 260 |
+
fetch(searchUrl, {
|
| 261 |
headers: {
|
| 262 |
'X-Requested-With': 'XMLHttpRequest'
|
| 263 |
}
|
|
|
|
| 267 |
return response.text();
|
| 268 |
})
|
| 269 |
.then(html => {
|
| 270 |
+
// Create a temporary DOM parser to extract results
|
| 271 |
const parser = new DOMParser();
|
| 272 |
const doc = parser.parseFromString(html, 'text/html');
|
| 273 |
|
| 274 |
+
// Extract results - using different selectors since ahmia.fi structure may have changed
|
| 275 |
+
const resultElements = doc.querySelectorAll('.search-result');
|
| 276 |
|
| 277 |
if (resultElements.length > 0) {
|
| 278 |
resultElements.forEach(result => {
|
| 279 |
+
const titleElement = result.querySelector('h4 a') || result.querySelector('h3 a') || result.querySelector('a');
|
| 280 |
+
const title = titleElement ? titleElement.textContent : 'No title';
|
| 281 |
+
const url = titleElement ? titleElement.href : '#';
|
| 282 |
+
const descriptionElement = result.querySelector('p') || result.querySelector('.description');
|
| 283 |
+
const description = descriptionElement ? descriptionElement.textContent : 'No description available';
|
| 284 |
|
| 285 |
// Create result card
|
| 286 |
const resultCard = document.createElement('div');
|
|
|
|
| 311 |
setInterval(checkTorConnection, 30000);
|
| 312 |
});
|
| 313 |
</script>
|
| 314 |
+
</body>
|
| 315 |
</html>
|