latestBGonStripChat

Enable users to seamlessly access and appreciate the latest backgrounds on SC.

Από την 17/07/2023. Δείτε την τελευταία έκδοση.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         latestBGonStripChat
// @namespace    http://carllx.com/
// @version      0.1.3.1
// @description  Enable users to seamlessly access and appreciate the latest backgrounds on SC.
// @author       carllx
// @include        https://stripchat.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=stripchat.com
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    function replaceTimestamp(url) {
        const timestampRegex = /\d+(?=\/)/;
        const newTimestamp = Math.floor(Date.now() / 1000)-19;
        return url.replace(timestampRegex, newTimestamp);
    }

    function updateSrcInHTML() {
        const divElements = document.querySelectorAll('.image-background__image');
        const viewportWidth = window.innerWidth;
        const viewportHeight = window.innerHeight;
        divElements.forEach((imgElement) => {
            const rect = imgElement.getBoundingClientRect();
            const isInView =
                  rect.top >= 0 &&
                  rect.bottom <= viewportHeight &&
                  rect.left >= 0 &&
                  rect.right <= viewportWidth;
            if (isInView) {
                const src = imgElement.getAttribute('src');
                const newSrc = replaceTimestamp(src);
                imgElement.setAttribute('src', newSrc);
            }
        });
    }
    function executeFunctionEvery5Seconds(fn) {
        const intervalId = setInterval(fn, 3000);
        const eventListener = () => {
            clearInterval(intervalId);
            document.removeEventListener('stop', eventListener);
            // Additional code to handle the 'stop' event if needed
        };
        document.addEventListener('stop', eventListener);
    }

    executeFunctionEvery5Seconds(updateSrcInHTML);

    // document.dispatchEvent(new Event('stop'));

    // HTML button element
    // const button = document.querySelector('#myButton');

    // // Event listener for button click
    // button.addEventListener('click', () => {
    //   const stopEvent = new Event('stop');
    //   document.dispatchEvent(stopEvent);
    // });
    // function updateSrcInHTML() {
    //   const elRoot = document.querySelector('#app > div.main-layout-main-right > div.main-layout-main-content > div > div.index-page.index-page-multiple.page.page-columns > div > div > div > div.multiple-categories-scroll-bar-wrapper > div > div > section')
    //   const divElements = elRoot.querySelectorAll('div');
    //   divElements.forEach((div, index) => {
    //     const imgElement = div.querySelector('a > div.image-background > img');
    //     if (imgElement) {
    //       const src = imgElement.getAttribute('src');
    //       const newSrc = replaceTimestamp(src)
    //       imgElement.setAttribute('src', newSrc); // Replace 'new-src-value' with the desired new src value
    //     }
    //   });
    // }


    // Your code here...
})();