Greasy Fork is available in English.

Replace Service Links

Replace the patreon links with kemono links for easy navigation. Strictly on Kemono.su

  1. // ==UserScript==
  2. // @name Replace Service Links
  3. // @namespace https://github.com/Official-Husko/violentmonkey-scripts
  4. // @match https://kemono.su/*
  5. // @grant none
  6. // @version 1.0.0
  7. // @license GNU GPLv3
  8. // @author Official Husko
  9. // @icon https://www.pulexart.com/uploads/7/0/1/2/70121829/3-greyfox.png
  10. // @description Replace the patreon links with kemono links for easy navigation. Strictly on Kemono.su
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. // Function to extract meta content by name
  17. function getMetaContentByName(name) {
  18. const metaTag = document.querySelector(`meta[name="${name}"]`);
  19. return metaTag ? metaTag.getAttribute('content') : null;
  20. }
  21.  
  22. // Function to extract numeric part from the right of a string
  23. function extractNumericPartFromRight(inputString) {
  24. const match = inputString.match(/(\d+)$/);
  25. return match ? match[1] : null;
  26. }
  27.  
  28. // Get USER_ID and SERVICE_ID from meta tags
  29. const USER_ID = getMetaContentByName('user');
  30. const SERVICE_ID = getMetaContentByName('service');
  31.  
  32. // Check if USER_ID and SERVICE_ID are available
  33. if (USER_ID && SERVICE_ID) {
  34. // Find and replace Patreon links
  35. document.querySelectorAll('a[href*="patreon.com/posts/"]').forEach(link => {
  36. const match = link.href.match(/https:\/\/(www\.)?patreon\.com\/posts\/(.+)/);
  37. if (match) {
  38. const rawPostID = match[2];
  39. const numericPostID = extractNumericPartFromRight(rawPostID);
  40. // Replace the link with the custom format
  41. if (numericPostID) {
  42. link.href = `https://kemono.su/${SERVICE_ID}/user/${USER_ID}/post/${numericPostID}`;
  43. }
  44. }
  45. });
  46. }
  47. })();