Skip to content

Instantly share code, notes, and snippets.

@aetonsi
Last active December 27, 2023 10:26
Show Gist options
  • Save aetonsi/cfd96b3e8cf2d07a86a5a973f834df1d to your computer and use it in GitHub Desktop.
Save aetonsi/cfd96b3e8cf2d07a86a5a973f834df1d to your computer and use it in GitHub Desktop.
Scrolller Redirect with URL Condition
// ==UserScript==
// @name Scrolller Redirect with NO NAV
// @namespace https://your-namespace.example.com/
// @version 1.0
// @description Redirects to the media URL on Scrolller.com after waiting for the element to appear (excluding URLs with ?NONAV and scrolller.com/r/*)
// @author YourName
// @match https://scrolller.com/*
// @exclude https://scrolller.com/r/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
const intervalTime = 1000; // Interval time in milliseconds (adjust if needed)
let intervalId;
function qMarked(arg, page=location.href) { return page.includes('?') ? `&${arg}` : `?${arg}` }
function redirectToMedia() {
const mediaElement = document.querySelector('.fullscreen-view__media');
if (mediaElement) {
const mediaSrc = mediaElement.currentSrc;
if (mediaSrc) {
clearInterval(intervalId); // Stop the interval once redirected
const m = mediaSrc + qMarked(`from=${encodeURIComponent(location.href)}`, mediaSrc); // save the previous URL in the "url" query param
location = m; // navigate
}
}
}
intervalId = setInterval(redirectToMedia, intervalTime);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment