PageSourceSearch

https://www.betting-forum.com/js/bf_livescore/schedule_loader.js?_v=c2657d5c

js betting-forum.com collected 2026-09-24 09:11:09 UTC 3,179 bytes, 93 lines download raw bytes

1
2function bfFetchJson(url) {
3    return new Promise((resolve) => {
4        XF.ajax('GET', url, {}, (data) => {
5            resolve(data);
6        }, { skipDefaultError: true, global: false });
7    });
8}
9
10function addDaysISO(dateISO, offset) {
11    const d = new Date(dateISO + 'T00:00:00Z');
12    d.setUTCDate(d.getUTCDate() + offset);
13    const yyyy = d.getUTCFullYear();
14    const mm = String(d.getUTCMonth()+1).padStart(2,'0');
15    const dd = String(d.getUTCDate()).padStart(2,'0');
16    return `${yyyy}-${mm}-${dd}`;
17}
18
19function localDateISOFromTs(ts) {
20    const d = new Date(ts * 1000);
21    const yyyy = d.getFullYear();
22    const mm = String(d.getMonth()+1).padStart(2,'0');
23    const dd = String(d.getDate()).padStart(2,'0');
24    return `${yyyy}-${mm}-${dd}`;
25}
26
27async function bfLoadScheduleForDate(targetDateISO) {
28    console.log("BF LiveScore: Loading schedule for " + targetDateISO);
29    
30    // --- TIMEZONE FIX: Always fetch 3 Days ---
31    // Instead of guessing, we fetch [Yesterday, Target, Tomorrow].
32    // This covers matches spilling over either edge for ANY timezone.
33    const toFetch = [ 
34        addDaysISO(targetDateISO, -1), 
35        targetDateISO, 
36        addDaysISO(targetDateISO, 1) 
37    ];
38
39    // 2. Fetch only the necessary dates
40    const unique = Array.from(new Set(toFetch));
41    const promises = unique.map(d => bfFetchJson(XF.canonicalizeUrl('score/schedule?date=' + d)));
42    const results = await Promise.all(promises);
43
44    const merged = [];
45    const seen = new Set();
46
47    for (let response of results) {
48        if (!response) continue;
49        let arr = (response.matches && Array.isArray(response.matches)) ? response.matches : response;
50        if (!Array.isArray(arr)) continue;
51
52        for (const fx of arr) {
53            if (!fx || !fx.id) continue;
54            const fid = String(fx.id);
55            if (seen.has(fid)) continue;
56            seen.add(fid);
57            merged.push(fx);
58        }
59    }
60    
61    // 3. Strict Local Filtering (Same as before)
62    const filtered = merged.filter(fx => {
63        if (!fx || !fx.timestamp) return false;
64        const localISO = localDateISOFromTs(fx.timestamp);
65        return (localISO === targetDateISO);
66    });
67
68    // 4. Sort
69    filtered.sort((a, b) => {
70        const rawPA = a.league_priority != null ? parseInt(a.league_priority) : 3;
71        const rawPB = b.league_priority != null ? parseInt(b.league_priority) : 3;
72
73        // NEUTRALIZE TIER 4 -> 3
74        const pA = (rawPA === 4) ? 3 : rawPA;
75        const pB = (rawPB === 4) ? 3 : rawPB;
76
77        if (pA !== pB) return pA - pB;
78
79        const cA = (a.country || "").toUpperCase();
80        const cB = (b.country || "").toUpperCase();
81        if (cA !== cB) return cA.localeCompare(cB);
82        const lA = (a.league || "").toUpperCase();
83        const lB = (b.league || "").toUpperCase();
84        if (lA !== lB) return lA.localeCompare(lB);
85        return (a.timestamp || 0) - (b.timestamp || 0);
86    });
87
88    return filtered;
89}
90
91if (typeof window !== 'undefined') {
92    window.bfLoadScheduleForDate = bfLoadScheduleForDate;
93}

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.