PageSourceSearch

https://www.cinegy.com/modules/bg/bg.js

js cinegy.com collected 2026-10-02 03:13:29 UTC 1,961 bytes, 57 lines download raw bytes

1// bg module
2
3
4export function extendBackgroundIfNeeded() {
5    const main = document.querySelector('main');
6    const bgBox = document.querySelector('.bg_holder .bg-box');
7    const bgElements = bgBox?.querySelectorAll('.bg');
8
9    if (!main || !bgBox || !bgElements || bgElements.length <= 2) {
10        console.warn('Missing required elements or insufficient .bg elements.');
11        return;
12    }
13
14    // === Step 1: Always reset inline styles ===
15    bgBox.style.height = '';
16    for (let i = 2; i < bgElements.length; i++) {
17        bgElements[i].style.top = '';
18    }
19
20    // === Step 2: Measure clean state ===
21    const mainHeight = main.offsetHeight;
22    const mainBottom = main.offsetTop + mainHeight;
23    const boxTop = bgBox.offsetTop;
24    const boxHeight = bgBox.offsetHeight;
25    const boxBottom = boxTop + boxHeight;
26
27    console.log('[BG Debug]');
28    console.log('→ Main height:', mainHeight + 'px');
29    console.log('→ Main bottom:', mainBottom + 'px');
30    console.log('→ BG box current bottom:', boxBottom + 'px');
31    console.log('→ BG box current height:', boxHeight + 'px');
32
33    if (mainHeight <= window.innerHeight) {
34        console.log('→ Main fits viewport. No extension needed.');
35        return;
36    }
37
38    const missingHeight = mainBottom - boxBottom;
39    if (missingHeight <= 0) {
40        console.log('→ BG box already covers the main. No action needed.');
41        return;
42    }
43
44    // === Step 3: Extend + Shift ===
45    const newHeight = boxHeight + missingHeight;
46    bgBox.style.height = newHeight + 'px';
47    console.log('→ BG box extended to:', newHeight + 'px');
48
49    const shiftAmount = missingHeight * 1.9;
50    for (let i = 2; i < bgElements.length; i++) {
51        const el = bgElements[i];
52        const originalTop = parseFloat(getComputedStyle(el).top || '0');
53        el.style.top = (originalTop + shiftAmount) + 'px';
54    }
55
56    console.log('→ Shifted .bg elements [2+] by:', shiftAmount + 'px');
57}

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.