PageSourceSearch

https://toomuchrock.com/js/donation-popup.js

js toomuchrock.com collected 2026-10-02 09:56:55 UTC 1,649 bytes, 56 lines download raw bytes

1(function () {
2  let hasScrolledNearBottom = false;
3  let hasSpentEnoughTime = false;
4  let popupShown = false;
5
6  // Timer: after 60 seconds
7  setTimeout(() => {
8    hasSpentEnoughTime = true;
9    checkConditions();
10  }, 60000); // 60 seconds
11
12  // Scroll detection — triggers when within 100px of bottom
13  const url = window.location.href.toLowerCase();
14
15  if (url.includes('podcast')) {
16    // On podcast pages, assume scrolled near bottom immediately
17    hasScrolledNearBottom = true;
18  } else {
19    // For other pages, wait for actual scroll near bottom
20    window.addEventListener('scroll', () => {
21      const scrollY = window.scrollY + window.innerHeight;
22      const pageHeight = document.documentElement.scrollHeight;
23      if (pageHeight - scrollY <= 100) { // within 100px of bottom
24        hasScrolledNearBottom = true;
25        checkConditions();
26      }
27    });
28  }
29
30  // Check both conditions
31  function checkConditions() {
32    if (hasScrolledNearBottom && hasSpentEnoughTime && !popupShown) {
33      popupShown = true;
34      showDonationPopup();
35    }
36  }
37
38  function showDonationPopup() {
39    const popup = document.createElement('div');
40    popup.className = 'donation';
41    popup.innerHTML = `
42  		<strong>Like what you see?</strong><br>
43  		Consider helping Too Much Rock document independent music.
44  		<br><br>
45  		<a href="https://buymeacoffee.com/toomuchrock" target="_blank" class="donate-button">Donate</a>
46  		<button class="close-donation">Close</button>
47	`;
48
49    document.body.appendChild(popup);
50
51    document.querySelector('.close-donation').addEventListener('click', () => {
52      popup.remove();
53    });
54  }
55})();
56

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.