Mobile Pull to Refresh

Adds pull-to-refresh functionality to Funny Junk mobile

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

You will need to install an extension such as Tampermonkey to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name         Mobile Pull to Refresh
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Adds pull-to-refresh functionality to Funny Junk mobile
// @author       EMANON
// @match        *://funnyjunk.com/*
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    let startY = 0;
    const threshold = 150; // Distance in pixels to trigger refresh

    // 1. Capture the starting point of the touch
    window.addEventListener('touchstart', (e) => {
        if (window.scrollY === 0) {
            startY = e.touches[0].pageY;
        }
    }, { passive: true });

    // 2. Track the movement
    window.addEventListener('touchmove', (e) => {
        const touchY = e.touches[0].pageY;
        const pullDistance = touchY - startY;

        // If user pulls down more than the threshold at the top of the page
        if (window.scrollY === 0 && pullDistance > threshold) {
            // Optional: You could add a visual CSS transform here
            console.log("Release to refresh...");
        }
    }, { passive: true });

    // 3. Trigger action on release
    window.addEventListener('touchend', (e) => {
        const touchY = e.changedTouches[0].pageY;
        const pullDistance = touchY - startY;

        if (window.scrollY === 0 && pullDistance > threshold) {
            // Perform the refresh
            location.reload();
        }
        // Reset startY
        startY = 0;
    });
})();