Kemono.su IRS [Internal Redirect Service]

Hate all the redirects to patreon pages when clicking on links listed on user post? Well, this script will allow you to stay on kemono.su without going to pateron and try to redirect to the same post if it was imported.

  1. // ==UserScript==
  2. // @name Kemono.su IRS [Internal Redirect Service]
  3. // @namespace https://greasyfork.org/en/scripts/486390-kemono-su-irs-internal-redirect-service
  4. // @version 0.0.4
  5. // @description Hate all the redirects to patreon pages when clicking on links listed on user post? Well, this script will allow you to stay on kemono.su without going to pateron and try to redirect to the same post if it was imported.
  6. // @author LUXCORP
  7. // @copyright Code provided as is. Do not edit, change or redistribute without my permission.
  8. // @match https://www.kemono.su/*
  9. // @match https://kemono.su/*
  10. // @match https://beta.kemono.su/*
  11. // @icon <$ICON$>
  12. // @grant none
  13. // ==/UserScript==
  14.  
  15.  
  16.  
  17. // Select all the links on the page
  18. var links = document.querySelectorAll('a');
  19. var currentUrl = window.location.href;
  20.  
  21. // Loop through each link
  22. links.forEach(function(link) {
  23. // Get the current href of the link
  24. var currentHref = link.getAttribute('href');
  25. var url = new URL(currentUrl);
  26. var pathnamePartsS = url.pathname.split('/');
  27. var usr = pathnamePartsS[3];
  28. console.log(usr);
  29. // Find the ending ID at the end of the link
  30. var endingId = currentHref.substring(currentHref.lastIndexOf('/')+1);
  31. var eID = endingId.match(/\d{5,12}/g);
  32. if (eID) {
  33. endingId = eID[0];
  34. }
  35. // Replace the domain and path of the link with the new domain and path
  36. let m = currentHref.match(/patreon.com\/posts/g);
  37. var newHref = currentHref;
  38. if (m) {
  39. newHref = currentHref.replace("patreon.com/posts", "kemono.su/patreon/user/" + usr + "/post");
  40. newHref = newHref.slice(0, newHref.lastIndexOf("/") + 1) + endingId;
  41. }
  42. // Update the href of the link with the new value
  43. link.setAttribute("href", newHref);
  44. });