please use this for an advertising spot between swipes. or every 3 swipes or soemthing
Browse files
script.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
|
| 2 |
class RabbitHole {
|
| 3 |
-
constructor() {
|
| 4 |
this.titleEl = document.getElementById('title');
|
| 5 |
this.extractEl = document.getElementById('extract');
|
| 6 |
this.metaEl = document.getElementById('meta');
|
|
@@ -16,6 +16,7 @@ constructor() {
|
|
| 16 |
this.currentIndex = -1;
|
| 17 |
this.user = null;
|
| 18 |
this.insights = [];
|
|
|
|
| 19 |
this.analytics = {
|
| 20 |
totalArticles: 0,
|
| 21 |
totalTime: 0,
|
|
@@ -25,8 +26,7 @@ constructor() {
|
|
| 25 |
|
| 26 |
this.init();
|
| 27 |
}
|
| 28 |
-
|
| 29 |
-
init() {
|
| 30 |
this.createParticles();
|
| 31 |
this.bindEvents();
|
| 32 |
this.animateEntrance();
|
|
@@ -72,10 +72,15 @@ createParticles() {
|
|
| 72 |
return;
|
| 73 |
}
|
| 74 |
if (!this.started) return;
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
|
| 80 |
// Keyboard navigation
|
| 81 |
document.addEventListener('keydown', e => {
|
|
@@ -104,6 +109,11 @@ createParticles() {
|
|
| 104 |
}
|
| 105 |
async fetchRandomArticle() {
|
| 106 |
try {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 107 |
this.setLoading(true);
|
| 108 |
this.clearError();
|
| 109 |
this.showRabbitAnimation();
|
|
@@ -126,6 +136,11 @@ createParticles() {
|
|
| 126 |
if (!this.outgoingLinks.length) return this.fetchRandomArticle();
|
| 127 |
const next = this.outgoingLinks[Math.floor(Math.random() * this.outgoingLinks.length)];
|
| 128 |
try {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 129 |
this.setLoading(true);
|
| 130 |
this.clearError();
|
| 131 |
this.showRabbitAnimation();
|
|
@@ -267,16 +282,21 @@ startExperience() {
|
|
| 267 |
video.currentTime = 0;
|
| 268 |
}, 2500); // Extended from 1000ms to 2500ms
|
| 269 |
}
|
| 270 |
-
handleArrowRight() {
|
| 271 |
if (!this.started) this.startExperience();
|
| 272 |
-
else
|
|
|
|
|
|
|
|
|
|
| 273 |
}
|
| 274 |
|
| 275 |
handleArrowLeft() {
|
| 276 |
-
if (this.started)
|
|
|
|
|
|
|
|
|
|
| 277 |
}
|
| 278 |
-
|
| 279 |
-
shareExperience() {
|
| 280 |
if (navigator.share) {
|
| 281 |
navigator.share({
|
| 282 |
title: 'QuantumRabbitHole Explorer',
|
|
@@ -338,7 +358,47 @@ handleArrowRight() {
|
|
| 338 |
}
|
| 339 |
}
|
| 340 |
}
|
| 341 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 342 |
const text = page.extract?.toLowerCase() || '';
|
| 343 |
const card = document.getElementById('card');
|
| 344 |
|
|
|
|
| 1 |
|
| 2 |
class RabbitHole {
|
| 3 |
+
constructor() {
|
| 4 |
this.titleEl = document.getElementById('title');
|
| 5 |
this.extractEl = document.getElementById('extract');
|
| 6 |
this.metaEl = document.getElementById('meta');
|
|
|
|
| 16 |
this.currentIndex = -1;
|
| 17 |
this.user = null;
|
| 18 |
this.insights = [];
|
| 19 |
+
this.swipeCount = 0;
|
| 20 |
this.analytics = {
|
| 21 |
totalArticles: 0,
|
| 22 |
totalTime: 0,
|
|
|
|
| 26 |
|
| 27 |
this.init();
|
| 28 |
}
|
| 29 |
+
init() {
|
|
|
|
| 30 |
this.createParticles();
|
| 31 |
this.bindEvents();
|
| 32 |
this.animateEntrance();
|
|
|
|
| 72 |
return;
|
| 73 |
}
|
| 74 |
if (!this.started) return;
|
| 75 |
+
if (dx > 60) {
|
| 76 |
+
this.swipeCount++;
|
| 77 |
+
this.fetchLinkedArticle();
|
| 78 |
+
}
|
| 79 |
+
if (dx < -60) {
|
| 80 |
+
this.swipeCount++;
|
| 81 |
+
this.fetchRandomArticle();
|
| 82 |
+
}
|
| 83 |
+
});
|
| 84 |
|
| 85 |
// Keyboard navigation
|
| 86 |
document.addEventListener('keydown', e => {
|
|
|
|
| 109 |
}
|
| 110 |
async fetchRandomArticle() {
|
| 111 |
try {
|
| 112 |
+
// Check if we should show ad
|
| 113 |
+
if (this.swipeCount > 0 && this.swipeCount % 3 === 0) {
|
| 114 |
+
await this.showAdvertisement();
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
this.setLoading(true);
|
| 118 |
this.clearError();
|
| 119 |
this.showRabbitAnimation();
|
|
|
|
| 136 |
if (!this.outgoingLinks.length) return this.fetchRandomArticle();
|
| 137 |
const next = this.outgoingLinks[Math.floor(Math.random() * this.outgoingLinks.length)];
|
| 138 |
try {
|
| 139 |
+
// Check if we should show ad
|
| 140 |
+
if (this.swipeCount > 0 && this.swipeCount % 3 === 0) {
|
| 141 |
+
await this.showAdvertisement();
|
| 142 |
+
}
|
| 143 |
+
|
| 144 |
this.setLoading(true);
|
| 145 |
this.clearError();
|
| 146 |
this.showRabbitAnimation();
|
|
|
|
| 282 |
video.currentTime = 0;
|
| 283 |
}, 2500); // Extended from 1000ms to 2500ms
|
| 284 |
}
|
| 285 |
+
handleArrowRight() {
|
| 286 |
if (!this.started) this.startExperience();
|
| 287 |
+
else {
|
| 288 |
+
this.swipeCount++;
|
| 289 |
+
this.fetchLinkedArticle();
|
| 290 |
+
}
|
| 291 |
}
|
| 292 |
|
| 293 |
handleArrowLeft() {
|
| 294 |
+
if (this.started) {
|
| 295 |
+
this.swipeCount++;
|
| 296 |
+
this.fetchRandomArticle();
|
| 297 |
+
}
|
| 298 |
}
|
| 299 |
+
shareExperience() {
|
|
|
|
| 300 |
if (navigator.share) {
|
| 301 |
navigator.share({
|
| 302 |
title: 'QuantumRabbitHole Explorer',
|
|
|
|
| 358 |
}
|
| 359 |
}
|
| 360 |
}
|
| 361 |
+
|
| 362 |
+
async showAdvertisement() {
|
| 363 |
+
return new Promise((resolve) => {
|
| 364 |
+
const adOverlay = document.createElement('div');
|
| 365 |
+
adOverlay.className = 'ad-overlay';
|
| 366 |
+
adOverlay.innerHTML = `
|
| 367 |
+
<div class="ad-content">
|
| 368 |
+
<div class="ad-header">
|
| 369 |
+
<span class="ad-badge">Sponsored</span>
|
| 370 |
+
<button class="ad-close">×</button>
|
| 371 |
+
</div>
|
| 372 |
+
<div class="ad-body">
|
| 373 |
+
<img src="https://static.photos/technology/320x240/42" alt="Advertisement" class="ad-image">
|
| 374 |
+
<h3 class="ad-title">Discover More with Quantum Explorer</h3>
|
| 375 |
+
<p class="ad-description">Unlock premium features and ad-free experience with our Pro plan!</p>
|
| 376 |
+
<button class="ad-cta">Learn More</button>
|
| 377 |
+
</div>
|
| 378 |
+
</div>
|
| 379 |
+
`;
|
| 380 |
+
|
| 381 |
+
document.body.appendChild(adOverlay);
|
| 382 |
+
|
| 383 |
+
const closeAd = () => {
|
| 384 |
+
adOverlay.classList.add('fade-out');
|
| 385 |
+
setTimeout(() => {
|
| 386 |
+
document.body.removeChild(adOverlay);
|
| 387 |
+
resolve();
|
| 388 |
+
}, 300);
|
| 389 |
+
};
|
| 390 |
+
|
| 391 |
+
adOverlay.querySelector('.ad-close').addEventListener('click', closeAd);
|
| 392 |
+
adOverlay.querySelector('.ad-cta').addEventListener('click', () => {
|
| 393 |
+
window.open('https://example.com/pro-plan', '_blank');
|
| 394 |
+
closeAd();
|
| 395 |
+
});
|
| 396 |
+
|
| 397 |
+
// Auto-close after 5 seconds
|
| 398 |
+
setTimeout(closeAd, 5000);
|
| 399 |
+
});
|
| 400 |
+
}
|
| 401 |
+
setContentBackground(page) {
|
| 402 |
const text = page.extract?.toLowerCase() || '';
|
| 403 |
const card = document.getElementById('card');
|
| 404 |
|
style.css
CHANGED
|
@@ -483,6 +483,116 @@ user-profile {
|
|
| 483 |
history-modal {
|
| 484 |
display: none;
|
| 485 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 486 |
/* Loading states */
|
| 487 |
.loading {
|
| 488 |
opacity: 0.8;
|
|
|
|
| 483 |
history-modal {
|
| 484 |
display: none;
|
| 485 |
}
|
| 486 |
+
|
| 487 |
+
/* Advertisement overlay styles */
|
| 488 |
+
.ad-overlay {
|
| 489 |
+
position: fixed;
|
| 490 |
+
top: 0;
|
| 491 |
+
left: 0;
|
| 492 |
+
width: 100%;
|
| 493 |
+
height: 100%;
|
| 494 |
+
background: rgba(14, 15, 17, 0.95);
|
| 495 |
+
display: flex;
|
| 496 |
+
align-items: center;
|
| 497 |
+
justify-content: center;
|
| 498 |
+
z-index: 2000;
|
| 499 |
+
animation: fadeIn 0.3s ease;
|
| 500 |
+
}
|
| 501 |
+
|
| 502 |
+
.ad-content {
|
| 503 |
+
background: #1a1c20;
|
| 504 |
+
border: 2px solid var(--rabbithole-accent);
|
| 505 |
+
border-radius: 1rem;
|
| 506 |
+
padding: 1.5rem;
|
| 507 |
+
width: 90%;
|
| 508 |
+
max-width: 400px;
|
| 509 |
+
box-shadow: 0 0 40px var(--rabbithole-glow);
|
| 510 |
+
}
|
| 511 |
+
|
| 512 |
+
.ad-header {
|
| 513 |
+
display: flex;
|
| 514 |
+
justify-content: space-between;
|
| 515 |
+
align-items: center;
|
| 516 |
+
margin-bottom: 1rem;
|
| 517 |
+
}
|
| 518 |
+
|
| 519 |
+
.ad-badge {
|
| 520 |
+
background: var(--rabbithole-accent);
|
| 521 |
+
color: white;
|
| 522 |
+
padding: 0.25rem 0.75rem;
|
| 523 |
+
border-radius: 1rem;
|
| 524 |
+
font-size: 0.8rem;
|
| 525 |
+
font-weight: 600;
|
| 526 |
+
}
|
| 527 |
+
|
| 528 |
+
.ad-close {
|
| 529 |
+
background: none;
|
| 530 |
+
border: none;
|
| 531 |
+
color: var(--rabbithole-muted);
|
| 532 |
+
font-size: 1.5rem;
|
| 533 |
+
cursor: pointer;
|
| 534 |
+
padding: 0;
|
| 535 |
+
width: 30px;
|
| 536 |
+
height: 30px;
|
| 537 |
+
display: flex;
|
| 538 |
+
align-items: center;
|
| 539 |
+
justify-content: center;
|
| 540 |
+
}
|
| 541 |
+
|
| 542 |
+
.ad-close:hover {
|
| 543 |
+
color: var(--rabbithole-fg);
|
| 544 |
+
}
|
| 545 |
+
|
| 546 |
+
.ad-body {
|
| 547 |
+
text-align: center;
|
| 548 |
+
}
|
| 549 |
+
|
| 550 |
+
.ad-image {
|
| 551 |
+
width: 100%;
|
| 552 |
+
height: 180px;
|
| 553 |
+
object-fit: cover;
|
| 554 |
+
border-radius: 0.5rem;
|
| 555 |
+
margin-bottom: 1rem;
|
| 556 |
+
}
|
| 557 |
+
|
| 558 |
+
.ad-title {
|
| 559 |
+
color: var(--rabbithole-fg);
|
| 560 |
+
margin: 0 0 0.5rem 0;
|
| 561 |
+
font-size: 1.2rem;
|
| 562 |
+
}
|
| 563 |
+
|
| 564 |
+
.ad-description {
|
| 565 |
+
color: var(--rabbithole-muted);
|
| 566 |
+
margin: 0 0 1.5rem 0;
|
| 567 |
+
font-size: 0.9rem;
|
| 568 |
+
line-height: 1.4;
|
| 569 |
+
}
|
| 570 |
+
|
| 571 |
+
.ad-cta {
|
| 572 |
+
background: linear-gradient(135deg, var(--rabbithole-accent), var(--rabbithole-accent2));
|
| 573 |
+
color: white;
|
| 574 |
+
border: none;
|
| 575 |
+
padding: 0.75rem 2rem;
|
| 576 |
+
border-radius: 2rem;
|
| 577 |
+
font-weight: 600;
|
| 578 |
+
cursor: pointer;
|
| 579 |
+
transition: all 0.3s var(--rabbithole-easing);
|
| 580 |
+
width: 100%;
|
| 581 |
+
}
|
| 582 |
+
|
| 583 |
+
.ad-cta:hover {
|
| 584 |
+
transform: translateY(-2px);
|
| 585 |
+
box-shadow: 0 0 20px var(--rabbithole-glow);
|
| 586 |
+
}
|
| 587 |
+
|
| 588 |
+
.fade-out {
|
| 589 |
+
animation: fadeOut 0.3s ease forwards;
|
| 590 |
+
}
|
| 591 |
+
|
| 592 |
+
@keyframes fadeOut {
|
| 593 |
+
from { opacity: 1; }
|
| 594 |
+
to { opacity: 0; }
|
| 595 |
+
}
|
| 596 |
/* Loading states */
|
| 597 |
.loading {
|
| 598 |
opacity: 0.8;
|