SleazyFork Redirect

Redirects sleazyfork.org URLs to greatest.deepsurf.us if a specific text is found.

  1. // ==UserScript==
  2. // @name SleazyFork Redirect
  3. // @namespace github.com/lngkidkoolstar
  4. // @version 1.0
  5. // @description Redirects sleazyfork.org URLs to greatest.deepsurf.us if a specific text is found.
  6. // @author longkidkoolstar
  7. // @match https://sleazyfork.org/*
  8. // @license MIT
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. // Function to check and redirect if needed
  16. function checkAndRedirect() {
  17. const section = document.querySelector('section.text-content');
  18. if (section) {
  19. const pElement = section.querySelector('p');
  20. if (pElement && pElement.textContent.trim() === 'This script is not available on this site.') {
  21. // Redirect to GreasyFork
  22. window.location.href = window.location.href.replace('sleazyfork.org', 'greatest.deepsurf.us');
  23. }
  24. }
  25. }
  26.  
  27. // Run the check on page load
  28. checkAndRedirect();
  29.  
  30. // Also run the check when new content is added (for dynamic sites)
  31. const observer = new MutationObserver(mutationsList => {
  32. for (const mutation of mutationsList) {
  33. if (mutation.type === 'childList') {
  34. checkAndRedirect();
  35. break; // Stop checking once a change is detected
  36. }
  37. }
  38. });
  39.  
  40. // Observe changes in the document's body
  41. observer.observe(document.body, { childList: true, subtree: true });
  42. })();